Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: tools/android_link.py

Issue 1904153003: DBC: Adds simdbc64 target, adds arm64 arithmetic overflow logic (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix stack overflow area size Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 The Dart Authors. All rights reserved. 3 # Copyright (c) 2012 The Dart Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """ 7 """
8 This script performs the final link step for Android NDK executables. 8 This script performs the final link step for Android NDK executables.
9 Usage: 9 Usage:
10 ./android_link {arm,arm64,ia32} {executable,library,shared_library} 10 ./android_link {arm,arm64,ia32} {executable,library,shared_library}
(...skipping 30 matching lines...) Expand all
41 if sys.argv[1] == '-shared': 41 if sys.argv[1] == '-shared':
42 sys.argv.remove('-shared') 42 sys.argv.remove('-shared')
43 43
44 # Grab the command line arguments. 44 # Grab the command line arguments.
45 target_arch = sys.argv[1] 45 target_arch = sys.argv[1]
46 link_type = sys.argv[2] 46 link_type = sys.argv[2]
47 link_target = sys.argv[3] 47 link_target = sys.argv[3]
48 link_args = sys.argv[4:] 48 link_args = sys.argv[4:]
49 49
50 # Check arguments. 50 # Check arguments.
51 if target_arch not in ['arm', 'arm64', 'ia32', 'x64']: 51 if target_arch not in ['arm', 'arm64', 'ia32', 'x64', 'simdbc', 'simdbc64']:
52 raise Exception(sys.argv[0] + 52 raise Exception(sys.argv[0] +
53 " first argument must be 'arm', 'arm64', 'ia32', or 'x64'") 53 " first argument must be 'arm', 'arm64', 'ia32', 'x64', "
54 "'simdbc', or 'simdbc64'")
54 if link_type not in ['executable', 'library', 'shared_library']: 55 if link_type not in ['executable', 'library', 'shared_library']:
55 raise Exception(sys.argv[0] + 56 raise Exception(sys.argv[0] +
56 " second argument must be 'executable' or 'library'") 57 " second argument must be 'executable' or 'library'")
57 if link_target not in ['host', 'target']: 58 if link_target not in ['host', 'target']:
58 raise Exception(sys.argv[0] + " third argument must be 'host' or 'target'") 59 raise Exception(sys.argv[0] + " third argument must be 'host' or 'target'")
59 60
60 # TODO(zra): Figure out how to link a shared library with the NDK 61 # TODO(zra): Figure out how to link a shared library with the NDK
61 # cross-compilers. For now, we disable it by generating empty files 62 # cross-compilers. For now, we disable it by generating empty files
62 # for the results. We disable it here to avoid inspecting the OS type in 63 # for the results. We disable it here to avoid inspecting the OS type in
63 # the gyp files. 64 # the gyp files.
64 if link_type == 'shared_library': 65 if link_type == 'shared_library':
65 print "NOT linking shared library for Android." 66 print "NOT linking shared library for Android."
66 o_index = link_args.index('-o') 67 o_index = link_args.index('-o')
67 output = os.path.join(DART_ROOT, link_args[o_index + 1]) 68 output = os.path.join(DART_ROOT, link_args[o_index + 1])
68 open(output, 'a').close() 69 open(output, 'a').close()
69 sys.exit(0) 70 sys.exit(0)
70 71
71 # Set up path to the Android NDK. 72 # Set up path to the Android NDK.
72 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') 73 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools')
73 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') 74 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools')
74 CheckDirExists(android_tools, 'Android tools') 75 CheckDirExists(android_tools, 'Android tools')
75 android_ndk_root = os.path.join(android_tools, 'ndk') 76 android_ndk_root = os.path.join(android_tools, 'ndk')
76 CheckDirExists(android_ndk_root, 'Android NDK') 77 CheckDirExists(android_ndk_root, 'Android NDK')
77 78
78 # Set up the directory of the Android NDK cross-compiler toolchain. 79 # Set up the directory of the Android NDK cross-compiler toolchain.
79 toolchain_arch = 'arm-linux-androideabi-4.9' 80 toolchain_arch = 'arm-linux-androideabi-4.9'
80 if target_arch == 'arm64': 81 if target_arch == 'arm64' or target_arch == "simdbc64":
81 toolchain_arch = 'aarch64-linux-android-4.9' 82 toolchain_arch = 'aarch64-linux-android-4.9'
82 if target_arch == 'ia32': 83 if target_arch == 'ia32':
83 toolchain_arch = 'x86-4.9' 84 toolchain_arch = 'x86-4.9'
84 if target_arch == 'x64': 85 if target_arch == 'x64':
85 toolchain_arch = 'x86_64-4.9' 86 toolchain_arch = 'x86_64-4.9'
86 toolchain_dir = 'linux-x86_64' 87 toolchain_dir = 'linux-x86_64'
87 android_toolchain = os.path.join(android_ndk_root, 88 android_toolchain = os.path.join(android_ndk_root,
88 'toolchains', toolchain_arch, 89 'toolchains', toolchain_arch,
89 'prebuilt', toolchain_dir, 'bin') 90 'prebuilt', toolchain_dir, 'bin')
90 CheckDirExists(android_toolchain, 'Android toolchain') 91 CheckDirExists(android_toolchain, 'Android toolchain')
91 92
92 # Set up the path to the linker executable. 93 # Set up the path to the linker executable.
93 android_linker = os.path.join(android_toolchain, 'arm-linux-androideabi-g++') 94 android_linker = os.path.join(android_toolchain, 'arm-linux-androideabi-g++')
94 if target_arch == 'arm64': 95 if target_arch == 'arm64' or target_arch == "simdbc64":
95 android_linker = os.path.join( 96 android_linker = os.path.join(
96 android_toolchain, 'aarch64-linux-android-c++') 97 android_toolchain, 'aarch64-linux-android-c++')
97 if target_arch == 'ia32': 98 if target_arch == 'ia32':
98 android_linker = os.path.join(android_toolchain, 'i686-linux-android-g++') 99 android_linker = os.path.join(android_toolchain, 'i686-linux-android-g++')
99 if target_arch == 'x64': 100 if target_arch == 'x64':
100 android_linker = os.path.join(android_toolchain, 'x86_64-linux-android-g++') 101 android_linker = os.path.join(android_toolchain, 'x86_64-linux-android-g++')
101 102
102 # Grab the path to libgcc.a, which we must explicitly add to the link, 103 # Grab the path to libgcc.a, which we must explicitly add to the link,
103 # by invoking the cross-compiler with the -print-libgcc-file-name flag. 104 # by invoking the cross-compiler with the -print-libgcc-file-name flag.
104 android_gcc = os.path.join(android_toolchain, 'arm-linux-androideabi-gcc') 105 android_gcc = os.path.join(android_toolchain, 'arm-linux-androideabi-gcc')
105 if target_arch == 'arm64': 106 if target_arch == 'arm64' or target_arch == "simdbc64":
106 android_gcc = os.path.join(android_toolchain, 'aarch64-linux-android-gcc') 107 android_gcc = os.path.join(android_toolchain, 'aarch64-linux-android-gcc')
107 if target_arch == 'ia32': 108 if target_arch == 'ia32':
108 android_gcc = os.path.join(android_toolchain, 'i686-linux-android-gcc') 109 android_gcc = os.path.join(android_toolchain, 'i686-linux-android-gcc')
109 if target_arch == 'x64': 110 if target_arch == 'x64':
110 android_gcc = os.path.join(android_toolchain, 'x86_64-linux-android-gcc') 111 android_gcc = os.path.join(android_toolchain, 'x86_64-linux-android-gcc')
111 android_libgcc = subprocess.check_output( 112 android_libgcc = subprocess.check_output(
112 [android_gcc, '-print-libgcc-file-name']).strip() 113 [android_gcc, '-print-libgcc-file-name']).strip()
113 114
114 # Set up the path to the system root directory, which is where we'll find the 115 # Set up the path to the system root directory, which is where we'll find the
115 # Android specific system includes and libraries. 116 # Android specific system includes and libraries.
116 android_ndk_sysroot = os.path.join(android_ndk_root, 117 android_ndk_sysroot = os.path.join(android_ndk_root,
117 'platforms', 'android-14', 'arch-arm') 118 'platforms', 'android-14', 'arch-arm')
118 libdir = 'lib' 119 libdir = 'lib'
119 if target_arch == 'arm64': 120 if target_arch == 'arm64' or target_arch == "simdbc64":
120 android_ndk_sysroot = os.path.join(android_ndk_root, 121 android_ndk_sysroot = os.path.join(android_ndk_root,
121 'platforms', 'android-21', 'arch-arm64') 122 'platforms', 'android-21', 'arch-arm64')
122 if target_arch == 'ia32': 123 if target_arch == 'ia32':
123 android_ndk_sysroot = os.path.join(android_ndk_root, 124 android_ndk_sysroot = os.path.join(android_ndk_root,
124 'platforms', 'android-14', 'arch-x86') 125 'platforms', 'android-14', 'arch-x86')
125 if target_arch == 'x64': 126 if target_arch == 'x64':
126 android_ndk_sysroot = os.path.join(android_ndk_root, 127 android_ndk_sysroot = os.path.join(android_ndk_root,
127 'platforms', 'android-21', 'arch-x86_64') 128 'platforms', 'android-21', 'arch-x86_64')
128 libdir = 'lib64' 129 libdir = 'lib64'
129 CheckDirExists(android_ndk_sysroot, 'Android sysroot') 130 CheckDirExists(android_ndk_sysroot, 'Android sysroot')
(...skipping 16 matching lines...) Expand all
146 147
147 link_args.insert(0, android_linker) 148 link_args.insert(0, android_linker)
148 else: 149 else:
149 link_args.extend(['-ldl', '-lrt']) 150 link_args.extend(['-ldl', '-lrt'])
150 link_args.insert(0, 'g++') 151 link_args.insert(0, 'g++')
151 152
152 sys.exit(execute(link_args)) 153 sys.exit(execute(link_args))
153 154
154 if __name__ == '__main__': 155 if __name__ == '__main__':
155 main() 156 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698