Add an option to skip the allowed deps check.

This is for use on thin manifests where there are `apex` Soong modules
in the tree that lack dependencies to be built. Since the APEX
singleton in Soong adds all such modules to the apex-allowed-deps-check
target it won't work, even if SOONG_ALLOW_MISSING_DEPENDENCIES is used.

Also use the apex-allowed-deps-check phony target rather than
referencing the check file directly.

Test: env TARGET_BUILD_VARIANT=userdebug \
        TARGET_BUILD_APPS="com.android.art com.android.art.debug" \
        BUILD_BROKEN_DISABLE_BAZEL=true \
        packages/modules/common/build/mainline_modules_sdks.sh \
        --skip-allowed-deps-check
  on master-art with https://r.android.com/2743421, which adds a
  project with the com.andoid.tethering APEX, which cannot be built on
  master-art.
Test: env TARGET_BUILD_VARIANT=userdebug \
        TARGET_BUILD_APPS="com.android.art com.android.art.debug" \
        packages/modules/common/build/mainline_modules_sdks.sh \
        --build-release latest
  on AOSP main with libbase removed from allowed_deps.txt, and verify
  that it fails.
Bug: 300072791
Change-Id: I313905e1f00614b263d8240d01504805380e3076
This commit is contained in:
Martin Stjernholm
2023-09-12 14:05:31 +01:00
parent a0e8b60014
commit 8dfa763dd1

View File

@@ -322,6 +322,9 @@ class SnapshotBuilder:
# The out/soong/mainline-sdks directory.
mainline_sdks_dir: str = ""
# True if apex-allowed-deps-check is to be skipped.
skip_allowed_deps_check: bool = False
def __post_init__(self):
self.mainline_sdks_dir = os.path.join(self.out_dir,
"soong/mainline-sdks")
@@ -356,8 +359,9 @@ class SnapshotBuilder:
f"TARGET_BUILD_VARIANT={target_build_variant}",
"TARGET_PRODUCT=mainline_sdk",
"MODULE_BUILD_FROM_SOURCE=true",
"out/soong/apex/depsinfo/new-allowed-deps.txt.check",
] + target_paths
if not self.skip_allowed_deps_check:
cmd += ["apex-allowed-deps-check"]
print_command(extraEnv, cmd)
env = os.environ.copy()
env.update(extraEnv)
@@ -1409,7 +1413,7 @@ def apply_transformations(producer, tmp_dir, transformations, build_release):
os.utime(path, (modified, modified))
def create_producer(tool_path):
def create_producer(tool_path, skip_allowed_deps_check):
# Variables initialized from environment variables that are set by the
# calling mainline_modules_sdks.sh.
out_dir = os.environ["OUT_DIR"]
@@ -1424,6 +1428,7 @@ def create_producer(tool_path):
tool_path=tool_path,
subprocess_runner=subprocess_runner,
out_dir=out_dir,
skip_allowed_deps_check=skip_allowed_deps_check,
)
return SdkDistProducer(
subprocess_runner=subprocess_runner,
@@ -1519,6 +1524,11 @@ def main(args):
"Defaults to true when TARGET_BUILD_APPS is not set. "
"Applicable only if the \"latest\" build release is built.",
)
args_parser.add_argument(
"--skip-allowed-deps-check",
action="store_true",
help="Skip apex-allowed-deps-check.",
)
args = args_parser.parse_args(args)
build_releases = ALL_BUILD_RELEASES
@@ -1538,7 +1548,7 @@ def main(args):
if not target_build_apps or args.build_platform_sdks_for_mainline:
modules += PLATFORM_SDKS_FOR_MAINLINE
producer = create_producer(args.tool_path)
producer = create_producer(args.tool_path, args.skip_allowed_deps_check)
producer.dist_generate_sdk_supported_modules_file(modules)
producer.produce_dist(modules, build_releases)