Move populate_stubs into LEGACY BuildRelease
Previously, the populate_stubs was handled specially in produce_dist.
However, it is LEGACY behavior and so it makes sense to move the
code into the LEGACY BuildRelease's creator function.
While testing, the script failed because the LEGACY BuildRelease does
not build the snapshots, it assumes that the LEGACY is always run after
LATEST. This change makes the LEGACY build the snapshots. In normal use
it will not cause any increase in build time as it will always run
after LATEST and build the snapshots with the same environment turning
the build command into a no-op.
Bug: 218685706
Test: rm -fr out/soong/mainline-sdks
packages/modules/common/build/mainline_modules_sdks.sh --build-release=LEGACY
# Before this change it fails due to missing files, after it works.
pyformat -s 4 --force_quote_type double -i build/mainline_modules_sdks*.py
/usr/bin/pylint --rcfile $ANDROID_BUILD_TOP/tools/repohooks/tools/pylintrc build/mainline_modules_sdks*.py
Change-Id: Iaa2f9f71dd5085965d3ad32110b324453df87ee6
This commit is contained in:
@@ -349,11 +349,30 @@ def create_sdk_snapshots_in_soong(build_release: BuildRelease,
|
||||
producer.produce_dist_for_build_release(build_release, modules)
|
||||
|
||||
|
||||
def reuse_latest_sdk_snapshots(build_release: BuildRelease,
|
||||
def create_legacy_dist_structures(build_release: BuildRelease,
|
||||
producer: "SdkDistProducer",
|
||||
modules: List["MainlineModule"]):
|
||||
"""Copies the snapshots from the latest build."""
|
||||
producer.populate_dist(build_release, build_release.sdk_versions, modules)
|
||||
"""Creates legacy file structures."""
|
||||
producer.produce_dist_for_build_release(build_release, modules)
|
||||
|
||||
# Create the out/dist/mainline-sdks/stubs structure.
|
||||
# TODO(b/199759953): Remove stubs once it is no longer used by gantry.
|
||||
# Clear and populate the stubs directory.
|
||||
dist_dir = producer.dist_dir
|
||||
stubs_dir = os.path.join(dist_dir, "stubs")
|
||||
shutil.rmtree(stubs_dir, ignore_errors=True)
|
||||
|
||||
for module in modules:
|
||||
apex = module.apex
|
||||
dest_dir = os.path.join(dist_dir, "stubs", apex)
|
||||
for sdk in module.sdks:
|
||||
# If the sdk's name ends with -sdk then extract sdk library
|
||||
# related files from its zip file.
|
||||
if sdk.endswith("-sdk"):
|
||||
sdk_file = producer.snapshot_builder.get_sdk_path(
|
||||
sdk, "current")
|
||||
extract_matching_files_from_zip(sdk_file, dest_dir,
|
||||
sdk_library_files_pattern())
|
||||
|
||||
|
||||
Q = BuildRelease(
|
||||
@@ -398,12 +417,11 @@ LEGACY_BUILD_RELEASE = BuildRelease(
|
||||
name="legacy",
|
||||
# There is no build release specific sub directory.
|
||||
sub_dir="",
|
||||
# Create snapshots needed for legacy tools.
|
||||
creator=create_legacy_dist_structures,
|
||||
# There are no build release specific environment variables to pass to
|
||||
# Soong.
|
||||
soong_env={},
|
||||
# Do not create new snapshots, simply use the snapshots generated for
|
||||
# latest.
|
||||
creator=reuse_latest_sdk_snapshots,
|
||||
)
|
||||
|
||||
|
||||
@@ -576,32 +594,12 @@ class SdkDistProducer:
|
||||
f" build release")
|
||||
build_release.creator(build_release, self, filtered_modules)
|
||||
|
||||
self.populate_stubs(modules)
|
||||
|
||||
def produce_dist_for_build_release(self, build_release, modules):
|
||||
sdk_versions = build_release.sdk_versions
|
||||
self.snapshot_builder.build_snapshots(build_release, sdk_versions,
|
||||
modules)
|
||||
self.populate_dist(build_release, sdk_versions, modules)
|
||||
|
||||
def populate_stubs(self, modules):
|
||||
# TODO(b/199759953): Remove stubs once it is no longer used by gantry.
|
||||
# Clear and populate the stubs directory.
|
||||
stubs_dir = os.path.join(self.dist_dir, "stubs")
|
||||
shutil.rmtree(stubs_dir, ignore_errors=True)
|
||||
|
||||
for module in modules:
|
||||
apex = module.apex
|
||||
dest_dir = os.path.join(self.dist_dir, "stubs", apex)
|
||||
for sdk in module.sdks:
|
||||
# If the sdk's name ends with -sdk then extract sdk library
|
||||
# related files from its zip file.
|
||||
if sdk.endswith("-sdk"):
|
||||
sdk_file = self.snapshot_builder.get_sdk_path(
|
||||
sdk, "current")
|
||||
extract_matching_files_from_zip(sdk_file, dest_dir,
|
||||
sdk_library_files_pattern())
|
||||
|
||||
def populate_dist(self, build_release, sdk_versions, modules):
|
||||
build_release_dist_dir = os.path.join(self.mainline_sdks_dir,
|
||||
build_release.sub_dir)
|
||||
|
||||
Reference in New Issue
Block a user