| 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 root 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 Steps to rebuild the arm sysroot image: | 17 Steps to rebuild the arm sysroot image: |
| 18 | 18 |
| 19 - cd $SRC/native_client | 19 - cd $SRC/native_client |
| 20 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \ | 20 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \ |
| 21 UpdatePackageLists | 21 UpdatePackageLists |
| 22 - ./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 | 23 BuildJail $SRC/out/arm-sysroot.tar.gz |
| 24 - gsutil cp -a public-read $SRC/out/arm-sysroot.tar.gz \ | 24 - gsutil cp -a public-read $SRC/out/arm-sysroot.tar.gz \ |
| 25 nativeclient-archive2/toolchain/$NACL_REV/naclsdk_linux_arm-trusted.tgz | 25 nativeclient-archive2/toolchain/$NACL_REV/sysroot-arm-trusted.tgz |
| 26 """ | 26 """ |
| 27 | 27 |
| 28 import os | 28 import os |
| 29 import shutil | 29 import shutil |
| 30 import subprocess | 30 import subprocess |
| 31 import sys | 31 import sys |
| 32 | 32 |
| 33 | 33 |
| 34 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 34 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 35 URL_PREFIX = 'https://commondatastorage.googleapis.com' | 35 URL_PREFIX = 'https://commondatastorage.googleapis.com' |
| 36 URL_PATH = 'nativeclient-archive2/toolchain' | 36 URL_PATH = 'nativeclient-archive2/toolchain' |
| 37 REVISION = 12203 | 37 REVISION = 12292 |
| 38 TARBALL = 'naclsdk_linux_arm-trusted.tgz' | 38 TARBALL = 'sysroot-arm-trusted.tgz' |
| 39 | 39 |
| 40 # TODO(sbc): remove armel support once the transision to armhf |
| 41 # is complete. |
| 42 REVISION_ARMEL = 12203 |
| 43 TARBALL_ARMEL = 'naclsdk_linux_arm-trusted.tgz' |
| 40 | 44 |
| 41 def main(args): | 45 def main(args): |
| 42 if '--linux-only' in args: | 46 if '--linux-only' in args: |
| 43 # This argument is passed when run from the gclient hooks. | 47 # This argument is passed when run from the gclient hooks. |
| 44 # In this case we return early on non-linux platforms | 48 # In this case we return early on non-linux platforms |
| 45 # or if GYP_DEFINES doesn't include target_arch=arm | 49 # or if GYP_DEFINES doesn't include target_arch=arm |
| 46 if not sys.platform.startswith('linux'): | 50 if not sys.platform.startswith('linux'): |
| 47 return 0 | 51 return 0 |
| 48 | 52 |
| 49 if "target_arch=arm" not in os.environ.get('GYP_DEFINES', ''): | 53 if "target_arch=arm" not in os.environ.get('GYP_DEFINES', ''): |
| 50 return 0 | 54 return 0 |
| 51 | 55 |
| 52 src_root = os.path.dirname(os.path.dirname(SCRIPT_DIR)) | 56 src_root = os.path.dirname(os.path.dirname(SCRIPT_DIR)) |
| 53 sysroot = os.path.join(src_root, 'arm-sysroot') | 57 sysroot = os.path.join(src_root, 'arm-sysroot') |
| 54 url = "%s/%s/%s/%s" % (URL_PREFIX, URL_PATH, REVISION, TARBALL) | 58 if '-gnueabihf-' in os.environ.get('CC', ''): |
| 59 url = "%s/%s/%s/%s" % (URL_PREFIX, URL_PATH, REVISION, TARBALL) |
| 60 else: |
| 61 url = "%s/%s/%s/%s" % (URL_PREFIX, URL_PATH, REVISION_ARMEL, TARBALL_ARMEL) |
| 55 | 62 |
| 56 stamp = os.path.join(sysroot, ".stamp") | 63 stamp = os.path.join(sysroot, ".stamp") |
| 57 if os.path.exists(stamp): | 64 if os.path.exists(stamp): |
| 58 with open(stamp) as s: | 65 with open(stamp) as s: |
| 59 if s.read() == url: | 66 if s.read() == url: |
| 60 print "ARM root image already up-to-date: %s" % sysroot | 67 print "ARM root image already up-to-date: %s" % sysroot |
| 61 return 0 | 68 return 0 |
| 62 | 69 |
| 63 print "Installing ARM root image: %s" % sysroot | 70 print "Installing ARM root image: %s" % sysroot |
| 64 if os.path.isdir(sysroot): | 71 if os.path.isdir(sysroot): |
| 65 shutil.rmtree(sysroot) | 72 shutil.rmtree(sysroot) |
| 66 os.mkdir(sysroot) | 73 os.mkdir(sysroot) |
| 67 tarball = os.path.join(sysroot, TARBALL) | 74 tarball = os.path.join(sysroot, TARBALL) |
| 68 subprocess.check_call(['curl', '-L', url, '-o', tarball]) | 75 subprocess.check_call(['curl', '-L', url, '-o', tarball]) |
| 69 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) | 76 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) |
| 70 os.remove(tarball) | 77 os.remove(tarball) |
| 71 | 78 |
| 72 with open(stamp, 'w') as s: | 79 with open(stamp, 'w') as s: |
| 73 s.write(url) | 80 s.write(url) |
| 74 return 0 | 81 return 0 |
| 75 | 82 |
| 76 | 83 |
| 77 if __name__ == '__main__': | 84 if __name__ == '__main__': |
| 78 sys.exit(main(sys.argv[1:])) | 85 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |