aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2024-04-09 05:15:02 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-09 05:15:02 +0000
commit9edcb82c084c41c0f2bd15a4efe45dd8d02adc75 (patch)
treef475f505f88077478e172c35967a32cf5e1f4327
parentda3daf8f79092e6b6ee797ec416b6b038ef4eedf (diff)
parentdc1354b9101b1c6c351b24a369fc7dceb0eb9b90 (diff)
downloadllvm_android-9edcb82c084c41c0f2bd15a4efe45dd8d02adc75.tar.gz
Merge "Fix profile upload logic" into main
-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():