OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
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. | |
5 | |
6 # Script to install arm choot 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 | |
9 # platforms. | |
10 | |
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 | |
15 # changed. | |
16 | |
17 import os | |
18 import sys | |
19 | |
20 | |
21 script_dir = os.path.dirname(os.path.abspath(__file__)) | |
22 | |
23 | |
24 def main(args): | |
25 if '--linux-only' in args: | |
26 # This argument is passed when run from the gclient hooks. | |
27 # In this case we return early on non-linux platforms | |
28 # or if GYP_DEFINES doesn't include target_arch=arm | |
29 if sys.platform != 'linux2': | |
tony
2012/12/07 01:01:42
Please use sys.platform.startswith('linux'). See t
Sam Clegg
2012/12/07 18:29:37
Done.
| |
30 return | |
31 | |
32 if "target_arch=arm" not in os.environ.get('GYP_DEFINES', ''): | |
tony
2012/12/07 01:01:42
Is it OK that this doesn't run when someone uses ~
Sam Clegg
2012/12/07 18:29:37
Such people will want to run install-arm-sysroot.p
| |
33 return 0 | |
34 | |
35 src_root = os.path.dirname(script_dir) | |
36 sysroot = os.path.join(src_root, 'arm-sysroot') | |
37 url_prefix = 'https://commondatastorage.googleapis.com/nativeclient-archive2/t oolchain' | |
38 rev = 8001 | |
39 url = "%s/%s/naclsdk_linux_arm-trusted.tgz" % (url_prefix, rev) | |
40 | |
41 stamp = os.path.join(sysroot, ".stamp") | |
42 if os.path.exists(stamp): | |
43 with open(stamp) as s: | |
44 if s.read() == url: | |
45 print "ARM root image already up-to-date: %s" % sysroot | |
46 return 0 | |
47 | |
48 print "Installing ARM root image: %s" % sysroot | |
49 if not os.path.isdir(sysroot): | |
50 os.mkdir(sysroot) | |
51 tarball = os.path.join(sysroot, 'naclsdk_linux_arm-trusted.tgz') | |
52 rtn = os.system('curl -L "%s" -o "%s"' % (url, tarball)) | |
53 if rtn: | |
54 return rtn | |
55 rtn = os.system('tar xf %s -C %s' % (tarball, sysroot)) | |
56 if rtn: | |
57 return rtn | |
58 os.remove(tarball) | |
59 open(stamp, 'w').write(url) | |
60 | |
61 return 0 | |
62 | |
63 | |
64 if __name__ == '__main__': | |
65 sys.exit(main(sys.argv[1:])) | |
OLD | NEW |