| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Script to install arm choot image for cross building of arm chrome on linux. | 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 | 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 | 8 # hooks. When run from hooks this script should be a no-op on non-linux |
| 9 # platforms. | 9 # platforms. |
| 10 | 10 |
| 11 # The sysroot image could be constructed from scratch based on the current | 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 | 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 | 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 | 14 # will normally need to be rebuilt every time chrome's build dependancies are |
| 15 # changed. | 15 # changed. |
| 16 | 16 |
| 17 import os | 17 import os |
| 18 import shutil | 18 import shutil |
| 19 import subprocess | 19 import subprocess |
| 20 import sys | 20 import sys |
| 21 | 21 |
| 22 | 22 |
| 23 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 23 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 24 URL_PREFIX = 'https://commondatastorage.googleapis.com' | 24 URL_PREFIX = 'https://commondatastorage.googleapis.com' |
| 25 URL_PATH = 'nativeclient-archive2/toolchain' | 25 URL_PATH = 'nativeclient-archive2/toolchain' |
| 26 REVISION = 10991 | 26 REVISION = 10991 |
| 27 TARBALL = 'naclsdk_linux_arm-trusted.tgz' |
| 27 | 28 |
| 28 | 29 |
| 29 def main(args): | 30 def main(args): |
| 30 if '--linux-only' in args: | 31 if '--linux-only' in args: |
| 31 # This argument is passed when run from the gclient hooks. | 32 # This argument is passed when run from the gclient hooks. |
| 32 # In this case we return early on non-linux platforms | 33 # In this case we return early on non-linux platforms |
| 33 # or if GYP_DEFINES doesn't include target_arch=arm | 34 # or if GYP_DEFINES doesn't include target_arch=arm |
| 34 if not sys.platform.startswith('linux'): | 35 if not sys.platform.startswith('linux'): |
| 35 return 0 | 36 return 0 |
| 36 | 37 |
| 37 if "target_arch=arm" not in os.environ.get('GYP_DEFINES', ''): | 38 if "target_arch=arm" not in os.environ.get('GYP_DEFINES', ''): |
| 38 return 0 | 39 return 0 |
| 39 | 40 |
| 40 src_root = os.path.dirname(os.path.dirname(SCRIPT_DIR)) | 41 src_root = os.path.dirname(os.path.dirname(SCRIPT_DIR)) |
| 41 sysroot = os.path.join(src_root, 'arm-sysroot') | 42 sysroot = os.path.join(src_root, 'arm-sysroot') |
| 42 url = "%s/%s/%s/naclsdk_linux_arm-trusted.tgz" % (URL_PREFIX, | 43 url = "%s/%s/%s/%s" % (URL_PREFIX, URL_PATH, REVISION, TARBALL) |
| 43 URL_PATH, REVISION) | |
| 44 | 44 |
| 45 stamp = os.path.join(sysroot, ".stamp") | 45 stamp = os.path.join(sysroot, ".stamp") |
| 46 if os.path.exists(stamp): | 46 if os.path.exists(stamp): |
| 47 with open(stamp) as s: | 47 with open(stamp) as s: |
| 48 if s.read() == url: | 48 if s.read() == url: |
| 49 print "ARM root image already up-to-date: %s" % sysroot | 49 print "ARM root image already up-to-date: %s" % sysroot |
| 50 return 0 | 50 return 0 |
| 51 | 51 |
| 52 print "Installing ARM root image: %s" % sysroot | 52 print "Installing ARM root image: %s" % sysroot |
| 53 if os.path.isdir(sysroot): | 53 if os.path.isdir(sysroot): |
| 54 shutil.rmtree(sysroot) | 54 shutil.rmtree(sysroot) |
| 55 os.mkdir(sysroot) | 55 os.mkdir(sysroot) |
| 56 tarball = os.path.join(sysroot, 'naclsdk_linux_arm-trusted.tgz') | 56 tarball = os.path.join(sysroot, TARBALL) |
| 57 subprocess.check_call(['curl', '-L', url, '-o', tarball]) | 57 subprocess.check_call(['curl', '-L', url, '-o', tarball]) |
| 58 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) | 58 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) |
| 59 os.remove(tarball) | 59 os.remove(tarball) |
| 60 | 60 |
| 61 with open(stamp, 'w') as s: | 61 with open(stamp, 'w') as s: |
| 62 s.write(url) | 62 s.write(url) |
| 63 return 0 | 63 return 0 |
| 64 | 64 |
| 65 | 65 |
| 66 if __name__ == '__main__': | 66 if __name__ == '__main__': |
| 67 sys.exit(main(sys.argv[1:])) | 67 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |