Merge "Copy the out/soong/build_number.txt file into sdk snapshots for R"
This commit is contained in:
@@ -303,6 +303,8 @@ class SnapshotBuilder:
|
||||
r_snapshot_dir = os.path.join(snapshot_dir, "for-R-build")
|
||||
shutil.rmtree(r_snapshot_dir, ignore_errors=True)
|
||||
|
||||
build_number_file = os.path.join(self.out_dir, "soong/build_number.txt")
|
||||
|
||||
for module in modules:
|
||||
apex = module.apex
|
||||
dest_dir = os.path.join(r_snapshot_dir, apex)
|
||||
@@ -323,6 +325,7 @@ class SnapshotBuilder:
|
||||
bp.write(f"// {self.tool_path}\n")
|
||||
bp.write(COPYRIGHT_BOILERPLATE)
|
||||
aosp_apex = google_to_aosp_name(apex)
|
||||
|
||||
for library in module.for_r_build.sdk_libraries:
|
||||
module_name = library.name
|
||||
shared_library = str(library.shared_library).lower()
|
||||
@@ -365,6 +368,12 @@ java_sdk_library_import {{
|
||||
}}
|
||||
""")
|
||||
|
||||
# Copy the build_number.txt file into the snapshot.
|
||||
snapshot_build_number_file = os.path.join(
|
||||
dest_dir, "snapshot-creation-build-number.txt")
|
||||
shutil.copy(build_number_file, snapshot_build_number_file)
|
||||
|
||||
# Now zip up the files into a snapshot zip file.
|
||||
base_file = os.path.join(r_snapshot_dir, sdk_name + "-current")
|
||||
shutil.make_archive(base_file, "zip", dest_dir)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# limitations under the License.
|
||||
"""Unit tests for mainline_modules_sdks.py."""
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import re
|
||||
import typing
|
||||
from pathlib import Path
|
||||
@@ -112,6 +113,10 @@ class TestProduceDist(unittest.TestCase):
|
||||
return files
|
||||
|
||||
def test_unbundled_modules(self):
|
||||
# Create the out/soong/build_number.txt file that is copied into the
|
||||
# snapshots.
|
||||
self.create_build_number_file()
|
||||
|
||||
modules = [
|
||||
MAINLINE_MODULES_BY_APEX["com.android.art"],
|
||||
MAINLINE_MODULES_BY_APEX["com.android.ipsec"],
|
||||
@@ -175,11 +180,13 @@ class TestProduceDist(unittest.TestCase):
|
||||
"com.android.ipsec/sdk_library/public/android.net.ipsec.ike-stubs.jar",
|
||||
"com.android.ipsec/sdk_library/public/android.net.ipsec.ike.srcjar",
|
||||
"com.android.ipsec/sdk_library/public/android.net.ipsec.ike.txt",
|
||||
"com.android.ipsec/snapshot-creation-build-number.txt",
|
||||
google_wifi_android_bp,
|
||||
"com.google.android.wifi/sdk_library/public/framework-wifi-removed.txt",
|
||||
"com.google.android.wifi/sdk_library/public/framework-wifi-stubs.jar",
|
||||
"com.google.android.wifi/sdk_library/public/framework-wifi.srcjar",
|
||||
"com.google.android.wifi/sdk_library/public/framework-wifi.txt",
|
||||
"com.google.android.wifi/snapshot-creation-build-number.txt",
|
||||
"ipsec-module-sdk-current.zip",
|
||||
"wifi-module-sdk-current.zip",
|
||||
], sorted(self.list_files_in_dir(r_snaphot_dir)))
|
||||
@@ -263,7 +270,18 @@ class TestProduceDist(unittest.TestCase):
|
||||
],
|
||||
sorted(self.list_files_in_dir(self.tmp_dist_dir)))
|
||||
|
||||
def create_build_number_file(self):
|
||||
soong_dir = os.path.join(self.tmp_out_dir, "soong")
|
||||
os.makedirs(soong_dir, exist_ok=True)
|
||||
build_number_file = os.path.join(soong_dir, "build_number.txt")
|
||||
with open(build_number_file, "w", encoding="utf8") as f:
|
||||
f.write("build-number")
|
||||
|
||||
def test_snapshot_build_order(self):
|
||||
# Create the out/soong/build_number.txt file that is copied into the
|
||||
# snapshots.
|
||||
self.create_build_number_file()
|
||||
|
||||
subprocess_runner = unittest.mock.Mock(mm.SubprocessRunner)
|
||||
snapshot_builder = FakeSnapshotBuilder(
|
||||
tool_path="path/to/mainline_modules_sdks.sh",
|
||||
|
||||
Reference in New Issue
Block a user