aboutsummaryrefslogtreecommitdiff
path: root/llvm_tools
diff options
context:
space:
mode:
authorSalud Lemus <saludlemus@google.com>2019-07-31 10:18:19 -0700
committerSalud Lemus <saludlemus@google.com>2019-08-01 22:44:50 +0000
commit2493f134145c4102a37f8df2113af945f37e5b06 (patch)
treed52d06f475b4f4a0ba76a6d17dde5008efcad40a /llvm_tools
parent1394e94e88b54b10afe0dbaad656de8cd21f3431 (diff)
downloadtoolchain-utils-2493f134145c4102a37f8df2113af945f37e5b06.tar.gz
LLVM tools: Removed calls to g4 when retrieving latest g3 LLVM version
BUG=None TEST=Ran the script and the correct g3 LLVM version was returned Change-Id: I37847c56b1f72f3ceadc9e5fb7171faae273203c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1729508 Reviewed-by: George Burgess <gbiv@chromium.org> Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: Salud Lemus <saludlemus@google.com>
Diffstat (limited to 'llvm_tools')
-rwxr-xr-xllvm_tools/get_google3_llvm_version.py97
1 files changed, 19 insertions, 78 deletions
diff --git a/llvm_tools/get_google3_llvm_version.py b/llvm_tools/get_google3_llvm_version.py
index 420ec7ea..33599c2a 100755
--- a/llvm_tools/get_google3_llvm_version.py
+++ b/llvm_tools/get_google3_llvm_version.py
@@ -4,118 +4,59 @@
# 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"""
+"""Gets the latest google3 LLVM version"""
from __future__ import print_function
from pipes import quote
import argparse
-import traceback
-import os
from cros_utils import command_executer
class LLVMVersion(object):
- """Provides a method to retrieve the latest google3 llvm version."""
+ """Provides a method to retrieve the latest google3 LLVM version."""
def __init__(self, log_level="none"):
self._ce = command_executer.GetCommandExecuter(log_level=log_level)
- def _DeleteClient(self):
- """Deletes a created client."""
-
- # delete client
- delete_cmd = 'g4 citc -d my_local_client'
- ret, _, err = self._ce.RunCommandWOutput(delete_cmd, print_to_console=False)
-
- if ret: # failed to delete client
- raise ValueError("Failed to delete client: %s" % err)
-
- def _CreateClient(self):
- """Creates a client returns a path to the google3 directory.
-
- Args:
- ce: A CommandExecuter object for executing commands
-
- Returns:
- A string that is the path to the google3 directory.
-
- Raises:
- Exception: Failed to create a client.
- """
-
- # number of tries to create client
- num_tries = 2
-
- # cmd to create client
- client_cmd = 'p4 g4d -f my_local_client'
-
- # try to create client
- for _ in range(num_tries):
- ret, google3_path, err = self._ce.RunCommandWOutput(
- client_cmd, print_to_console=False)
-
- if not ret: # created client
- return google3_path
-
- try: # delete client and re-try
- self._DeleteClient()
- except ValueError:
- traceback.print_exc()
-
- raise Exception('Failed to create a client: %s' % err)
-
def GetGoogle3LLVMVersion(self):
- """Gets the latest google3 llvm version.
-
- Creates a client to retrieve the llvm version.
- The client is then deleted after the llvm version is retrieved.
+ """Gets the latest google3 LLVM version.
Returns:
- The latest llvm version as an integer.
+ The latest LLVM version as an integer.
Raises:
- Exception: An invalid path has been provided to the cat command.
+ ValueError: An invalid path has been provided to the cat command.
"""
- # create a client and get the path
- google3_path = self._CreateClient()
-
- try:
- # remove '\n' at the end
- google3_path = google3_path.strip()
+ path_to_google3_llvm_version = ('/google/src/head/depot/google3/third_party'
+ '/crosstool/v18/stable/installs/llvm/'
+ 'revision')
- # cmd to retrieve latest version
- llvm_version_path = 'third_party/crosstool/v18/stable/' \
- 'installs/llvm/revision'
+ # Cmd to get latest google3 LLVM version.
+ cat_cmd = 'cat %s' % quote(path_to_google3_llvm_version)
- path_to_version = os.path.join(google3_path, llvm_version_path)
- cat_cmd = 'cat %s' % quote(path_to_version)
+ # Get latest version.
+ ret, g3_version, err = self._ce.RunCommandWOutput(
+ cat_cmd, print_to_console=False)
- # get latest version
- ret, g3_version, err = self._ce.RunCommandWOutput(
- cat_cmd, print_to_console=False)
- # check return code
- if ret: # failed to get latest version
- raise Exception('Failed to get google3 llvm version: %s' % err)
- finally:
- # no longer need the client
- self._DeleteClient()
+ if ret: # Failed to get the latest google3 LLVM version.
+ raise ValueError('Failed to get google3 LLVM version: %s' % err)
- # change type to an integer
- return int(g3_version.strip())
+ # Change type to an integer
+ return int(g3_version.rstrip())
def main():
- """Prints the google3 llvm version.
+ """Prints the google3 LLVM version.
Parses the command line for the optional command line
argument.
"""
# create parser and add optional command-line argument
- parser = argparse.ArgumentParser(description='Get the google3 llvm version.')
+ parser = argparse.ArgumentParser(description='Get the google3 LLVM version.')
parser.add_argument(
'--log_level',
default='none',