Retry: Generate soong_config_module_type inline in the snapshot

Previously, this imported the soong_config_module_type definitions from
a manually curated file. That had a couple of problems:
1. It required that the file be manually updated everytime that a new
   module_type was added to an sdk snapshot controlled by a specific
   config variable.
2. Adding a new config variable required creating another file to be
   manually curated.
3. It made a snapshot that was generated for an earlier release
   dependent on an additional file from that release which was in a
   separate repository and would require a lot of extra work to update
   if necessary.

This change generates the soong_config_module_type inline in the
snapshot Android.bp file and while it makes it slightly bigger it makes
each snapshot much more self contained and makes it easier to add
module specific config variables.

The latter is the main driver for this change as follow up changes will
add module specific variables for the optional modules.

Due to bug 235475711 each soong_config_module_type has to be unique
across all mainline modules so this uses both the module short name
and a prefix associated with the SdkType to generate unique module
names. However, that only affects the S snapshots as from T onwards is
is not necessary to use soong_config_module_type modules at all.

Bug: 233965247
Test: atest --host mainline_modules_sdks_test
      packages/modules/common/build/mainline_modules_sdks.sh
      # Extract art sdk and module_exports snapshots into
      # prebuilts/module_sdk/art and then run "m nothing"
Change-Id: Ib0e2ece1779451dffff6dfaca7ca39b264004b5b
This commit is contained in:
Paul Duffin
2022-06-08 11:06:00 +00:00
parent d7b7cddf54
commit f3c17ef416
5 changed files with 219 additions and 76 deletions

View File

@@ -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)