Add local mode to the script.
Local mainline SDK artifacts can be built via TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true vendor/google/build/mainline_modules_sdks.sh Bug: 260755259 Test: run locally Change-Id: I0eb13441201d62db1686f2930957e33b4aa4ce37
This commit is contained in:
@@ -22,8 +22,10 @@ COMPAT_README = Path('extensions/README.md')
|
||||
BUILD_TARGET_TRAIN = 'train_build'
|
||||
# This build target is used when fetching from a non-train build (XXXXXXXX)
|
||||
BUILD_TARGET_CONTINUOUS = 'mainline_modules_sdks-userdebug'
|
||||
# The glob of sdk artifacts to fetch
|
||||
# The glob of sdk artifacts to fetch from remote build
|
||||
ARTIFACT_PATTERN = 'mainline-sdks/for-latest-build/current/{module_name}/sdk/*.zip'
|
||||
# The glob of sdk artifacts to fetch from local build
|
||||
ARTIFACT_LOCAL_PATTERN = 'out/dist/mainline-sdks/for-latest-build/current/{module_name}/sdk/*.zip'
|
||||
COMMIT_TEMPLATE = """Finalize artifacts for extension SDK %d
|
||||
|
||||
Import from build id %s.
|
||||
@@ -38,9 +40,16 @@ def fail(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
sys.exit(1)
|
||||
|
||||
def fetch_artifacts(target, build_id, artifact_path):
|
||||
def fetch_artifacts(target, build_id, module_name):
|
||||
tmpdir = Path(tempfile.TemporaryDirectory().name)
|
||||
tmpdir.mkdir()
|
||||
if args.local_mode:
|
||||
artifact_path = ARTIFACT_LOCAL_PATTERN.format(module_name='*')
|
||||
print('Copying %s to %s ...' % (artifact_path, tmpdir))
|
||||
for file in glob.glob(artifact_path):
|
||||
shutil.copy(file, tmpdir)
|
||||
else:
|
||||
artifact_path = ARTIFACT_PATTERN.format(module_name=module_name)
|
||||
print('Fetching %s from %s ...' % (artifact_path, target))
|
||||
fetch_cmd = [FETCH_ARTIFACT]
|
||||
fetch_cmd.extend(['--bid', str(build_id)])
|
||||
@@ -108,12 +117,13 @@ parser.add_argument('-b', '--bug', type=int, required=True, help='The bug number
|
||||
parser.add_argument('-r', '--readme', required=True, help='Version history entry to add to %s' % (COMPAT_REPO / COMPAT_README))
|
||||
parser.add_argument('-a', '--amend_last_commit', action="store_true", help='Amend current HEAD commits instead of making new commits.')
|
||||
parser.add_argument('-m', '--modules', action='append', help='Modules to include. Can be provided multiple times, or not at all for all modules.')
|
||||
parser.add_argument('-l', '--local_mode', action="store_true", help='Local mode: use locally built artifacts and don\'t upload the result to Gerrit.')
|
||||
parser.add_argument('bid', help='Build server build ID')
|
||||
args = parser.parse_args()
|
||||
|
||||
build_target = BUILD_TARGET_TRAIN if args.bid[0] == 'T' else BUILD_TARGET_CONTINUOUS
|
||||
branch_name = 'finalize-%d' % args.finalize_sdk
|
||||
cmdline = shlex.join([x for x in sys.argv if x not in ['-a', '--amend_last_commit']])
|
||||
cmdline = shlex.join([x for x in sys.argv if x not in ['-a', '--amend_last_commit', '-l', '--local_mode']])
|
||||
commit_message = COMMIT_TEMPLATE % (args.finalize_sdk, args.bid, cmdline, args.bug)
|
||||
module_names = args.modules or ['*']
|
||||
|
||||
@@ -124,7 +134,7 @@ if compat_dir.is_dir():
|
||||
|
||||
created_dirs = defaultdict(set)
|
||||
for m in module_names:
|
||||
tmpdir = fetch_artifacts(build_target, args.bid, ARTIFACT_PATTERN.format(module_name=m))
|
||||
tmpdir = fetch_artifacts(build_target, args.bid, m)
|
||||
for f in tmpdir.iterdir():
|
||||
repo = repo_for_sdk(f.name)
|
||||
dir = dir_for_sdk(f.name, args.finalize_sdk)
|
||||
@@ -153,6 +163,9 @@ for m in module_names:
|
||||
shutil.copy(src_file, dest_file)
|
||||
created_dirs[COMPAT_REPO].add(dest_dir.relative_to(COMPAT_REPO))
|
||||
|
||||
if args.local_mode:
|
||||
sys.exit(0)
|
||||
|
||||
subprocess.check_output(['repo', 'start', branch_name] + list(created_dirs.keys()))
|
||||
print('Running git commit')
|
||||
for repo in created_dirs:
|
||||
|
||||
Reference in New Issue
Block a user