AndroidR 修改framework后如何快速模块编译

AndroidR 修改framework后如何快速模块编译

最近工作安排android大版本升级,需要将androidQ上的framework修改移植到androidR上。

移植后,整个工程全部make编译太耗费时间了,于是经验性的使用模块编译命令make framework进行模块单编。然而,虽然提示编译成功,但在out目录下并没有相应的framework.jar包生成。看来android11在此处进行了改动。

对比androidQ和androidR的frameworks/base/Android.bp文件,发现Android.bp文件做了不小的修改。

撷取其中一段对我们编译有帮助的配置及注释,如下:

java_library {
     
    name: "framework-minus-apex",
    defaults: ["framework-defaults"],
    srcs: [":framework-non-updatable-sources"],
    installable: true,
    javac_shard_size: 150,
    required: [
        "framework-platform-compat-config",
        "libcore-platform-compat-config",
        "services-platform-compat-config",
        "documents-ui-compat-config",
    ],
    libs: ["framework-updatable-stubs-module_libs_api"],
    static_libs: [
        // If MimeMap ever becomes its own APEX, then this dependency would need to be removed
        // in favor of an API stubs dependency in java_library "framework" below.
        "mimemap",
    ],
    // For backwards compatibility.
    stem: "framework",
    apex_available: ["//apex_available:platform"],
    visibility: [
        "//frameworks/base",
        // TODO(b/147128803) remove the below lines
        "//frameworks/base/apex/blobstore/framework",
        "//frameworks/base/apex/jobscheduler/framework",
        "//frameworks/base/packages/Tethering/tests/unit",
    ],
}

// This "framework" module is NOT installed to the device. It's
// "framework-minus-apex" that gets installed to the device. Note that
// the filename is still framework.jar (via the stem property) for
// compatibility reason. The purpose of this module is to provide
// framework APIs (both public and private) for bundled apps.
// "framework-minus-apex" can't be used for the purpose because 1)
// many apps have already hardcoded the name "framework" and
// 2) it lacks API symbols from updatable modules - as it's clear from
// its suffix "-minus-apex".
java_library {
     
    name: "framework",
    defaults: ["framework-aidl-export-defaults"],
    installable: false, // this lib is a build-only library
    static_libs: [
        "app-compat-annotations",
        "framework-minus-apex",
        "framework-updatable-stubs-module_libs_api",
    ],
    sdk_version: "core_platform",
    apex_available: ["//apex_available:platform"],
}

通过反复理解此bp文件,对谷歌工程师的想法似乎可以揣摩一二了。

于是尝试采用下面的模块编译命令(可以加-j8/-j16指定编译线程数):

make framework-minus-apex

果不其然,顺利编译出了frameowrk.jar包:

[100% 1155/1155] Install: out/target/product/PorjectAndroidR/system/framework/framework.jar
#### build completed successfully (04:50 (mm:ss)) ####

为文以记之。

2020年12月末,于青岛。

感谢:
[1]: https://blog.csdn.net/zhzhangnews/article/details/105634037

你可能感兴趣的:(android,framework,makefile)