diff options
author | Denis Nikitin <denik@google.com> | 2020-10-06 12:07:42 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-13 13:18:33 +0000 |
commit | 5672f28e2acdf00721356e67a4de7d03f4d18960 (patch) | |
tree | 3affafe96d91d07316d4f250fb9d734850c5315f /crosperf | |
parent | aac9c23c9414831617739e1271aa9491b04b7e4f (diff) | |
download | toolchain-utils-5672f28e2acdf00721356e67a4de7d03f4d18960.tar.gz |
crosperf: refactor chrome src search
Replace multiple levels of if/else of the chrome src search with a loop.
Add a missing search path .cache/distfiles/chrome-src.
Add checks for the Chrome source location and raise RuntimeError if it
does not exist.
BUG=None
TEST=Tested with crosperf and distfiles/target/chrome-src-internal.
Change-Id: I66dd7c802a4e80238e4d625586198bdf573621dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2453595
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Caroline Tice <cmtice@chromium.org>
Tested-by: Denis Nikitin <denik@chromium.org>
Commit-Queue: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'crosperf')
-rw-r--r-- | crosperf/label.py | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/crosperf/label.py b/crosperf/label.py index b14c4a73..a55d663c 100644 --- a/crosperf/label.py +++ b/crosperf/label.py @@ -72,22 +72,31 @@ class Label(object): self.chromeos_root = chromeos_root if not chrome_src: - self.chrome_src = os.path.join( - self.chromeos_root, '.cache/distfiles/target/chrome-src-internal') - if not os.path.exists(self.chrome_src): - self.chrome_src = os.path.join(self.chromeos_root, - '.cache/distfiles/target/chrome-src') - # Chrome source location has changed and we have to support - # old and new path. - if not os.path.exists(self.chrome_src): - self.chrome_src = os.path.join(self.chromeos_root, - '.cache/distfiles/chrome-src-internal') + # Old and new chroots may have different chrome src locations. + # The path also depends on the chrome build flags. + # Give priority to chrome-src-internal. + chrome_src_rel_paths = [ + '.cache/distfiles/target/chrome-src-internal', + '.cache/distfiles/chrome-src-internal', + '.cache/distfiles/target/chrome-src', + '.cache/distfiles/chrome-src', + ] + for chrome_src_rel_path in chrome_src_rel_paths: + chrome_src_abs_path = os.path.join(self.chromeos_root, + chrome_src_rel_path) + if os.path.exists(chrome_src_abs_path): + chrome_src = chrome_src_abs_path + break + if not chrome_src: + raise RuntimeError('Can not find location of Chrome sources.\n' + f'Checked paths: {chrome_src_rel_paths}') else: - chromeos_src = misc.CanonicalizePath(chrome_src) - if not chromeos_src: + chrome_src = misc.CanonicalizePath(chrome_src) + # Make sure the path exists. + if not os.path.exists(chrome_src): raise RuntimeError("Invalid Chrome src given for label '%s': '%s'." % (name, chrome_src)) - self.chrome_src = chromeos_src + self.chrome_src = chrome_src self._SetupChecksum() |