diff options
Diffstat (limited to 'infra/bots/assets/armhf_sysroot')
-rw-r--r-- | infra/bots/assets/armhf_sysroot/README.md | 9 | ||||
-rw-r--r-- | infra/bots/assets/armhf_sysroot/VERSION | 1 | ||||
-rwxr-xr-x | infra/bots/assets/armhf_sysroot/common.py | 26 | ||||
-rwxr-xr-x | infra/bots/assets/armhf_sysroot/create.py | 78 | ||||
-rwxr-xr-x | infra/bots/assets/armhf_sysroot/create_and_upload.py | 46 | ||||
-rwxr-xr-x | infra/bots/assets/armhf_sysroot/download.py | 16 | ||||
-rwxr-xr-x | infra/bots/assets/armhf_sysroot/upload.py | 16 |
7 files changed, 192 insertions, 0 deletions
diff --git a/infra/bots/assets/armhf_sysroot/README.md b/infra/bots/assets/armhf_sysroot/README.md new file mode 100644 index 0000000000..257acd7b7a --- /dev/null +++ b/infra/bots/assets/armhf_sysroot/README.md @@ -0,0 +1,9 @@ +ARM (hard float) sysroot for cross-compiling c++ code on a x86_64 Linux bot. + +Run create_and_upload which installs the following debian packages and turns them +into a toolchain: + + libstdc++-4.8-dev-armhf-cross libgcc-4.8-dev-armhf-cross binutils-arm-linux-gnueabihf + +Take a peak at `/usr/arm-linux-gnueabihf/include/c++/4.8.X` - you may need to update the +include paths if that number changed from the previous release (currently 4.8.4).
\ No newline at end of file diff --git a/infra/bots/assets/armhf_sysroot/VERSION b/infra/bots/assets/armhf_sysroot/VERSION new file mode 100644 index 0000000000..e440e5c842 --- /dev/null +++ b/infra/bots/assets/armhf_sysroot/VERSION @@ -0,0 +1 @@ +3
\ No newline at end of file diff --git a/infra/bots/assets/armhf_sysroot/common.py b/infra/bots/assets/armhf_sysroot/common.py new file mode 100755 index 0000000000..4920c9b4fb --- /dev/null +++ b/infra/bots/assets/armhf_sysroot/common.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Common vars used by scripts in this directory.""" + + +import os +import sys + +FILE_DIR = os.path.dirname(os.path.abspath(__file__)) +INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir)) + +sys.path.insert(0, INFRA_BOTS_DIR) +from assets import assets + +ASSET_NAME = os.path.basename(FILE_DIR) + + +def run(cmd): + """Run a command, eg. "upload" or "download". """ + assets.main([cmd, ASSET_NAME] + sys.argv[1:]) diff --git a/infra/bots/assets/armhf_sysroot/create.py b/infra/bots/assets/armhf_sysroot/create.py new file mode 100755 index 0000000000..7be59fbc8e --- /dev/null +++ b/infra/bots/assets/armhf_sysroot/create.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Create the asset.""" + + +import argparse +import fileinput +import os +import shutil +import subprocess +import sys + +from distutils import dir_util + + +def create_asset(target_dir): + """Create the asset.""" + + print "Installing some cross-compiling packages. Hit enter to continue." + raw_input() + subprocess.check_call([ + "sudo","apt-get","install", + "libstdc++-4.8-dev-armhf-cross", + "libgcc-4.8-dev-armhf-cross", + "binutils-arm-linux-gnueabihf" + ]) + + + shutil.copytree('/usr/arm-linux-gnueabihf', target_dir) + shutil.copytree('/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8.4', + os.path.join(target_dir, 'gcc-cross')) + # copy_tree allows copying into a dir that exists + # We need to augment the toolchain with some lib*.so that help ld + # do its magic as well as some includes that may be useful. + dir_util.copy_tree('/usr/x86_64-linux-gnu/arm-linux-gnueabihf/lib', + os.path.join(target_dir, 'lib')) + dir_util.copy_tree('/usr/x86_64-linux-gnu/arm-linux-gnueabihf/include', + os.path.join(target_dir, 'include')) + + # The file paths in libpthread.so and libc.so start off as absolute file + # paths (e.g. /usr/arm-linux-gnueabihf/lib/libpthread.so.0), which won't + # work on the bots. We use fileinput to replace just those lines (which + # start with GROUP). fileinput redirects stdout, so printing here actually + # writes to the file. + bad_libpthread = os.path.join(target_dir, "lib", "libpthread.so") + for line in fileinput.input(bad_libpthread, inplace=True): + if line.startswith("GROUP"): + print "GROUP ( libpthread.so.0 libpthread_nonshared.a )" + else: + print line + + bad_libc = os.path.join(target_dir, "lib", "libc.so") + for line in fileinput.input(bad_libc, inplace=True): + if line.startswith("GROUP"): + print ("GROUP ( libc.so.6 libc_nonshared.a " + "AS_NEEDED ( ld-linux-armhf.so.3 ) )") + else: + print line + + +def main(): + if 'linux' not in sys.platform: + print >> sys.stderr, 'This script only runs on Linux.' + sys.exit(1) + parser = argparse.ArgumentParser() + parser.add_argument('--target_dir', '-t', required=True) + args = parser.parse_args() + create_asset(args.target_dir) + + +if __name__ == '__main__': + main() diff --git a/infra/bots/assets/armhf_sysroot/create_and_upload.py b/infra/bots/assets/armhf_sysroot/create_and_upload.py new file mode 100755 index 0000000000..b9e6d6f669 --- /dev/null +++ b/infra/bots/assets/armhf_sysroot/create_and_upload.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Create the asset and upload it.""" + + +import argparse +import common +import os +import subprocess +import sys +import utils + + +def main(): + if 'linux' not in sys.platform: + print >> sys.stderr, 'This script only runs on Linux.' + sys.exit(1) + parser = argparse.ArgumentParser() + parser.add_argument('--gsutil') + args = parser.parse_args() + + with utils.tmp_dir(): + cwd = os.getcwd() + create_script = os.path.join(common.FILE_DIR, 'create.py') + upload_script = os.path.join(common.FILE_DIR, 'upload.py') + + try: + cwd = os.path.join(cwd, 'sysroot') + subprocess.check_call(['python', create_script, '-t', cwd]) + cmd = ['python', upload_script, '-t', cwd] + if args.gsutil: + cmd.extend(['--gsutil', args.gsutil]) + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + # Trap exceptions to avoid printing two stacktraces. + sys.exit(1) + + +if __name__ == '__main__': + main() diff --git a/infra/bots/assets/armhf_sysroot/download.py b/infra/bots/assets/armhf_sysroot/download.py new file mode 100755 index 0000000000..96cc87d43f --- /dev/null +++ b/infra/bots/assets/armhf_sysroot/download.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Download the current version of the asset.""" + + +import common + + +if __name__ == '__main__': + common.run('download') diff --git a/infra/bots/assets/armhf_sysroot/upload.py b/infra/bots/assets/armhf_sysroot/upload.py new file mode 100755 index 0000000000..ba7fc8b6a1 --- /dev/null +++ b/infra/bots/assets/armhf_sysroot/upload.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Upload a new version of the asset.""" + + +import common + + +if __name__ == '__main__': + common.run('upload') |