diff options
author | Salud Lemus <saludlemus@google.com> | 2019-08-16 16:44:56 -0700 |
---|---|---|
committer | Salud Lemus <saludlemus@google.com> | 2019-08-16 23:54:35 +0000 |
commit | fcda3b3e33d46699bdfd08a81d897dd903c5d526 (patch) | |
tree | 70a9f9b70b846e66117bb3c825b1777c59580129 /llvm_tools | |
parent | 3f0c0754d9d2d068a14489cf207a4d5994e740f4 (diff) | |
download | toolchain-utils-fcda3b3e33d46699bdfd08a81d897dd903c5d526.tar.gz |
LLVM tools: Moved function that retrieves latest g3 LLVM version
BUG=None
TEST=Ran the script that creates tryjobs for both 'tot' and 'google3'
Change-Id: I1be3971ab8858cb21d9d95b63b1bf60a98d3c7b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1758728
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Salud Lemus <saludlemus@google.com>
Diffstat (limited to 'llvm_tools')
-rw-r--r-- | llvm_tools/README.md | 25 | ||||
-rwxr-xr-x | llvm_tools/get_google3_llvm_version.py | 49 | ||||
-rwxr-xr-x | llvm_tools/get_llvm_hash.py | 32 | ||||
-rwxr-xr-x | llvm_tools/llvm_patch_management.py | 4 |
4 files changed, 38 insertions, 72 deletions
diff --git a/llvm_tools/README.md b/llvm_tools/README.md index 2aab1ec0..d0b76fe6 100644 --- a/llvm_tools/README.md +++ b/llvm_tools/README.md @@ -116,21 +116,6 @@ python patch_manager.py --help ## Other Helpful Scripts -### `get_google3_llvm_version.py` - -#### Usage - -This script has a class that deals with retrieving the latest google3 LLVM -version. - -For example, to retrieve the latest google3 LLVM version: - -``` -from get_google3_llvm_version import LLVMVersion - -LLVMVersion().GetGoogle3LLVMVersion() -``` - ### `get_llvm_hash.py` #### Usage @@ -139,6 +124,8 @@ The script has a class that deals with retrieving either the top of trunk git hash of LLVM, the git hash of google3, or a specific git hash of a SVN version. It also has other functions when dealing with a git hash of LLVM. +In addition, it has a function to retrieve the latest google3 LLVM version. + For example, to retrieve the top of trunk git hash of LLVM: ``` @@ -170,3 +157,11 @@ from get_llvm_hash import LLVMHash LLVMHash.GetCommitMessageForHash(<git_hash>) ``` + +For example, to retrieve the latest google3 LLVM version: + +``` +from get_llvm_hash import GetGoogle3LLVMVersion + +GetGoogle3LLVMVersion() +``` diff --git a/llvm_tools/get_google3_llvm_version.py b/llvm_tools/get_google3_llvm_version.py deleted file mode 100755 index 53e2d7bf..00000000 --- a/llvm_tools/get_google3_llvm_version.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -# Copyright 2019 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Gets the latest google3 LLVM version.""" - -from __future__ import print_function - -import subprocess - - -class LLVMVersion(object): - """Provides a method to retrieve the latest google3 LLVM version.""" - - def GetGoogle3LLVMVersion(self): - """Gets the latest google3 LLVM version. - - Returns: - The latest LLVM SVN version as an integer. - - Raises: - subprocess.CalledProcessError: An invalid path has been provided to the - `cat` command. - """ - - path_to_google3_llvm_version = ('/google/src/head/depot/google3/third_party' - '/crosstool/v18/stable/installs/llvm/' - 'revision') - - # Cmd to get latest google3 LLVM version. - cat_cmd = ['cat', path_to_google3_llvm_version] - - # Get latest version. - g3_version = subprocess.check_output(cat_cmd) - - # Change type to an integer - return int(g3_version.rstrip()) - - -def main(): - """Prints the google3 llvm version.""" - - print(LLVMVersion().GetGoogle3LLVMVersion()) - - -if __name__ == '__main__': - main() diff --git a/llvm_tools/get_llvm_hash.py b/llvm_tools/get_llvm_hash.py index 3c708f68..dbc743bd 100755 --- a/llvm_tools/get_llvm_hash.py +++ b/llvm_tools/get_llvm_hash.py @@ -17,7 +17,30 @@ import shutil import subprocess import tempfile -from get_google3_llvm_version import LLVMVersion + +def GetGoogle3LLVMVersion(): + """Gets the latest google3 LLVM version. + + Returns: + The latest LLVM SVN version as an integer. + + Raises: + subprocess.CalledProcessError: An invalid path has been provided to the + `cat` command. + """ + + path_to_google3_llvm_version = ('/google/src/head/depot/google3/third_party' + '/crosstool/v18/stable/installs/llvm/' + 'revision') + + # Cmd to get latest google3 LLVM version. + cat_cmd = ['cat', path_to_google3_llvm_version] + + # Get latest version. + g3_version = subprocess.check_output(cat_cmd) + + # Change type to an integer + return int(g3_version.rstrip()) def is_svn_option(svn_option): @@ -74,7 +97,7 @@ def GetLLVMHashAndVersionFromSVNOption(svn_option): if isinstance(svn_option, int): llvm_version = svn_option else: - llvm_version = LLVMVersion().GetGoogle3LLVMVersion() + llvm_version = GetGoogle3LLVMVersion() llvm_hash = new_llvm_hash.GetLLVMHash(llvm_version) @@ -255,10 +278,7 @@ class LLVMHash(object): def GetGoogle3LLVMHash(self): """Retrieves the google3 LLVM hash.""" - google3_llvm = LLVMVersion() - google3_llvm_version = google3_llvm.GetGoogle3LLVMVersion() - - return self.GetLLVMHash(google3_llvm_version) + return self.GetLLVMHash(GetGoogle3LLVMVersion()) def GetTopOfTrunkGitHash(self): """Gets the latest git hash from top of trunk of LLVM.""" diff --git a/llvm_tools/llvm_patch_management.py b/llvm_tools/llvm_patch_management.py index 9c4d9410..ac8adc83 100755 --- a/llvm_tools/llvm_patch_management.py +++ b/llvm_tools/llvm_patch_management.py @@ -16,7 +16,7 @@ import patch_manager from assert_not_in_chroot import VerifyOutsideChroot from cros_utils import command_executer from failure_modes import FailureModes -from get_google3_llvm_version import LLVMVersion +from get_llvm_hash import GetGoogle3LLVMVersion from get_llvm_hash import LLVMHash ce = command_executer.GetCommandExecuter() @@ -262,7 +262,7 @@ def main(): # Get the google3 LLVM version if a LLVM version was not provided. if not args_output.llvm_version: - args_output.llvm_version = LLVMVersion().GetGoogle3LLVMVersion() + args_output.llvm_version = GetGoogle3LLVMVersion() UpdatePackagesPatchMetadataFile( args_output.chroot_path, args_output.llvm_version, |