2012-12-09 01:04:20 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2013-09-30 22:51:46 +04:00
|
|
|
"""Script to install ARM root image for cross building of ARM chrome on linux.
|
|
|
|
This script can be run manually but is more often run as part of gclient
|
|
|
|
hooks. When run from hooks this script should be a no-op on non-linux
|
|
|
|
platforms.
|
2012-12-09 01:04:20 +04:00
|
|
|
|
2013-09-30 22:51:46 +04:00
|
|
|
The sysroot image could be constructed from scratch based on the current
|
|
|
|
state or precise/arm but for consistency we currently use a pre-built root
|
|
|
|
image which was originally designed for building trusted NaCl code. The image
|
|
|
|
will normally need to be rebuilt every time chrome's build dependancies are
|
|
|
|
changed.
|
|
|
|
|
|
|
|
Steps to rebuild the arm sysroot image:
|
|
|
|
|
|
|
|
- cd $SRC/native_client
|
|
|
|
- ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \
|
|
|
|
UpdatePackageLists
|
|
|
|
- ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \
|
|
|
|
BuildJail $SRC/out/arm-sysroot.tar.gz
|
|
|
|
- gsutil cp -a public-read $SRC/out/arm-sysroot.tar.gz \
|
2013-10-29 06:38:46 +04:00
|
|
|
nativeclient-archive2/toolchain/$NACL_REV/sysroot-arm-trusted.tgz
|
2013-09-30 22:51:46 +04:00
|
|
|
"""
|
2012-12-09 01:04:20 +04:00
|
|
|
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
2013-01-04 02:16:25 +04:00
|
|
|
URL_PREFIX = 'https://commondatastorage.googleapis.com'
|
|
|
|
URL_PATH = 'nativeclient-archive2/toolchain'
|
2013-11-05 02:25:24 +04:00
|
|
|
REVISION = 12356
|
2013-10-29 06:38:46 +04:00
|
|
|
TARBALL = 'sysroot-arm-trusted.tgz'
|
2012-12-09 01:04:20 +04:00
|
|
|
|
|
|
|
def main(args):
|
|
|
|
if '--linux-only' in args:
|
|
|
|
# This argument is passed when run from the gclient hooks.
|
|
|
|
# In this case we return early on non-linux platforms
|
|
|
|
# or if GYP_DEFINES doesn't include target_arch=arm
|
|
|
|
if not sys.platform.startswith('linux'):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if "target_arch=arm" not in os.environ.get('GYP_DEFINES', ''):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
src_root = os.path.dirname(os.path.dirname(SCRIPT_DIR))
|
|
|
|
sysroot = os.path.join(src_root, 'arm-sysroot')
|
2013-11-05 02:25:24 +04:00
|
|
|
url = "%s/%s/%s/%s" % (URL_PREFIX, URL_PATH, REVISION, TARBALL)
|
2012-12-09 01:04:20 +04:00
|
|
|
|
|
|
|
stamp = os.path.join(sysroot, ".stamp")
|
|
|
|
if os.path.exists(stamp):
|
|
|
|
with open(stamp) as s:
|
|
|
|
if s.read() == url:
|
|
|
|
print "ARM root image already up-to-date: %s" % sysroot
|
|
|
|
return 0
|
|
|
|
|
|
|
|
print "Installing ARM root image: %s" % sysroot
|
|
|
|
if os.path.isdir(sysroot):
|
|
|
|
shutil.rmtree(sysroot)
|
|
|
|
os.mkdir(sysroot)
|
2013-05-10 06:32:19 +04:00
|
|
|
tarball = os.path.join(sysroot, TARBALL)
|
2012-12-09 01:04:20 +04:00
|
|
|
subprocess.check_call(['curl', '-L', url, '-o', tarball])
|
|
|
|
subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot])
|
|
|
|
os.remove(tarball)
|
|
|
|
|
|
|
|
with open(stamp, 'w') as s:
|
|
|
|
s.write(url)
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main(sys.argv[1:]))
|