diff --git a/Changes.md b/Changes.md index cabbed6a5a..a03a48c554 100644 --- a/Changes.md +++ b/Changes.md @@ -1,5 +1,62 @@ # Build System Changes for Android.mk Writers +## Gensrcs starts disallowing depfile property + +To migrate all gensrcs to Bazel, we are restricting the use of depfile property +because Bazel requires specifying the dependencies directly. + +To fix existing uses, remove depfile and directly specify all the dependencies +in .bp files. For example: + +``` +gensrcs { + name: "framework-cppstream-protos", + tools: [ + "aprotoc", + "protoc-gen-cppstream", + ], + cmd: "mkdir -p $(genDir)/$(in) " + + "&& $(location aprotoc) " + + " --plugin=$(location protoc-gen-cppstream) " + + " -I . " + + " $(in) ", + srcs: [ + "bar.proto", + ], + output_extension: "srcjar", +} +``` +where `bar.proto` imports `external.proto` would become + +``` +gensrcs { + name: "framework-cppstream-protos", + tools: [ + "aprotoc", + "protoc-gen-cpptream", + ], + tool_files: [ + "external.proto", + ], + cmd: "mkdir -p $(genDir)/$(in) " + + "&& $(location aprotoc) " + + " --plugin=$(location protoc-gen-cppstream) " + + " $(in) ", + srcs: [ + "bar.proto", + ], + output_extension: "srcjar", +} +``` +as in https://android-review.googlesource.com/c/platform/frameworks/base/+/2125692/. + +`BUILD_BROKEN_DEPFILE` can be used to allowlist usage of depfile in `gensrcs`. + +If `depfile` is needed for generating javastream proto, `java_library` with `proto.type` +set `stream` is the alternative solution. Sees +https://android-review.googlesource.com/c/platform/packages/modules/Permission/+/2118004/ +for an example. + ## Genrule starts disallowing directory inputs To better specify the inputs to the build, we are restricting use of directories diff --git a/core/board_config.mk b/core/board_config.mk index 8074225ba1..d2803490f8 100644 --- a/core/board_config.mk +++ b/core/board_config.mk @@ -174,6 +174,7 @@ _board_strip_list += ODM_MANIFEST_SKUS _build_broken_var_list := \ + BUILD_BROKEN_DEPFILE \ BUILD_BROKEN_DUP_RULES \ BUILD_BROKEN_DUP_SYSPROP \ BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES \ diff --git a/core/soong_config.mk b/core/soong_config.mk index 9b5cd1e27d..feffcc7bba 100644 --- a/core/soong_config.mk +++ b/core/soong_config.mk @@ -274,6 +274,7 @@ $(call add_json_str, PrebuiltHiddenApiDir, $(BOARD_PREBUILT_HIDDENAPI_DIR)) $(call add_json_str, ShippingApiLevel, $(PRODUCT_SHIPPING_API_LEVEL)) +$(call add_json_bool, BuildBrokenDepfile, $(filter true,$(BUILD_BROKEN_DEPFILE))) $(call add_json_bool, BuildBrokenEnforceSyspropOwner, $(filter true,$(BUILD_BROKEN_ENFORCE_SYSPROP_OWNER))) $(call add_json_bool, BuildBrokenTrebleSyspropNeverallow, $(filter true,$(BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW))) $(call add_json_bool, BuildBrokenVendorPropertyNamespace, $(filter true,$(BUILD_BROKEN_VENDOR_PROPERTY_NAMESPACE)))