aboutsummaryrefslogtreecommitdiff
path: root/llvm_tools/update_chromeos_llvm_hash.py
diff options
context:
space:
mode:
authorRyan Beltran <ryanbeltran@chromium.org>2021-05-21 17:17:32 +0000
committerCommit Bot <commit-bot@chromium.org>2021-05-25 19:53:55 +0000
commit09e2dac8f0faa19ba223020482253e9d6a508cfe (patch)
tree5cc6f37fcb214aa090fa42b0a71ea78f36fa5ea3 /llvm_tools/update_chromeos_llvm_hash.py
parenta8142b16788dcc0ab5ef03f6d15d15f524715cfa (diff)
downloadtoolchain-utils-09e2dac8f0faa19ba223020482253e9d6a508cfe.tar.gz
llvm_tools: detect cros checkout for default chroot_path
This CL improves the assumptions made when selecting the default chroot path in update_chromeos_llvm_hash.py. Previously, it assumed the chrome source tree was installed to ~/chromiumos which didn't work for people with multiple chroots or with different naming. Now we detect whether or not we are inside of the cros source tree and use that cros checkout if so (otherwise defaulting back to old logic). BUG=None TEST=./update_chromeos_llvm_hash.py produced CL:2912507 without specifiying chroot_path manually Change-Id: Idb6dfc18a6f7a95c36eba4209dc43e08e373d6e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2912956 Commit-Queue: Ryan Beltran <ryanbeltran@chromium.org> Tested-by: Ryan Beltran <ryanbeltran@chromium.org> Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Diffstat (limited to 'llvm_tools/update_chromeos_llvm_hash.py')
-rwxr-xr-xllvm_tools/update_chromeos_llvm_hash.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm_tools/update_chromeos_llvm_hash.py b/llvm_tools/update_chromeos_llvm_hash.py
index 8d8030b9..afc63f3c 100755
--- a/llvm_tools/update_chromeos_llvm_hash.py
+++ b/llvm_tools/update_chromeos_llvm_hash.py
@@ -39,6 +39,21 @@ class LLVMVariant(enum.Enum):
verbose = False
+def defaultCrosRoot():
+ """Get default location of chroot_path.
+
+ The logic assumes that the cros_root is ~/chromiumos, unless llvm_tools is
+ inside of a CrOS checkout, in which case that checkout should be used.
+
+ Returns:
+ The best guess location for the cros checkout.
+ """
+ llvm_tools_path = os.path.realpath(os.path.dirname(__file__))
+ if llvm_tools_path.endswith('src/third_party/toolchain-utils/llvm_tools'):
+ return os.path.join(llvm_tools_path, '../../../../')
+ return '~/chromiumos'
+
+
def GetCommandLineArgs():
"""Parses the command line for the optional command line arguments.
@@ -49,10 +64,6 @@ def GetCommandLineArgs():
and the LLVM version to use when retrieving the LLVM hash.
"""
- # Default path to the chroot if a path is not specified.
- cros_root = os.path.expanduser('~')
- cros_root = os.path.join(cros_root, 'chromiumos')
-
# Create parser and add optional command-line arguments.
parser = argparse.ArgumentParser(
description="Updates the build's hash for llvm-next.")
@@ -60,7 +71,7 @@ def GetCommandLineArgs():
# Add argument for a specific chroot path.
parser.add_argument(
'--chroot_path',
- default=cros_root,
+ default=defaultCrosRoot(),
help='the path to the chroot (default: %(default)s)')
# Add argument for specific builds to uprev and update their llvm-next hash.