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

Side by Side Diff: tools/android_link.py

Issue 539573003: Adds support for building arm64 Android. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/signal_handler_android.cc ('k') | tools/build.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,ia32} {executable,library,shared_library} {host,target} 10 ./android_link {arm,arm64,ia32} {executable,library,shared_library}
11 [linker args] 11 {host,target} [linker args]
12 """ 12 """
13 13
14 import os 14 import os
15 import subprocess 15 import subprocess
16 import sys 16 import sys
17 17
18 # Figure out where we are. 18 # Figure out where we are.
19 SCRIPT_DIR = os.path.dirname(sys.argv[0]) 19 SCRIPT_DIR = os.path.dirname(sys.argv[0])
20 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) 20 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
21 THIRD_PARTY_ROOT = os.path.join(DART_ROOT, 'third_party') 21 THIRD_PARTY_ROOT = os.path.join(DART_ROOT, 'third_party')
(...skipping 19 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', 'ia32']: 51 if target_arch not in ['arm', 'arm64', 'ia32']:
52 raise Exception(sys.argv[0] + " first argument must be 'arm' or 'ia32'") 52 raise Exception(sys.argv[0] +
53 " first argument must be 'arm', 'arm64', or 'ia32'")
53 if link_type not in ['executable', 'library', 'shared_library']: 54 if link_type not in ['executable', 'library', 'shared_library']:
54 raise Exception(sys.argv[0] + 55 raise Exception(sys.argv[0] +
55 " second argument must be 'executable' or 'library'") 56 " second argument must be 'executable' or 'library'")
56 if link_target not in ['host', 'target']: 57 if link_target not in ['host', 'target']:
57 raise Exception(sys.argv[0] + " third argument must be 'host' or 'target'") 58 raise Exception(sys.argv[0] + " third argument must be 'host' or 'target'")
58 59
59 # TODO(zra): Figure out how to link a shared library with the NDK 60 # TODO(zra): Figure out how to link a shared library with the NDK
60 # cross-compilers. For now, we disable it by generating empty files 61 # cross-compilers. For now, we disable it by generating empty files
61 # for the results. We disable it here to avoid inspecting the OS type in 62 # for the results. We disable it here to avoid inspecting the OS type in
62 # the gyp files. 63 # the gyp files.
63 if link_type == 'shared_library': 64 if link_type == 'shared_library':
64 print "NOT linking shared library for Android." 65 print "NOT linking shared library for Android."
65 o_index = link_args.index('-o') 66 o_index = link_args.index('-o')
66 output = os.path.join(DART_ROOT, link_args[o_index + 1]) 67 output = os.path.join(DART_ROOT, link_args[o_index + 1])
67 open(output, 'a').close() 68 open(output, 'a').close()
68 sys.exit(0) 69 sys.exit(0)
69 70
70 # Set up path to the Android NDK. 71 # Set up path to the Android NDK.
71 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') 72 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools')
72 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') 73 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools')
73 CheckDirExists(android_tools, 'Android tools') 74 CheckDirExists(android_tools, 'Android tools')
74 android_ndk_root = os.path.join(android_tools, 'ndk') 75 android_ndk_root = os.path.join(android_tools, 'ndk')
75 CheckDirExists(android_ndk_root, 'Android NDK') 76 CheckDirExists(android_ndk_root, 'Android NDK')
76 77
77 # Set up the directory of the Android NDK cross-compiler toolchain. 78 # Set up the directory of the Android NDK cross-compiler toolchain.
78 toolchain_arch = 'arm-linux-androideabi-4.6' 79 toolchain_arch = 'arm-linux-androideabi-4.6'
80 if target_arch == 'arm64':
81 toolchain_arch = 'aarch64-linux-android-4.9'
79 if target_arch == 'ia32': 82 if target_arch == 'ia32':
80 toolchain_arch = 'x86-4.6' 83 toolchain_arch = 'x86-4.6'
81 toolchain_dir = 'linux-x86_64' 84 toolchain_dir = 'linux-x86_64'
82 android_toolchain = os.path.join(android_ndk_root, 85 android_toolchain = os.path.join(android_ndk_root,
83 'toolchains', toolchain_arch, 86 'toolchains', toolchain_arch,
84 'prebuilt', toolchain_dir, 'bin') 87 'prebuilt', toolchain_dir, 'bin')
85 CheckDirExists(android_toolchain, 'Android toolchain') 88 CheckDirExists(android_toolchain, 'Android toolchain')
86 89
87 # Set up the path to the linker executable. 90 # Set up the path to the linker executable.
88 android_linker = os.path.join(android_toolchain, 'arm-linux-androideabi-g++') 91 android_linker = os.path.join(android_toolchain, 'arm-linux-androideabi-g++')
92 if target_arch == 'arm64':
93 android_linker = os.path.join(
94 android_toolchain, 'aarch64-linux-android-c++')
89 if target_arch == 'ia32': 95 if target_arch == 'ia32':
90 android_linker = os.path.join(android_toolchain, 'i686-linux-android-g++') 96 android_linker = os.path.join(android_toolchain, 'i686-linux-android-g++')
91 97
92 # Grab the path to libgcc.a, which we must explicitly add to the link, 98 # Grab the path to libgcc.a, which we must explicitly add to the link,
93 # by invoking the cross-compiler with the -print-libgcc-file-name flag. 99 # by invoking the cross-compiler with the -print-libgcc-file-name flag.
94 android_gcc = os.path.join(android_toolchain, 'arm-linux-androideabi-gcc') 100 android_gcc = os.path.join(android_toolchain, 'arm-linux-androideabi-gcc')
101 if target_arch == 'arm64':
102 android_gcc = os.path.join(android_toolchain, 'aarch64-linux-android-gcc')
95 if target_arch == 'ia32': 103 if target_arch == 'ia32':
96 android_gcc = os.path.join(android_toolchain, 'i686-linux-android-gcc') 104 android_gcc = os.path.join(android_toolchain, 'i686-linux-android-gcc')
97 android_libgcc = subprocess.check_output( 105 android_libgcc = subprocess.check_output(
98 [android_gcc, '-print-libgcc-file-name']).strip() 106 [android_gcc, '-print-libgcc-file-name']).strip()
99 107
100 # 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
101 # Android specific system includes and libraries. 109 # Android specific system includes and libraries.
102 android_ndk_sysroot = os.path.join(android_ndk_root, 110 android_ndk_sysroot = os.path.join(android_ndk_root,
103 'platforms', 'android-14', 'arch-arm') 111 'platforms', 'android-14', 'arch-arm')
112 if target_arch == 'arm64':
113 android_ndk_sysroot = os.path.join(android_ndk_root,
114 'platforms', 'android-L', 'arch-arm64')
104 if target_arch == 'ia32': 115 if target_arch == 'ia32':
105 android_ndk_sysroot = os.path.join(android_ndk_root, 116 android_ndk_sysroot = os.path.join(android_ndk_root,
106 'platforms', 'android-14', 'arch-x86') 117 'platforms', 'android-14', 'arch-x86')
107 CheckDirExists(android_ndk_sysroot, 'Android sysroot') 118 CheckDirExists(android_ndk_sysroot, 'Android sysroot')
108 android_ndk_lib = os.path.join(android_ndk_sysroot,'usr','lib') 119 android_ndk_lib = os.path.join(android_ndk_sysroot,'usr','lib')
109 android_ndk_include = os.path.join(android_ndk_sysroot, 'usr', 'include') 120 android_ndk_include = os.path.join(android_ndk_sysroot, 'usr', 'include')
110 crtend_android = os.path.join(android_ndk_lib, 'crtend_android.o') 121 crtend_android = os.path.join(android_ndk_lib, 'crtend_android.o')
111 122
112 if link_target == 'target': 123 if link_target == 'target':
113 # Add and remove libraries as listed in configurations_android.gypi 124 # Add and remove libraries as listed in configurations_android.gypi
(...skipping 11 matching lines...) Expand all
125 136
126 link_args.insert(0, android_linker) 137 link_args.insert(0, android_linker)
127 else: 138 else:
128 link_args.extend(['-ldl', '-lrt']) 139 link_args.extend(['-ldl', '-lrt'])
129 link_args.insert(0, 'g++') 140 link_args.insert(0, 'g++')
130 141
131 sys.exit(execute(link_args)) 142 sys.exit(execute(link_args))
132 143
133 if __name__ == '__main__': 144 if __name__ == '__main__':
134 main() 145 main()
OLDNEW
« no previous file with comments | « runtime/vm/signal_handler_android.cc ('k') | tools/build.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698