Optional modules need a module specific soong config variable

Optional modules, i.e. those modules which may be provided by Google or
vendors depending on the vendor, need to have its own Soong config
variable that controls whether prebuilts are used or not. Without that
the build will always attempt to use the Google prebuilt module instead
of the vendor provided module.

This change:
1. Adds support for specifying which modules are optional and will
   generate a module specific soong_config_module_type that uses a
   module specific Soong config variable.

2. Generates the soong_config_module_type for optional modules inline
   in the snapshot Android.bp file (instead of importing from a
   manually curated definitions files). That simplifies the cost of
   adding optional modules.

3. Adds some extra tests to ensure that S and Tiramisu behave the
   same way.

Bug: 233965247
Test: atest mainline_modules_sdks_test
      packages/modules/common/build/mainline_modules_sdks.sh
      # Check the output to ensure that wifi uses the wifi specific
      # Soong config but ipsec (as a non-optional module) does not.
      # Unpack the wifi snapshot into prebuilts/module_sdk/Wifi
Change-Id: I6a85b6f9877fc251010ff2bbee75fe8fa99db9b4
This commit is contained in:
Paul Duffin
2022-06-08 11:06:00 +00:00
parent e363782a5c
commit d20edd6c69
4 changed files with 390 additions and 13 deletions

View File

@@ -411,6 +411,36 @@ class TestSoongConfigBoilerplateInserter(unittest.TestCase):
self.apply_transformations(src, transformations, expected)
# Check that Tiramisu provides the same transformations as S.
tiramisu_transformations = module.transformations(mm.Tiramisu)
self.assertEqual(
transformations,
tiramisu_transformations,
msg="Tiramisu must use the same transformations as S")
def test_optional_mainline_module(self):
"""Tests the transformations applied to an optional mainline module.
This uses wifi as an example of a optional mainline module. This checks
that the module specific Soong config module types and variables are
used.
"""
src = read_test_data("wifi_Android.bp.input")
expected = read_test_data("wifi_Android.bp.expected")
module = MAINLINE_MODULES_BY_APEX["com.android.wifi"]
transformations = module.transformations(mm.S)
self.apply_transformations(src, transformations, expected)
# Check that Tiramisu provides the same transformations as S.
tiramisu_transformations = module.transformations(mm.Tiramisu)
self.assertEqual(
transformations,
tiramisu_transformations,
msg="Tiramisu must use the same transformations as S")
def test_art(self):
"""Tests the transformations applied to a the ART mainline module.