aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Beltran <ryanbeltran@chromium.org>2021-08-11 09:53:12 +0000
committerRyan Beltran <ryanbeltran@chromium.org>2021-08-11 20:45:20 +0000
commitbf26752f01853772132713de650fd574d1c3f5e0 (patch)
tree7f5a38dc4e3a283c92ad4654cad4b2ed4bba5593
parentaf7b646e9ec66fb6ed16f01071ec390e1c565ec1 (diff)
downloadtoolchain-utils-bf26752f01853772132713de650fd574d1c3f5e0.tar.gz
llvm_tools: update llvm major in non-llvm ebuilds
This CL implements updating the llvm major version in non-llvm ebuilds. An example of the current behavior (which uprevs the major version only for the LLVM ebuild) can be seen here: https://crrev.com/c/3080644/2 BUG=b:196193631 TEST=./update_chromeos_llvm_hash_unittest.py Change-Id: Icf82f0a8a4a01b255d0eeb242fe139aaa6957920 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3088319 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Commit-Queue: Ryan Beltran <ryanbeltran@chromium.org> Tested-by: Ryan Beltran <ryanbeltran@chromium.org>
-rwxr-xr-xllvm_tools/update_chromeos_llvm_hash.py6
-rwxr-xr-xllvm_tools/update_chromeos_llvm_hash_unittest.py16
2 files changed, 13 insertions, 9 deletions
diff --git a/llvm_tools/update_chromeos_llvm_hash.py b/llvm_tools/update_chromeos_llvm_hash.py
index afc63f3c..ab83321a 100755
--- a/llvm_tools/update_chromeos_llvm_hash.py
+++ b/llvm_tools/update_chromeos_llvm_hash.py
@@ -300,13 +300,12 @@ def UprevEbuildToVersion(symlink, svn_version, git_hash):
raise ValueError('Invalid symlink provided: %s' % symlink)
ebuild = os.path.realpath(symlink)
+ llvm_major_version = get_llvm_hash.GetLLVMMajorVersion(git_hash)
# llvm
package = os.path.basename(os.path.dirname(symlink))
if not package:
raise ValueError('Tried to uprev an unknown package')
- # llvm
if package == 'llvm':
- llvm_major_version = get_llvm_hash.GetLLVMMajorVersion(git_hash)
new_ebuild, is_changed = re.subn(
r'(\d+)\.(\d+)_pre([0-9]+)_p([0-9]+)',
'%s.\\2_pre%s_p%s' % (llvm_major_version, svn_version,
@@ -316,7 +315,8 @@ def UprevEbuildToVersion(symlink, svn_version, git_hash):
# any other package
else:
new_ebuild, is_changed = re.subn(
- r'pre([0-9]+)', 'pre%s' % svn_version, ebuild, count=1)
+ r'(\d+)\.(\d+)_pre([0-9]+)',
+ '%s.\\2_pre%s' % (llvm_major_version, svn_version), ebuild, count=1)
if not is_changed: # failed to increment the revision number
raise ValueError('Failed to uprev the ebuild.')
diff --git a/llvm_tools/update_chromeos_llvm_hash_unittest.py b/llvm_tools/update_chromeos_llvm_hash_unittest.py
index 01306ad6..adb20598 100755
--- a/llvm_tools/update_chromeos_llvm_hash_unittest.py
+++ b/llvm_tools/update_chromeos_llvm_hash_unittest.py
@@ -311,16 +311,19 @@ class UpdateLLVMHashTest(unittest.TestCase):
self.assertEqual(mock_command_output.call_args_list[3],
mock.call(expected_cmd))
+ @mock.patch.object(get_llvm_hash, 'GetLLVMMajorVersion')
@mock.patch.object(os.path, 'islink', return_value=True)
@mock.patch.object(os.path, 'realpath')
@mock.patch.object(subprocess, 'check_output', return_value=None)
def testSuccessfullyUprevEbuildToVersionNonLLVM(self, mock_command_output,
- mock_realpath, mock_islink):
- symlink = '/path/to/compiler-rt/compiler-rt_pre3_p2-r10.ebuild'
- ebuild = '/abs/path/to/compiler-rt/compiler-rt_pre3_p2.ebuild'
+ mock_realpath, mock_islink,
+ mock_llvm_version):
+ symlink = '/abs/path/to/compiler-rt/compiler-rt-12.0_pre314159265-r4.ebuild'
+ ebuild = '/abs/path/to/compiler-rt/compiler-rt-12.0_pre314159265.ebuild'
mock_realpath.return_value = ebuild
+ mock_llvm_version.return_value = '1234'
svn_version = 1000
- git_hash = '1234'
+ git_hash = '5678'
update_chromeos_llvm_hash.UprevEbuildToVersion(symlink, svn_version,
git_hash)
@@ -329,12 +332,13 @@ class UpdateLLVMHashTest(unittest.TestCase):
mock_realpath.assert_called_once_with(symlink)
+ mock_llvm_version.assert_called_once_with(git_hash)
+
mock_command_output.assert_called()
# Verify commands
symlink_dir = os.path.dirname(symlink)
- new_ebuild, _ = re.subn(
- r'pre([0-9]+)', 'pre%s' % svn_version, ebuild, count=1)
+ new_ebuild = '/abs/path/to/compiler-rt/compiler-rt-1234.0_pre1000.ebuild'
new_symlink = new_ebuild[:-len('.ebuild')] + '-r1.ebuild'
expected_cmd = ['git', '-C', symlink_dir, 'mv', ebuild, new_ebuild]