3 # Copyright 2016 Google Inc.
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
9 """Create the asset."""
12 from __future__ import print_function
21 def create_asset(target_dir):
22 """Create the asset."""
24 print("Installing some cross-compiling packages. You may be asked for your sudo password")
25 subprocess.check_call([
26 "sudo","apt-get","install",
27 "libstdc++-10-dev-armhf-cross",
28 "libgcc-10-dev-armhf-cross",
29 "binutils-arm-linux-gnueabihf"
32 # shutil complains if the target directory exists already.
33 shutil.rmtree(target_dir)
34 shutil.copytree('/usr/arm-linux-gnueabihf', target_dir)
35 shutil.copytree('/usr/lib/gcc-cross/arm-linux-gnueabihf/10',
36 os.path.join(target_dir, 'gcc-cross'))
38 # Libs needed to link. These were found by trial-and-error.
39 shutil.copy('/usr/lib/x86_64-linux-gnu/libbfd-2.37-armhf.so',
40 os.path.join(target_dir, 'lib'))
41 shutil.copy('/usr/lib/x86_64-linux-gnu/libopcodes-2.37-armhf.so',
42 os.path.join(target_dir, 'lib'))
43 shutil.copy('/usr/lib/x86_64-linux-gnu/libctf-armhf.so.0',
44 os.path.join(target_dir, 'lib'))
46 # The file paths in libc.so start off as absolute file
47 # paths (e.g. /usr/arm-linux-gnueabihf/lib/libpthread.so.0), which won't
48 # work on the bots. We use fileinput to replace just those lines (which
49 # start with GROUP). fileinput redirects stdout, so printing here actually
51 bad_libc = os.path.join(target_dir, "lib", "libc.so")
52 for line in fileinput.input(bad_libc, inplace=True):
53 if line.startswith("GROUP"):
54 print("GROUP ( libc.so.6 libc_nonshared.a "
55 "AS_NEEDED ( ld-linux-armhf.so.3 ) )")
61 if 'linux' not in sys.platform:
62 print('This script only runs on Linux.', file=sys.stderr)
64 parser = argparse.ArgumentParser()
65 parser.add_argument('--target_dir', '-t', required=True)
66 args = parser.parse_args()
67 create_asset(args.target_dir)
70 if __name__ == '__main__':