Decouple population of the dist dir from the SnapshotBuilder
Previously, the code for populating the dist directory, e.g.
populate_dist and create_legacy_dist_structures assumed that the sdk
snapshot files they needed could be found in the directory referenced
by SnapshotBuilder.mainline_sdks_dir. This change removes that
assumption and instead passes the snapshot_dirs directory into the
populate_dist method and uses it in the create_legacy_dist_structures
function.
This refactoring is needed to allow a follow up change to construct a
set of sdk snapshot files in a different directory while still using
the populate_dist method to copy them into the correct location in the
dist directory.
Bug: 218685706
Test: atest --host mainline_modules_sdks_test
packages/modules/common/build/mainline_modules_sdks.sh
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: I9fb659df28d7688b3f081bf84f5fae8ee85dc534
This commit is contained in:
@@ -41,8 +41,8 @@ class FakeSnapshotBuilder(mm.SnapshotBuilder):
|
||||
z.writestr(f"sdk_library/public/{name}-stubs.jar", "")
|
||||
z.writestr(f"sdk_library/public/{name}.txt", "")
|
||||
|
||||
def create_snapshot_file(self, name, version):
|
||||
zip_file = Path(self.get_sdk_path(name, version))
|
||||
def create_snapshot_file(self, out_dir, name, version):
|
||||
zip_file = Path(mm.sdk_snapshot_zip_file(out_dir, name, version))
|
||||
with zipfile.ZipFile(zip_file, "w") as z:
|
||||
z.writestr("Android.bp", "")
|
||||
if name.endswith("-sdk"):
|
||||
@@ -50,13 +50,14 @@ class FakeSnapshotBuilder(mm.SnapshotBuilder):
|
||||
|
||||
def build_snapshots(self, build_release, sdk_versions, modules):
|
||||
# Create input file structure.
|
||||
sdks_out_dir = Path(self.get_mainline_sdks_path())
|
||||
sdks_out_dir = Path(self.mainline_sdks_dir).joinpath("test")
|
||||
sdks_out_dir.mkdir(parents=True, exist_ok=True)
|
||||
# Create a fake sdk zip file for each module.
|
||||
for module in modules:
|
||||
for sdk in module.sdks:
|
||||
for sdk_version in sdk_versions:
|
||||
self.create_snapshot_file(sdk, sdk_version)
|
||||
self.create_snapshot_file(sdks_out_dir, sdk, sdk_version)
|
||||
return sdks_out_dir
|
||||
|
||||
|
||||
class TestProduceDist(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user