Add CR_SYSROOT_HASH define to force rebuilds on sysroot updates

R=thestig
TBR=thakis
BUG=800977

Change-Id: I1147d171fee32e8ce51c08449a1a50144d5e051b
Reviewed-on: https://chromium-review.googlesource.com/1002986
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#549213}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 745a6ceac201f7f7d27d730bae779d02df16ad80
This commit is contained in:
Tom Anderson 2018-04-09 17:38:24 +00:00 коммит произвёл Commit Bot
Родитель 6a4ce03ebb
Коммит d1819b57cc
2 изменённых файлов: 36 добавлений и 18 удалений

Просмотреть файл

@ -25,6 +25,7 @@ config("runtime_library") {
cflags_cc = []
cflags_objc = []
cflags_objcc = []
defines = []
ldflags = []
lib_dirs = []
libs = []
@ -32,7 +33,7 @@ config("runtime_library") {
if (use_custom_libcxx) {
if (libcpp_is_static) {
# Don't leak any symbols on a static build.
defines = [
defines += [
"_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
]
@ -71,6 +72,17 @@ config("runtime_library") {
if (!is_mac && !is_ios && sysroot != "") {
# Pass the sysroot to all C compiler variants, the assembler, and linker.
sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
if (is_linux) {
# This is here so that all files get recompiled after a sysroot roll and
# when turning the sysroot on or off. (defines are passed via the command
# line, and build system rebuilds things when their commandline
# changes). Nothing should ever read this define.
sysroot_hash =
exec_script("//build/linux/sysroot_scripts/install-sysroot.py",
[ "--print-hash=$current_cpu" ],
"trim string")
defines += [ "CR_SYSROOT_HASH=$sysroot_hash" ]
}
asmflags += sysroot_flags
link_sysroot_flags =

Просмотреть файл

@ -30,7 +30,6 @@ import sys
import urllib2
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.dirname(os.path.dirname(SCRIPT_DIR)))
URL_PREFIX = 'https://commondatastorage.googleapis.com'
URL_PATH = 'chrome-linux-sysroot/toolchain'
@ -44,6 +43,8 @@ ARCH_TRANSLATIONS = {
'mips64': 'mips64el',
}
DEFAULT_TARGET_PLATFORM = 'sid'
class Error(Exception):
pass
@ -67,45 +68,50 @@ def main(args):
parser.add_option('--all', action='store_true',
help='Install all sysroot images (useful when updating the'
' images)')
parser.add_option('--print-hash',
help='Print the hash of the sysroot for the given arch.')
options, _ = parser.parse_args(args)
if not sys.platform.startswith('linux'):
return 0
if options.print_hash:
arch = options.print_hash
print GetSysrootDict(DEFAULT_TARGET_PLATFORM,
ARCH_TRANSLATIONS.get(arch, arch))['Sha1Sum']
return 0
if options.arch:
InstallDefaultSysrootForArch(
ARCH_TRANSLATIONS.get(options.arch, options.arch))
InstallSysroot(DEFAULT_TARGET_PLATFORM,
ARCH_TRANSLATIONS.get(options.arch, options.arch))
elif options.all:
for arch in VALID_ARCHS:
InstallDefaultSysrootForArch(arch)
InstallSysroot(DEFAULT_TARGET_PLATFORM, arch)
else:
print 'You much specify either --arch or --all'
print 'You much specify one of the options.'
return 1
return 0
def InstallDefaultSysrootForArch(target_arch):
def GetSysrootDict(target_platform, target_arch):
if target_arch not in VALID_ARCHS:
raise Error('Unknown architecture: %s' % target_arch)
InstallSysroot('Sid', target_arch)
def InstallSysroot(target_platform, target_arch):
# The sysroot directory should match the one specified in
# build/config/sysroot.gni.
# TODO(thestig) Consider putting this elsewhere to avoid having to recreate
# it on every build.
linux_dir = os.path.dirname(SCRIPT_DIR)
sysroots_file = os.path.join(SCRIPT_DIR, 'sysroots.json')
sysroots = json.load(open(sysroots_file))
sysroot_key = '%s_%s' % (target_platform.lower(), target_arch)
sysroot_key = '%s_%s' % (target_platform, target_arch)
if sysroot_key not in sysroots:
raise Error('No sysroot for: %s %s' % (target_platform, target_arch))
sysroot_dict = sysroots[sysroot_key]
return sysroots[sysroot_key]
def InstallSysroot(target_platform, target_arch):
sysroot_dict = GetSysrootDict(target_platform, target_arch)
revision = sysroot_dict['Revision']
tarball_filename = sysroot_dict['Tarball']
tarball_sha1sum = sysroot_dict['Sha1Sum']
# TODO(thestig) Consider putting this elsewhere to avoid having to recreate
# it on every build.
linux_dir = os.path.dirname(SCRIPT_DIR)
sysroot = os.path.join(linux_dir, sysroot_dict['SysrootDir'])
url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, tarball_filename)