2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Script to install ARM root image for cross building of ARM chrome on linux.
7 This script can be run manually but is more often run as part of gclient
8 hooks. When run from hooks this script should be a no-op on non-linux
11 The sysroot image could be constructed from scratch based on the current
12 state or precise/arm but for consistency we currently use a pre-built root
13 image which was originally designed for building trusted NaCl code. The image
14 will normally need to be rebuilt every time chrome's build dependancies are
17 Steps to rebuild the arm sysroot image:
19 - cd $SRC/native_client
20 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \
22 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \
23 BuildJail $SRC/out/arm-sysroot.tar.gz
24 - gsutil cp -a public-read $SRC/out/arm-sysroot.tar.gz \
25 nativeclient-archive2/toolchain/$NACL_REV/sysroot-arm-trusted.tgz
34 SCRIPT_DIR
= os
.path
.dirname(os
.path
.abspath(__file__
))
35 URL_PREFIX
= 'https://storage.googleapis.com'
36 URL_PATH
= 'nativeclient-archive2/toolchain'
38 TARBALL
= 'sysroot-arm-trusted.tgz'
41 if '--linux-only' in args
:
42 # This argument is passed when run from the gclient hooks.
43 # In this case we return early on non-linux platforms
44 # or if GYP_DEFINES doesn't include target_arch=arm
45 if not sys
.platform
.startswith('linux'):
48 if "target_arch=arm" not in os
.environ
.get('GYP_DEFINES', ''):
51 src_root
= os
.path
.dirname(os
.path
.dirname(SCRIPT_DIR
))
52 sysroot
= os
.path
.join(src_root
, 'arm-sysroot')
53 url
= "%s/%s/%s/%s" % (URL_PREFIX
, URL_PATH
, REVISION
, TARBALL
)
55 stamp
= os
.path
.join(sysroot
, ".stamp")
56 if os
.path
.exists(stamp
):
57 with
open(stamp
) as s
:
59 print "ARM root image already up-to-date: %s" % sysroot
62 print "Installing ARM root image: %s" % sysroot
63 if os
.path
.isdir(sysroot
):
64 shutil
.rmtree(sysroot
)
66 tarball
= os
.path
.join(sysroot
, TARBALL
)
67 curl
= ['curl', '--fail', '-L', url
, '-o', tarball
]
68 if os
.isatty(sys
.stdout
.fileno()):
69 curl
.append('--progress')
71 curl
.append('--silent')
72 subprocess
.check_call(curl
)
73 subprocess
.check_call(['tar', 'xf', tarball
, '-C', sysroot
])
76 with
open(stamp
, 'w') as s
:
81 if __name__
== '__main__':
82 sys
.exit(main(sys
.argv
[1:]))