aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2022-06-09 14:52:48 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-06-09 14:52:48 +0000
commitcb49a23528008c346a1dfe05f4b8b9ab74333d29 (patch)
tree03c0c69f7b52daa5dd7dd96e09c685735f2ec1fd
parentaa72d8636b1d6bed24192439f408a63ddbec0f9a (diff)
parentd29f8e059712d28346eb2b92ef7b5780695ed3ad (diff)
downloadcommon-cb49a23528008c346a1dfe05f4b8b9ab74333d29.tar.gz
Generate soong_config_module_type inline in the snapshot am: d29f8e0597
Original change: https://android-review.googlesource.com/c/platform/packages/modules/common/+/2120156 Change-Id: I8265356d7190940055ff4193e8b5780501f40d7d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rwxr-xr-xbuild/mainline_modules_sdks.py48
-rw-r--r--build/mainline_modules_sdks_test.py5
-rw-r--r--build/mainline_modules_sdks_test_data/art_Android.bp.expected33
-rw-r--r--build/mainline_modules_sdks_test_data/ipsec_Android.bp.expected23
4 files changed, 64 insertions, 45 deletions
diff --git a/build/mainline_modules_sdks.py b/build/mainline_modules_sdks.py
index 25d67cee..809540e2 100755
--- a/build/mainline_modules_sdks.py
+++ b/build/mainline_modules_sdks.py
@@ -85,10 +85,6 @@ class SoongConfigBoilerplateInserter(FileTransformation):
# The configuration variable that will control the prefer setting.
configVar: ConfigVar
- # The bp file containing the definitions of the configuration module types
- # to use in the sdk.
- configBpDefFile: str
-
# The prefix to use for the soong config module types.
configModuleTypePrefix: str
@@ -162,12 +158,13 @@ class SoongConfigBoilerplateInserter(FileTransformation):
}},
}},""")
+ # Add the module type to the list of module types that need to
+ # have corresponding config module types.
+ config_module_types.add(module_type)
+
# Change the module type to the corresponding soong config
# module type by adding the prefix.
module_type = self.configModuleTypePrefix + module_type
- # Add the module type to the list of module types that need to
- # be imported into the bp file.
- config_module_types.add(module_type)
# Generate the module, possibly with the new module type and
# containing the
@@ -175,20 +172,23 @@ class SoongConfigBoilerplateInserter(FileTransformation):
content_lines.extend(module_content)
content_lines.append("}")
- # 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' "{mt}",' for mt in sorted(config_module_types)])
- header_lines.append(f"""
-// Soong config variable stanza added by {producer.script}.
-soong_config_module_type_import {{
- from: "{self.configBpDefFile}",
- module_types: [
-{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 module type added by {producer.script}.
+soong_config_module_type {{
+ name: "{config_module_type}",
+ module_type: "{module_type}",
+ config_namespace: "{self.configVar.namespace}",
+ bool_variables: ["{self.configVar.name}"],
+ properties: ["prefer"],
}}
-""")
+""".lstrip())
# Overwrite the file with the updated contents.
file.seek(0)
@@ -624,10 +624,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_"
@@ -644,8 +640,7 @@ class MainlineModule:
inserter = SoongConfigBoilerplateInserter(
"Android.bp",
configVar=self.configVar,
- configModuleTypePrefix=self.configModuleTypePrefix,
- configBpDefFile=self.configBpDefFile)
+ configModuleTypePrefix=self.configModuleTypePrefix)
transformations.append(inserter)
return transformations
@@ -690,7 +685,6 @@ MAINLINE_MODULES = [
namespace="art_module",
name="source_build",
),
- configBpDefFile="prebuilts/module_sdk/art/SoongConfig.bp",
configModuleTypePrefix="art_prebuilt_",
),
MainlineModule(
diff --git a/build/mainline_modules_sdks_test.py b/build/mainline_modules_sdks_test.py
index 72858e09..11a5d673 100644
--- a/build/mainline_modules_sdks_test.py
+++ b/build/mainline_modules_sdks_test.py
@@ -399,8 +399,7 @@ class TestSoongConfigBoilerplateInserter(unittest.TestCase):
"""Tests the transformations applied to a common mainline module.
This uses ipsec as an example of a common mainline module. 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")
@@ -416,7 +415,7 @@ class TestSoongConfigBoilerplateInserter(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")
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/ipsec_Android.bp.expected b/build/mainline_modules_sdks_test_data/ipsec_Android.bp.expected
index 99640c05..1a3d3432 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: "module_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: "module_prebuilt_bootclasspath_fragment",
+ module_type: "prebuilt_bootclasspath_fragment",
+ config_namespace: "ANDROID",
+ bool_variables: ["module_build_from_source"],
+ properties: ["prefer"],
}
package {