aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2024-04-09 05:23:42 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-04-09 05:23:42 +0000
commit495f3bc852ad719d7c695bf63544f34dca452acc (patch)
treef475f505f88077478e172c35967a32cf5e1f4327
parent9d3626ebb31a76e4dc22b0f4f492ae56e53f4641 (diff)
parent9edcb82c084c41c0f2bd15a4efe45dd8d02adc75 (diff)
downloadllvm_android-495f3bc852ad719d7c695bf63544f34dca452acc.tar.gz
Merge "Fix profile upload logic" into main am: 9edcb82c08
Original change: https://android-review.googlesource.com/c/toolchain/llvm_android/+/3032976 Change-Id: Icdae9e3f9ca7f51bfbee886304b13112fd1ab05c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rwxr-xr-xupdate-prebuilts.py38
1 files changed, 20 insertions, 18 deletions
diff --git a/update-prebuilts.py b/update-prebuilts.py
index cd9fd04..aa587b1 100755
--- a/update-prebuilts.py
+++ b/update-prebuilts.py
@@ -19,6 +19,7 @@
"""Update the prebuilt clang from the build server."""
import argparse
+import contextlib
import glob
import inspect
import logging
@@ -315,24 +316,25 @@ def install_clang_directory(extract_subdir: str, install_subdir: str, overwrite:
def update_profiles(download_dir, build_number, bug):
profiles_dir = paths.PREBUILTS_DIR / 'clang' / 'host' / 'linux-x86' / 'profiles'
- # First, delete the old profiles.
- for f in glob.glob(f'{profiles_dir}/{PGO_PROFILE_PATTERN}'):
- os.remove(f)
- for f in glob.glob(f'{profiles_dir}/{BOLT_PROFILE_PATTERN}'):
- os.remove(f)
-
- # Replace with the downloaded new profiles.
- shutil.copy(glob.glob(f'{download_dir}/{PGO_PROFILE_PATTERN}')[0], str(profiles_dir))
- shutil.copy(glob.glob(f'{download_dir}/{BOLT_PROFILE_PATTERN}')[0], str(profiles_dir))
-
- utils.check_call(['git', 'add', profiles_dir])
- message_lines = [f'Check in profiles from build {build_number}']
- if bug is not None:
- message_lines.append('')
- message_lines.append(f'Bug: {format_bug(bug)}')
- message_lines.append('Test: N/A')
- message = '\n'.join(message_lines)
- utils.check_call(['git', 'commit', '-m', message])
+ with contextlib.chdir(profiles_dir):
+ # First, delete the old profiles.
+ for f in glob.glob(PGO_PROFILE_PATTERN):
+ os.remove(f)
+ for f in glob.glob(BOLT_PROFILE_PATTERN):
+ os.remove(f)
+
+ # Replace with the downloaded new profiles.
+ shutil.copy(glob.glob(f'{download_dir}/{PGO_PROFILE_PATTERN}')[0], '.')
+ shutil.copy(glob.glob(f'{download_dir}/{BOLT_PROFILE_PATTERN}')[0], '.')
+
+ utils.check_call(['git', 'add', '.'])
+ message_lines = [f'Check in profiles from build {build_number}']
+ if bug is not None:
+ message_lines.append('')
+ message_lines.append(f'Bug: {format_bug(bug)}')
+ message_lines.append('Test: N/A')
+ message = '\n'.join(message_lines)
+ utils.check_call(['git', 'commit', '-m', message])
def main():