diff options
author | Paul Duffin <paulduffin@google.com> | 2022-07-27 00:51:36 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-07-27 00:51:36 +0000 |
commit | 574c7d88e88fa4dbd6c7471ff99064ca408ad58f (patch) | |
tree | deec59e87c698f6271e0b8cf73bdd2f9a2c35de6 | |
parent | d5b0d18b4330dbc2c33af95ff793c7fad7180df2 (diff) | |
parent | f3c17ef416378163a542913a46c551af3c671ca1 (diff) | |
download | common-574c7d88e88fa4dbd6c7471ff99064ca408ad58f.tar.gz |
Retry: Generate soong_config_module_type inline in the snapshot am: f3c17ef416
Original change: https://android-review.googlesource.com/c/platform/packages/modules/common/+/2165046
Change-Id: If90ccbc28cdc8ed17cca58a126d8d8d6bc187cc5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
5 files changed, 219 insertions, 76 deletions
diff --git a/build/mainline_modules_sdks.py b/build/mainline_modules_sdks.py index 7e671efc..1e33e379 100755 --- a/build/mainline_modules_sdks.py +++ b/build/mainline_modules_sdks.py @@ -108,9 +108,8 @@ class SoongConfigBoilerplateInserter(SoongConfigVarTransformation): through a Soong configuration variable. """ - # The bp file containing the definitions of the configuration module types - # to use in the sdk. - configBpDefFile: str + # The configuration variable that will control the prefer setting. + configVar: ConfigVar # The prefix to use for the soong config module types. configModuleTypePrefix: str @@ -202,32 +201,14 @@ class SoongConfigBoilerplateInserter(SoongConfigVarTransformation): content_lines.extend(module_content) content_lines.append("}") - if self.configBpDefFile: - # Add the soong_config_module_type_import module definition that - # imports the soong config module types into this bp file to the - # header lines so that they appear before any uses. - module_types = "\n".join([ - f' "{self.config_module_type(mt)}",' - for mt in sorted(config_module_types) - ]) + # Add the soong_config_module_type module definitions to the header + # lines so that they appear before any uses. + header_lines.append("") + for module_type in sorted(config_module_types): + # Create the corresponding soong config module type name by adding + # the prefix. + config_module_type = self.configModuleTypePrefix + module_type header_lines.append(f""" -// Soong config variable stanza added by {producer.script}. -soong_config_module_type_import {{ - from: "{self.configBpDefFile}", - module_types: [ -{module_types} - ], -}} -""") - else: - # Add the soong_config_module_type module definitions to the header - # lines so that they appear before any uses. - header_lines.append("") - for module_type in sorted(config_module_types): - # Create the corresponding soong config module type name by - # adding the prefix. - config_module_type = self.config_module_type(module_type) - header_lines.append(f""" // Soong config variable module type added by {producer.script}. soong_config_module_type {{ name: "{config_module_type}", @@ -823,13 +804,6 @@ class MainlineModule: name="module_build_from_source", ) - # The bp file containing the definitions of the configuration module types - # to use in the sdk. - configBpDefFile: str = "packages/modules/common/Android.bp" - - # The prefix to use for the soong config module types. - configModuleTypePrefix: str = "module_" - for_r_build: typing.Optional[ForRBuild] = None # The last release on which this module was optional. @@ -873,13 +847,11 @@ class MainlineModule: """Returns true for bundled modules. See BundledMainlineModule.""" return False - def transformations(self, build_release): + def transformations(self, build_release, sdk_type): """Returns the transformations to apply to this module's snapshot(s).""" transformations = [] config_var = self.configVar - config_module_type_prefix = self.configModuleTypePrefix - config_bp_def_file = self.configBpDefFile # If the module is optional then it needs its own Soong config # variable to allow it to be managed separately from other modules. @@ -889,18 +861,16 @@ class MainlineModule: namespace=f"{self.short_name}_module", name="source_build", ) - config_module_type_prefix = f"{self.short_name}_prebuilt_" - # Optional modules don't have their own config_bp_def_file so - # they have to generate the soong_config_module_types inline. - config_bp_def_file = "" prefer_handling = build_release.preferHandling if prefer_handling == PreferHandling.SOONG_CONFIG: + sdk_type_prefix = sdk_type.configModuleTypePrefix + config_module_type_prefix = \ + f"{self.short_name}{sdk_type_prefix}_prebuilt_" inserter = SoongConfigBoilerplateInserter( "Android.bp", configVar=config_var, - configModuleTypePrefix=config_module_type_prefix, - configBpDefFile=config_bp_def_file) + configModuleTypePrefix=config_module_type_prefix) transformations.append(inserter) elif prefer_handling == PreferHandling.USE_SOURCE_CONFIG_VAR_PROPERTY: transformation = UseSourceConfigVarTransformation( @@ -928,7 +898,7 @@ class BundledMainlineModule(MainlineModule): def is_bundled(self): return True - def transformations(self, build_release): + def transformations(self, build_release, sdk_type): # Bundled modules are only used on thin branches where the corresponding # sources are absent, so skip transformations and keep the default # `prefer: false`. @@ -960,8 +930,6 @@ MAINLINE_MODULES = [ namespace="art_module", name="source_build", ), - configBpDefFile="prebuilts/module_sdk/art/SoongConfig.bp", - configModuleTypePrefix="art_prebuilt_", ), MainlineModule( apex="com.android.btservices", @@ -1262,7 +1230,8 @@ class SdkDistProducer: sdk_dist_subdir = os.path.join(sdk_dist_dir, module.apex, subdir) sdk_path = sdk_snapshot_zip_file(snapshots_dir, sdk, sdk_version) - transformations = module.transformations(build_release) + sdk_type = sdk_type_from_name(sdk) + transformations = module.transformations(build_release, sdk_type) self.dist_sdk_snapshot_zip(sdk_path, sdk_dist_subdir, transformations) def dist_sdk_snapshot_zip(self, src_sdk_zip, sdk_dist_dir, transformations): @@ -1409,15 +1378,24 @@ def google_to_aosp_name(name): class SdkType: name: str + configModuleTypePrefix: str + providesApis: bool = False Sdk = SdkType( name="sdk", + configModuleTypePrefix="", providesApis=True, ) -HostExports = SdkType(name="host-exports") -TestExports = SdkType(name="test-exports") +HostExports = SdkType( + name="host-exports", + configModuleTypePrefix="_host_exports", +) +TestExports = SdkType( + name="test-exports", + configModuleTypePrefix="_test_exports", +) def sdk_type_from_name(name): diff --git a/build/mainline_modules_sdks_test.py b/build/mainline_modules_sdks_test.py index 726b6abe..ffe84576 100644 --- a/build/mainline_modules_sdks_test.py +++ b/build/mainline_modules_sdks_test.py @@ -417,15 +417,14 @@ class TestAndroidBpTransformations(unittest.TestCase): """Tests the transformations applied to a common mainline sdk on S. This uses ipsec as an example of a common mainline sdk. This checks - that the correct Soong config module types and variables are used and - that it imports the definitions from the correct location. + that the general Soong config module types and variables are used. """ src = read_test_data("ipsec_Android.bp.input") expected = read_test_data("ipsec_Android.bp.expected") module = MAINLINE_MODULES_BY_APEX["com.android.ipsec"] - transformations = module.transformations(mm.S) + transformations = module.transformations(mm.S, mm.Sdk) self.apply_transformations(src, transformations, expected) @@ -440,7 +439,7 @@ class TestAndroidBpTransformations(unittest.TestCase): expected = read_test_data("ipsec_tiramisu_Android.bp.expected") module = MAINLINE_MODULES_BY_APEX["com.android.ipsec"] - transformations = module.transformations(mm.Tiramisu) + transformations = module.transformations(mm.Tiramisu, mm.Sdk) self.apply_transformations(src, transformations, expected) @@ -456,7 +455,7 @@ class TestAndroidBpTransformations(unittest.TestCase): expected = read_test_data("wifi_Android.bp.expected") module = MAINLINE_MODULES_BY_APEX["com.android.wifi"] - transformations = module.transformations(mm.S) + transformations = module.transformations(mm.S, mm.Sdk) self.apply_transformations(src, transformations, expected) @@ -471,7 +470,7 @@ class TestAndroidBpTransformations(unittest.TestCase): expected = read_test_data("wifi_tiramisu_Android.bp.expected") module = MAINLINE_MODULES_BY_APEX["com.android.wifi"] - transformations = module.transformations(mm.Tiramisu) + transformations = module.transformations(mm.Tiramisu, mm.Sdk) self.apply_transformations(src, transformations, expected) @@ -480,14 +479,30 @@ class TestAndroidBpTransformations(unittest.TestCase): The ART mainline module uses a different Soong config setup to the common mainline modules. This checks that the ART specific Soong config - module types, variable and imports are used. + module types, and variables are used. """ src = read_test_data("art_Android.bp.input") expected = read_test_data("art_Android.bp.expected") module = MAINLINE_MODULES_BY_APEX["com.android.art"] - transformations = module.transformations(mm.S) + transformations = module.transformations(mm.S, mm.Sdk) + + self.apply_transformations(src, transformations, expected) + + def test_art_module_exports(self): + """Tests the transformations applied to a the ART mainline module. + + The ART mainline module uses a different Soong config setup to the + common mainline modules. This checks that the ART specific Soong config + module types, and variables are used. + """ + src = read_test_data("art_Android.bp.input") + + expected = read_test_data("art_host_exports_Android.bp.expected") + + module = MAINLINE_MODULES_BY_APEX["com.android.art"] + transformations = module.transformations(mm.S, mm.HostExports) self.apply_transformations(src, transformations, expected) @@ -505,7 +520,7 @@ class TestAndroidBpTransformations(unittest.TestCase): expected = src module = MAINLINE_MODULES_BY_APEX["com.android.ipsec"] - transformations = module.transformations(mm.R) + transformations = module.transformations(mm.R, mm.Sdk) self.apply_transformations(src, transformations, expected) diff --git a/build/mainline_modules_sdks_test_data/art_Android.bp.expected b/build/mainline_modules_sdks_test_data/art_Android.bp.expected index 135e4e6c..8fc0455e 100644 --- a/build/mainline_modules_sdks_test_data/art_Android.bp.expected +++ b/build/mainline_modules_sdks_test_data/art_Android.bp.expected @@ -1,13 +1,30 @@ // This is auto-generated. DO NOT EDIT. -// Soong config variable stanza added by test_art. -soong_config_module_type_import { - from: "prebuilts/module_sdk/art/SoongConfig.bp", - module_types: [ - "art_prebuilt_java_import", - "art_prebuilt_prebuilt_bootclasspath_fragment", - "art_prebuilt_prebuilt_platform_compat_config", - ], +// Soong config variable module type added by test_art. +soong_config_module_type { + name: "art_prebuilt_java_import", + module_type: "java_import", + config_namespace: "art_module", + bool_variables: ["source_build"], + properties: ["prefer"], +} + +// Soong config variable module type added by test_art. +soong_config_module_type { + name: "art_prebuilt_prebuilt_bootclasspath_fragment", + module_type: "prebuilt_bootclasspath_fragment", + config_namespace: "art_module", + bool_variables: ["source_build"], + properties: ["prefer"], +} + +// Soong config variable module type added by test_art. +soong_config_module_type { + name: "art_prebuilt_prebuilt_platform_compat_config", + module_type: "prebuilt_platform_compat_config", + config_namespace: "art_module", + bool_variables: ["source_build"], + properties: ["prefer"], } package { diff --git a/build/mainline_modules_sdks_test_data/art_host_exports_Android.bp.expected b/build/mainline_modules_sdks_test_data/art_host_exports_Android.bp.expected new file mode 100644 index 00000000..63eb2056 --- /dev/null +++ b/build/mainline_modules_sdks_test_data/art_host_exports_Android.bp.expected @@ -0,0 +1,124 @@ +// This is auto-generated. DO NOT EDIT. + +// Soong config variable module type added by test_art_module_exports. +soong_config_module_type { + name: "art_host_exports_prebuilt_java_import", + module_type: "java_import", + config_namespace: "art_module", + bool_variables: ["source_build"], + properties: ["prefer"], +} + +// Soong config variable module type added by test_art_module_exports. +soong_config_module_type { + name: "art_host_exports_prebuilt_prebuilt_bootclasspath_fragment", + module_type: "prebuilt_bootclasspath_fragment", + config_namespace: "art_module", + bool_variables: ["source_build"], + properties: ["prefer"], +} + +// Soong config variable module type added by test_art_module_exports. +soong_config_module_type { + name: "art_host_exports_prebuilt_prebuilt_platform_compat_config", + module_type: "prebuilt_platform_compat_config", + config_namespace: "art_module", + bool_variables: ["source_build"], + properties: ["prefer"], +} + +package { + // A default list here prevents the license LSC from adding its own list which would + // be unnecessary as every module in the sdk already has its own licenses property. + default_applicable_licenses: ["Android-Apache-2.0"], +} + +art_host_exports_prebuilt_prebuilt_bootclasspath_fragment { + name: "art-bootclasspath-fragment", + // Do not prefer prebuilt if the Soong config variable "source_build" in namespace "art_module" is true. + prefer: true, + soong_config_variables: { + source_build: { + prefer: false, + }, + }, + visibility: [ + "//art/build/apex", + "//art/build/boot", + "//art/build/sdk", + "//prebuilts:__subpackages__", + ], + apex_available: [ + "com.android.art", + ], + licenses: ["art-module-sdk_art_license"], + image_name: "art", + contents: [ + "core-oj", + "core-libart", + "okhttp", + "bouncycastle", + "apache-xml", + ], + api: { + stub_libs: ["art.module.public.api"], + }, + core_platform_api: { + stub_libs: ["art.module.public.api.stubs.module_lib"], + }, + hidden_api: { + max_target_o_low_priority: ["hiddenapi/hiddenapi-max-target-o-low-priority.txt"], + blocked: ["hiddenapi/hiddenapi-blocked.txt"], + unsupported_packages: ["hiddenapi/hiddenapi-unsupported-packages.txt"], + stub_flags: "hiddenapi/stub-flags.csv", + annotation_flags: "hiddenapi/annotation-flags.csv", + metadata: "hiddenapi/metadata.csv", + index: "hiddenapi/index.csv", + all_flags: "hiddenapi/all-flags.csv", + }, +} + +art_host_exports_prebuilt_prebuilt_platform_compat_config { + name: "libcore-platform-compat-config", + // Do not prefer prebuilt if the Soong config variable "source_build" in namespace "art_module" is true. + prefer: true, + soong_config_variables: { + source_build: { + prefer: false, + }, + }, + visibility: [ + "//art/build/apex", + "//art/build/sdk", + "//libcore", + "//prebuilts:__subpackages__", + ], + licenses: ["art-module-sdk_libcore_license"], + metadata: "compat_configs/libcore-platform-compat-config/libcore-platform-compat-config_meta.xml", +} + +art_host_exports_prebuilt_java_import { + name: "core-oj", + // Do not prefer prebuilt if the Soong config variable "source_build" in namespace "art_module" is true. + prefer: true, + soong_config_variables: { + source_build: { + prefer: false, + }, + }, + visibility: [ + "//art/build/apex", + "//art/build/sdk", + "//external/wycheproof", + "//libcore", + "//libcore/benchmarks", + "//packages/modules/ArtPrebuilt", + "//prebuilts:__subpackages__", + ], + apex_available: [ + "com.android.art", + "com.android.art.debug", + ], + licenses: ["art-module-sdk_libcore_license"], + jars: ["java/core-oj.jar"], +} diff --git a/build/mainline_modules_sdks_test_data/ipsec_Android.bp.expected b/build/mainline_modules_sdks_test_data/ipsec_Android.bp.expected index 0dd5bb0a..d705ecb4 100644 --- a/build/mainline_modules_sdks_test_data/ipsec_Android.bp.expected +++ b/build/mainline_modules_sdks_test_data/ipsec_Android.bp.expected @@ -1,12 +1,21 @@ // This is auto-generated. DO NOT EDIT. -// Soong config variable stanza added by test_common_mainline_module. -soong_config_module_type_import { - from: "packages/modules/common/Android.bp", - module_types: [ - "module_java_sdk_library_import", - "module_prebuilt_bootclasspath_fragment", - ], +// Soong config variable module type added by test_common_mainline_module. +soong_config_module_type { + name: "ipsec_prebuilt_java_sdk_library_import", + module_type: "java_sdk_library_import", + config_namespace: "ANDROID", + bool_variables: ["module_build_from_source"], + properties: ["prefer"], +} + +// Soong config variable module type added by test_common_mainline_module. +soong_config_module_type { + name: "ipsec_prebuilt_prebuilt_bootclasspath_fragment", + module_type: "prebuilt_bootclasspath_fragment", + config_namespace: "ANDROID", + bool_variables: ["module_build_from_source"], + properties: ["prefer"], } package { @@ -15,7 +24,7 @@ package { default_applicable_licenses: ["Android-Apache-2.0"], } -module_prebuilt_bootclasspath_fragment { +ipsec_prebuilt_prebuilt_bootclasspath_fragment { name: "com.android.ipsec-bootclasspath-fragment", // Do not prefer prebuilt if the Soong config variable "module_build_from_source" in namespace "ANDROID" is true. prefer: true, @@ -37,7 +46,7 @@ module_prebuilt_bootclasspath_fragment { }, } -module_java_sdk_library_import { +ipsec_prebuilt_java_sdk_library_import { name: "android.net.ipsec.ike", // Do not prefer prebuilt if the Soong config variable "module_build_from_source" in namespace "ANDROID" is true. prefer: true, |