Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
create.py
Go to the documentation of this file.
1#!/usr/bin/env python
2#
3# Copyright 2016 Google Inc.
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8
9"""Create the asset."""
10
11
12from __future__ import print_function
13import argparse
14import fileinput
15import os
16import shutil
17import subprocess
18import sys
19
20
21def create_asset(target_dir):
22 """Create the asset."""
23
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"
30 ])
31
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'))
37
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'))
45
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
50 # writes to the file.
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 ) )")
56 else:
57 print(line)
58
59
60def main():
61 if 'linux' not in sys.platform:
62 print('This script only runs on Linux.', file=sys.stderr)
63 sys.exit(1)
64 parser = argparse.ArgumentParser()
65 parser.add_argument('--target_dir', '-t', required=True)
66 args = parser.parse_args()
67 create_asset(args.target_dir)
68
69
70if __name__ == '__main__':
71 main()
void print(void *str)
Definition bridge.cpp:126
Definition main.py:1