Merge "Move populate_stubs into LEGACY BuildRelease" am: 2a5e1b5e4e

Original change: https://android-review.googlesource.com/c/platform/packages/modules/common/+/2032131

Change-Id: I3ca94c8308138e7a3a467e671fc86db137237a28
This commit is contained in:
Paul Duffin
2022-03-23 09:50:13 +00:00
committed by Automerger Merge Worker

View File

@@ -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,
)
@@ -580,32 +598,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)