Instrumented libraries: Remove dependence on GYP_DEFINES
This CL ports download_binaries.py and unpack_binaries.py from using
GYP_DEFINES to gn args. Previously, there was a gotcha step where you
had to run 'gclient sync' with the right GYP_DEFINES to actually download
the prebuilt instrumented libraries. This CL removes that step.
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_msan_rel_ng;master.tryserver.chromium.linux:linux_chromium_chromeos_msan_rel_ng
R=eugenis@chromium.org
BUG=705072
Review-Url: https://codereview.chromium.org/2775913002
Cr-Original-Commit-Position: refs/heads/master@{#459630}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 5adb8c047852670be6c9d42114f3a17d44b6c56e
diff --git a/BUILD.gn b/BUILD.gn
index 9d7636a..4d1e910 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -57,18 +57,27 @@
}
}
- # TODO(GYP): scripts/download_binaries.py uses GYP_DEFINES to decide whether
- # to download the archives extracted here.
+ action("download_prebuilt_instrumented_libraries") {
+ tarfile_name = "$archive_prefix-$instrumented_libraries_platform.tgz"
+ shafile = "binaries/$tarfile_name.sha1"
+ tarfile = "$target_out_dir/$tarfile_name"
+ inputs = [ shafile ]
+ outputs = [ tarfile ]
+ script = "scripts/download_binaries.py"
+ args = [ rebase_path(shafile), rebase_path(tarfile) ]
+ }
+
# Note: This requires a clobber whenever Ubuntu version changes.
action("extract_prebuilt_instrumented_libraries") {
+ deps = [ ":download_prebuilt_instrumented_libraries" ]
visibility = [ ":prebuilt" ]
script = "scripts/unpack_binaries.py"
depfile = "$target_out_dir/$archive_prefix.d"
+ tarfile = get_target_outputs(":download_prebuilt_instrumented_libraries")
args = [
- archive_prefix,
- rebase_path("binaries"),
+ rebase_path(tarfile[0]),
+ rebase_path("$target_out_dir/$archive_prefix.txt"),
rebase_path(root_out_dir + "/instrumented_libraries_prebuilt"),
- rebase_path(target_out_dir, root_out_dir),
]
outputs = [
"$target_out_dir/$archive_prefix.txt",
diff --git a/scripts/download_binaries.py b/scripts/download_binaries.py
index b7e87b2..fa339cc 100755
--- a/scripts/download_binaries.py
+++ b/scripts/download_binaries.py
@@ -3,69 +3,34 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Downloads pre-built sanitizer-instrumented third-party libraries from GCS."""
+"""Downloads pre-built sanitizer-instrumented third-party libraries from GCS.
+This script should only be run from gn.
+"""
-import os
-import re
import subprocess
import sys
-SCRIPT_PATH = os.path.abspath(__file__)
-BASE_PATH = os.path.normpath(os.path.join(SCRIPT_PATH, *(4 * ['..'])))
-
-# This defaults to the consuming project's base directory, e.g. 'src' in
-# chromium.
-BASE_DIR = os.path.basename(BASE_PATH)
-
-
-def get_ubuntu_release():
- supported_releases = ['trusty']
- release = subprocess.check_output(['lsb_release', '-cs']).strip()
- if release not in supported_releases:
- raise Exception("Supported Ubuntu versions: %s", str(supported_releases))
- return release
-
-
-def get_configuration(gyp_defines):
- if re.search(r'\b(msan)=1', gyp_defines):
- if 'msan_track_origins=0' in gyp_defines:
- return 'msan-no-origins'
- if 'msan_track_origins=2' in gyp_defines:
- return 'msan-chained-origins'
- if 'msan_track_origins=' not in gyp_defines:
- # NB: must be the same as the default value in common.gypi
- return 'msan-chained-origins'
- raise Exception(
- "Prebuilt instrumented libraries not available for your configuration.")
-
-
-def get_archive_name(gyp_defines):
- return "%s-%s.tgz" % (get_configuration(gyp_defines), get_ubuntu_release())
-
-
def main(args):
- gyp_defines = os.environ.get('GYP_DEFINES', '')
- if not 'use_prebuilt_instrumented_libraries=1' in gyp_defines:
- return 0
-
if not sys.platform.startswith('linux'):
- raise Exception("'use_prebuilt_instrumented_libraries=1' requires Linux.")
+ raise Exception("Prebuilt instrumented libraries require Linux.")
- archive_name = get_archive_name(gyp_defines)
- sha1file = '%s.sha1' % archive_name
- target_directory = os.path.join(
- BASE_DIR, 'third_party', 'instrumented_libraries', 'binaries')
+ sha1file = args[0]
+ tarfile = args[1]
subprocess.check_call([
'download_from_google_storage',
'--no_resume',
'--no_auth',
'--bucket', 'chromium-instrumented-libraries',
- '-s', sha1file], cwd=target_directory)
+ '-s', sha1file, '-o', tarfile])
return 0
if __name__ == '__main__':
+ # TODO(thomasanderson): Remove this once all third_party DEPS
+ # entires for this script are removed.
+ if (len(sys.argv) == 1):
+ sys.exit(0)
sys.exit(main(sys.argv[1:]))
diff --git a/scripts/unpack_binaries.py b/scripts/unpack_binaries.py
index 3e17790..2f335bc 100755
--- a/scripts/unpack_binaries.py
+++ b/scripts/unpack_binaries.py
@@ -3,38 +3,27 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Unpacks pre-built sanitizer-instrumented third-party libraries."""
+"""Unpacks pre-built sanitizer-instrumented third-party libraries.
+This script should only be run by gn.
+"""
import os
import subprocess
import shutil
import sys
-import download_binaries
-
-def get_archive_name(archive_prefix):
- return '%s-%s.tgz' % (archive_prefix, download_binaries.get_ubuntu_release())
-
-
-def main(archive_prefix, archive_dir, target_dir, stamp_dir=None):
+def main(archive, stamp_file, target_dir):
shutil.rmtree(target_dir, ignore_errors=True)
os.mkdir(target_dir)
subprocess.check_call([
'tar',
'-zxf',
- os.path.join(archive_dir, get_archive_name(archive_prefix)),
+ archive,
'-C',
target_dir])
- stamp_file = os.path.join(stamp_dir or target_dir, '%s.txt' % archive_prefix)
open(stamp_file, 'w').close()
-
- if stamp_dir:
- with open(os.path.join(stamp_dir, '%s.d' % archive_prefix), 'w') as f:
- f.write('%s: %s' % (
- stamp_file, os.path.join(archive_dir,
- get_archive_name(archive_prefix))))
return 0