OLD | NEW |
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if target_arch == 'arm64': | 101 if target_arch == 'arm64': |
102 android_gcc = os.path.join(android_toolchain, 'aarch64-linux-android-gcc') | 102 android_gcc = os.path.join(android_toolchain, 'aarch64-linux-android-gcc') |
103 if target_arch == 'ia32': | 103 if target_arch == 'ia32': |
104 android_gcc = os.path.join(android_toolchain, 'i686-linux-android-gcc') | 104 android_gcc = os.path.join(android_toolchain, 'i686-linux-android-gcc') |
105 android_libgcc = subprocess.check_output( | 105 android_libgcc = subprocess.check_output( |
106 [android_gcc, '-print-libgcc-file-name']).strip() | 106 [android_gcc, '-print-libgcc-file-name']).strip() |
107 | 107 |
108 # Set up the path to the system root directory, which is where we'll find the | 108 # Set up the path to the system root directory, which is where we'll find the |
109 # Android specific system includes and libraries. | 109 # Android specific system includes and libraries. |
110 android_ndk_sysroot = os.path.join(android_ndk_root, | 110 android_ndk_sysroot = os.path.join(android_ndk_root, |
111 'platforms', 'android-L', 'arch-arm') | 111 'platforms', 'android-14', 'arch-arm') |
112 if target_arch == 'arm64': | 112 if target_arch == 'arm64': |
113 android_ndk_sysroot = os.path.join(android_ndk_root, | 113 android_ndk_sysroot = os.path.join(android_ndk_root, |
114 'platforms', 'android-L', 'arch-arm64') | 114 'platforms', 'android-21', 'arch-arm64') |
115 if target_arch == 'ia32': | 115 if target_arch == 'ia32': |
116 android_ndk_sysroot = os.path.join(android_ndk_root, | 116 android_ndk_sysroot = os.path.join(android_ndk_root, |
117 'platforms', 'android-L', 'arch-x86') | 117 'platforms', 'android-14', 'arch-x86') |
118 CheckDirExists(android_ndk_sysroot, 'Android sysroot') | 118 CheckDirExists(android_ndk_sysroot, 'Android sysroot') |
119 android_ndk_lib = os.path.join(android_ndk_sysroot,'usr','lib') | 119 android_ndk_lib = os.path.join(android_ndk_sysroot,'usr','lib') |
120 android_ndk_include = os.path.join(android_ndk_sysroot, 'usr', 'include') | |
121 crtend_android = os.path.join(android_ndk_lib, 'crtend_android.o') | 120 crtend_android = os.path.join(android_ndk_lib, 'crtend_android.o') |
122 | 121 |
123 if link_target == 'target': | 122 if link_target == 'target': |
124 # Add and remove libraries as listed in configurations_android.gypi | 123 # Add and remove libraries as listed in configurations_android.gypi |
125 libs_to_rm = ['-lrt', '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', | 124 libs_to_rm = ['-lrt', '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', |
126 '-lplds4', '-lplc4', '-lnspr4',] | 125 '-lplds4', '-lplc4', '-lnspr4',] |
127 libs_to_add = ['-lstlport_static', android_libgcc, '-lc', '-ldl', | 126 libs_to_add = ['-lstlport_static', android_libgcc, '-lc', '-ldl', |
128 '-lstdc++', '-lm',] | 127 '-lstdc++', '-lm',] |
129 | 128 |
130 # Add crtend_android to end if we are linking an executable. | 129 # Add crtend_android to end if we are linking an executable. |
131 if link_type == 'executable': | 130 if link_type == 'executable': |
132 libs_to_add.extend(['-llog', '-lz', crtend_android]) | 131 libs_to_add.extend(['-llog', '-lz', crtend_android]) |
133 | 132 |
134 link_args = [i for i in link_args if i not in libs_to_rm] | 133 link_args = [i for i in link_args if i not in libs_to_rm] |
135 link_args.extend(libs_to_add) | 134 link_args.extend(libs_to_add) |
136 | 135 |
137 link_args.insert(0, android_linker) | 136 link_args.insert(0, android_linker) |
138 else: | 137 else: |
139 link_args.extend(['-ldl', '-lrt']) | 138 link_args.extend(['-ldl', '-lrt']) |
140 link_args.insert(0, 'g++') | 139 link_args.insert(0, 'g++') |
141 | 140 |
142 sys.exit(execute(link_args)) | 141 sys.exit(execute(link_args)) |
143 | 142 |
144 if __name__ == '__main__': | 143 if __name__ == '__main__': |
145 main() | 144 main() |
OLD | NEW |