Support building build target specific snapshots
This changes adds support for building target build release specific
snapshots.
It adds a BuildRelease class that defines the characteristics of the
build release, e.g. name, how to create it, etc. It also adds a
first_release field to MainlineModule which specifies the first
BuildRelease for which a snapshot of the module is required and
initializes that field for each module.
After these changes this script will generate:
1. A legacy set of snapshots that match the file structure that was
generated without this change. This is intended to allow existing
consumers of the generated artifacts to continue to work while they
are modified to make use of target build release specific snapshots.
2. The set of snapshots for the latest build release, i.e. the build
release containing the source from which the snapshots are produced.
This includes snapshots for all the modules.
3. For each build release from S onwards a set of snapshots for the
modules it supports.
It does not currently generate snapshots for Q and R releases as Soong
cannot generate a compatible snapshot for them. If it is necessary to
generate snapshots for those target build releases (similar to what the
packages/modules/common/generate_ml_bundle.sh would produce) then a
follow up change will add that capability to this script.
Bug: 204763318
Test: atest mainline_modules_sdks_test
packages/modules/common/build/mainline_modules_sdks.sh
tree out/dist/mainline-sdks out/dist/stubs
- check that it adds the for-latest-build directory but is
otherwise identical to what was produced before this change.
Change-Id: I48eb0b69cbe8664106b826ee0898557c98e039c2
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Unit tests for mainline_modules_sdks.py."""
|
||||
import dataclasses
|
||||
from pathlib import Path
|
||||
import os
|
||||
import tempfile
|
||||
@@ -42,7 +43,7 @@ class FakeSnapshotBuilder(mm.SnapshotBuilder):
|
||||
z.writestr("sdk_library/public/lib.jar", "")
|
||||
z.writestr("sdk_library/public/api.txt", "")
|
||||
|
||||
def build_snapshots(self, sdk_versions, modules):
|
||||
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.mkdir(parents=True, exist_ok=True)
|
||||
@@ -75,13 +76,21 @@ class TestProduceDist(unittest.TestCase):
|
||||
out_dir=tmp_out_dir,
|
||||
)
|
||||
|
||||
build_releases = [
|
||||
mm.Q,
|
||||
mm.R,
|
||||
mm.S,
|
||||
mm.LATEST,
|
||||
mm.LEGACY_BUILD_RELEASE,
|
||||
]
|
||||
|
||||
producer = mm.SdkDistProducer(
|
||||
subprocess_runner=subprocess_runner,
|
||||
snapshot_builder=snapshot_builder,
|
||||
dist_dir=tmp_dist_dir,
|
||||
)
|
||||
|
||||
producer.produce_dist(modules)
|
||||
producer.produce_dist(modules, build_releases)
|
||||
|
||||
files = []
|
||||
for abs_dir, _, filenames in os.walk(tmp_dist_dir):
|
||||
@@ -89,20 +98,33 @@ class TestProduceDist(unittest.TestCase):
|
||||
for f in filenames:
|
||||
files.append(os.path.join(rel_dir, f))
|
||||
# pylint: disable=line-too-long
|
||||
self.assertEqual([
|
||||
"mainline-sdks/current/com.android.art/host-exports/art-module-host-exports-current.zip",
|
||||
"mainline-sdks/current/com.android.art/sdk/art-module-sdk-current.zip",
|
||||
"mainline-sdks/current/com.android.art/test-exports/art-module-test-exports-current.zip",
|
||||
"mainline-sdks/current/com.android.ipsec/sdk/ipsec-module-sdk-current.zip",
|
||||
"stubs/com.android.art/sdk_library/public/api.txt",
|
||||
"stubs/com.android.art/sdk_library/public/lib.jar",
|
||||
"stubs/com.android.art/sdk_library/public/removed.txt",
|
||||
"stubs/com.android.art/sdk_library/public/source.srcjar",
|
||||
"stubs/com.android.ipsec/sdk_library/public/api.txt",
|
||||
"stubs/com.android.ipsec/sdk_library/public/lib.jar",
|
||||
"stubs/com.android.ipsec/sdk_library/public/removed.txt",
|
||||
"stubs/com.android.ipsec/sdk_library/public/source.srcjar",
|
||||
], sorted(files))
|
||||
self.assertEqual(
|
||||
[
|
||||
# Legacy copy of the snapshots, for use by tools that don't support build specific snapshots.
|
||||
"mainline-sdks/current/com.android.art/host-exports/art-module-host-exports-current.zip",
|
||||
"mainline-sdks/current/com.android.art/sdk/art-module-sdk-current.zip",
|
||||
"mainline-sdks/current/com.android.art/test-exports/art-module-test-exports-current.zip",
|
||||
"mainline-sdks/current/com.android.ipsec/sdk/ipsec-module-sdk-current.zip",
|
||||
# Build specific snapshots.
|
||||
"mainline-sdks/for-S-build/current/com.android.art/host-exports/art-module-host-exports-current.zip",
|
||||
"mainline-sdks/for-S-build/current/com.android.art/sdk/art-module-sdk-current.zip",
|
||||
"mainline-sdks/for-S-build/current/com.android.art/test-exports/art-module-test-exports-current.zip",
|
||||
"mainline-sdks/for-S-build/current/com.android.ipsec/sdk/ipsec-module-sdk-current.zip",
|
||||
"mainline-sdks/for-latest-build/current/com.android.art/host-exports/art-module-host-exports-current.zip",
|
||||
"mainline-sdks/for-latest-build/current/com.android.art/sdk/art-module-sdk-current.zip",
|
||||
"mainline-sdks/for-latest-build/current/com.android.art/test-exports/art-module-test-exports-current.zip",
|
||||
"mainline-sdks/for-latest-build/current/com.android.ipsec/sdk/ipsec-module-sdk-current.zip",
|
||||
# Legacy stubs directory containing unpacked java_sdk_library artifacts.
|
||||
"stubs/com.android.art/sdk_library/public/api.txt",
|
||||
"stubs/com.android.art/sdk_library/public/lib.jar",
|
||||
"stubs/com.android.art/sdk_library/public/removed.txt",
|
||||
"stubs/com.android.art/sdk_library/public/source.srcjar",
|
||||
"stubs/com.android.ipsec/sdk_library/public/api.txt",
|
||||
"stubs/com.android.ipsec/sdk_library/public/lib.jar",
|
||||
"stubs/com.android.ipsec/sdk_library/public/removed.txt",
|
||||
"stubs/com.android.ipsec/sdk_library/public/source.srcjar",
|
||||
],
|
||||
sorted(files))
|
||||
|
||||
|
||||
def pathToTestData(relative_path):
|
||||
|
||||
Reference in New Issue
Block a user