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

Side by Side Diff: tools/build.py

Issue 23788009: Allows build of the standalone VM for ARM adroid. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 7
8 import optparse 8 import optparse
9 import os 9 import os
10 import re 10 import re
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 print "Unknown os %s" % os 94 print "Unknown os %s" % os
95 return False 95 return False
96 if os != HOST_OS: 96 if os != HOST_OS:
97 if os != 'android': 97 if os != 'android':
98 print "Unsupported target os %s" % os 98 print "Unsupported target os %s" % os
99 return False 99 return False
100 if not HOST_OS in ['linux']: 100 if not HOST_OS in ['linux']:
101 print ("Cross-compilation to %s is not supported on host os %s." 101 print ("Cross-compilation to %s is not supported on host os %s."
102 % (os, HOST_OS)) 102 % (os, HOST_OS))
103 return False 103 return False
104 if not arch in ['ia32']: 104 if not arch in ['ia32', 'arm']:
105 print ("Cross-compilation to %s is not supported for architecture %s." 105 print ("Cross-compilation to %s is not supported for architecture %s."
106 % (os, arch)) 106 % (os, arch))
107 return False 107 return False
108 # We have not yet tweaked the v8 dart build to work with the Android 108 # We have not yet tweaked the v8 dart build to work with the Android
109 # NDK/SDK, so don't try to build it. 109 # NDK/SDK, so don't try to build it.
110 if args == []: 110 if args == []:
111 print "For android builds you must specify a target, such as 'samples'." 111 print "For android builds you must specify a target, such as 'samples'."
112 return False 112 return False
113 if 'v8' in args: 113 if 'v8' in args:
114 print "The v8 target is not supported for android builds." 114 print "The v8 target is not supported for android builds."
(...skipping 22 matching lines...) Expand all
137 raise Exception('Could not find %s directory %s' 137 raise Exception('Could not find %s directory %s'
138 % (docstring, path)) 138 % (docstring, path))
139 139
140 140
141 def SetCrossCompilationEnvironment(host_os, target_os, target_arch, old_path): 141 def SetCrossCompilationEnvironment(host_os, target_os, target_arch, old_path):
142 global THIRD_PARTY_ROOT 142 global THIRD_PARTY_ROOT
143 if host_os not in ['linux']: 143 if host_os not in ['linux']:
144 raise Exception('Unsupported host os %s' % host_os) 144 raise Exception('Unsupported host os %s' % host_os)
145 if target_os not in ['android']: 145 if target_os not in ['android']:
146 raise Exception('Unsupported target os %s' % target_os) 146 raise Exception('Unsupported target os %s' % target_os)
147 if target_arch not in ['ia32']: 147 if target_arch not in ['ia32', 'arm']:
148 raise Exception('Unsupported target architecture %s' % target_arch) 148 raise Exception('Unsupported target architecture %s' % target_arch)
149 149
150 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools'); 150 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools');
151 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') 151 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools')
152 CheckDirExists(android_tools, 'Android tools') 152 CheckDirExists(android_tools, 'Android tools')
153 android_ndk_root = os.path.join(android_tools, 'ndk') 153 android_ndk_root = os.path.join(android_tools, 'ndk')
154 CheckDirExists(android_ndk_root, 'Android NDK') 154 CheckDirExists(android_ndk_root, 'Android NDK')
155 android_sdk_root = os.path.join(android_tools, 'sdk') 155 android_sdk_root = os.path.join(android_tools, 'sdk')
156 CheckDirExists(android_sdk_root, 'Android SDK') 156 CheckDirExists(android_sdk_root, 'Android SDK')
157 157
158 os.environ['ANDROID_NDK_ROOT'] = android_ndk_root 158 os.environ['ANDROID_NDK_ROOT'] = android_ndk_root
159 os.environ['ANDROID_SDK_ROOT'] = android_sdk_root 159 os.environ['ANDROID_SDK_ROOT'] = android_sdk_root
160 160
161 toolchain_arch = 'x86-4.4.3' 161 if target_arch == 'arm':
162 toolchain_arch = 'arm-linux-androideabi-4.6'
163 else:
164 toolchain_arch = 'x86-4.4.3'
162 toolchain_dir = 'linux-x86' 165 toolchain_dir = 'linux-x86'
163 android_toolchain = os.path.join(android_ndk_root, 166 android_toolchain = os.path.join(android_ndk_root,
164 'toolchains', toolchain_arch, 167 'toolchains', toolchain_arch,
165 'prebuilt', toolchain_dir, 'bin') 168 'prebuilt', toolchain_dir, 'bin')
166 CheckDirExists(android_toolchain, 'Android toolchain') 169 CheckDirExists(android_toolchain, 'Android toolchain')
167 170
168 os.environ['ANDROID_TOOLCHAIN'] = android_toolchain 171 os.environ['ANDROID_TOOLCHAIN'] = android_toolchain
169 172
170 android_sdk_version = 15 173 android_sdk_version = 15
171 174
172 android_sdk_tools = os.path.join(android_sdk_root, 'tools') 175 android_sdk_tools = os.path.join(android_sdk_root, 'tools')
173 CheckDirExists(android_sdk_tools, 'Android SDK tools') 176 CheckDirExists(android_sdk_tools, 'Android SDK tools')
174 177
175 android_sdk_platform_tools = os.path.join(android_sdk_root, 'platform-tools') 178 android_sdk_platform_tools = os.path.join(android_sdk_root, 'platform-tools')
176 CheckDirExists(android_sdk_platform_tools, 'Android SDK platform tools') 179 CheckDirExists(android_sdk_platform_tools, 'Android SDK platform tools')
177 180
178 pathList = [old_path, 181 pathList = [old_path,
179 android_ndk_root, 182 android_ndk_root,
180 android_sdk_tools, 183 android_sdk_tools,
181 android_sdk_platform_tools, 184 android_sdk_platform_tools,
182 # for Ninja - maybe don't need? 185 # for Ninja - maybe don't need?
183 android_toolchain 186 android_toolchain
184 ] 187 ]
185 os.environ['PATH'] = ':'.join(pathList) 188 os.environ['PATH'] = ':'.join(pathList)
186 189
190 android_target_arch = target_arch
191 if target_arch == 'ia32':
192 android_target_arch = 'x86'
193
187 gypDefinesList = [ 194 gypDefinesList = [
188 'target_arch=ia32', 195 'target_arch=%s' % target_arch,
196 'android_target_arch=%s' % android_target_arch,
189 'OS=%s' % target_os, 197 'OS=%s' % target_os,
190 'android_build_type=0', 198 'android_build_type=0',
191 'host_os=%s' % host_os, 199 'host_os=%s' % host_os,
192 'linux_fpic=1', 200 'linux_fpic=1',
193 'release_optimize=s', 201 'release_optimize=s',
194 'linux_use_tcmalloc=0', 202 'linux_use_tcmalloc=0',
195 'android_sdk=%s', os.path.join(android_sdk_root, 'platforms', 203 'android_sdk=%s', os.path.join(android_sdk_root, 'platforms',
196 'android-%d' % android_sdk_version), 204 'android-%d' % android_sdk_version),
197 'android_sdk_tools=%s' % android_sdk_platform_tools 205 'android_sdk_tools=%s' % android_sdk_platform_tools
198 ] 206 ]
199 207
200 os.environ['GYP_DEFINES'] = ' '.join(gypDefinesList) 208 os.environ['GYP_DEFINES'] = ' '.join(gypDefinesList)
201 209
202 210
203 def Execute(args): 211 def Execute(args):
204 process = subprocess.Popen(args) 212 process = subprocess.Popen(args)
205 process.wait() 213 process.wait()
206 if process.returncode != 0: 214 if process.returncode != 0:
207 raise Exception(args[0] + " failed") 215 raise Exception(args[0] + " failed")
208 216
209 217
210 def GClientRunHooks(): 218 def GClientRunHooks():
211 Execute(['gclient', 'runhooks']) 219 Execute(['gclient', 'runhooks'])
212 220
213 221
214 def RunhooksIfNeeded(host_os, mode, arch, target_os): 222 def RunhooksIfNeeded(host_os, mode, target_arch, target_os):
215 if host_os != 'linux': 223 if host_os != 'linux':
216 return 224 return
217 build_root = utils.GetBuildRoot(host_os) 225 build_root = utils.GetBuildRoot(host_os)
218 build_cookie_path = os.path.join(build_root, 'lastHooksTargetOS.txt') 226 build_cookie_path = os.path.join(build_root, 'lastHooksTargetOS.txt')
219 227
220 old_target_os = None 228 old_target_os = None
229 old_target_arch = None
221 try: 230 try:
222 with open(build_cookie_path) as f: 231 with open(build_cookie_path) as f:
223 old_target_os = f.read(1024) 232 lines = f.readlines()
233 old_target_os = lines[0]
234 old_target_arch = lines[1]
224 except IOError as e: 235 except IOError as e:
225 pass 236 pass
226 if target_os != old_target_os: 237 if (target_os != old_target_os) or (target_arch != old_target_arch):
227 try: 238 try:
228 os.mkdir(build_root) 239 os.mkdir(build_root)
229 except OSError as e: 240 except OSError as e:
230 pass 241 pass
231 with open(build_cookie_path, 'w') as f: 242 with open(build_cookie_path, 'w') as f:
232 f.write(target_os) 243 f.write(target_os + '\n')
244 f.write(target_arch + '\n')
233 GClientRunHooks() 245 GClientRunHooks()
234 246
235 247
236 def CurrentDirectoryBaseName(): 248 def CurrentDirectoryBaseName():
237 """Returns the name of the current directory""" 249 """Returns the name of the current directory"""
238 return os.path.relpath(os.curdir, start=os.pardir) 250 return os.path.relpath(os.curdir, start=os.pardir)
239 251
240 252
241 def FilterEmptyXcodebuildSections(process): 253 def FilterEmptyXcodebuildSections(process):
242 """ 254 """
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 422
411 args += [target] 423 args += [target]
412 424
413 if target_os != HOST_OS: 425 if target_os != HOST_OS:
414 SetCrossCompilationEnvironment( 426 SetCrossCompilationEnvironment(
415 HOST_OS, target_os, arch, old_path) 427 HOST_OS, target_os, arch, old_path)
416 428
417 RunhooksIfNeeded(HOST_OS, mode, arch, target_os) 429 RunhooksIfNeeded(HOST_OS, mode, arch, target_os)
418 430
419 toolchainprefix = None 431 toolchainprefix = None
420 if target_os == 'android': 432 if target_os == 'android' and arch == 'ia32':
421 toolchainprefix = ('%s/i686-linux-android' 433 toolchainprefix = ('%s/i686-linux-android'
422 % os.environ['ANDROID_TOOLCHAIN']) 434 % os.environ['ANDROID_TOOLCHAIN'])
435 elif target_os == 'android' and arch == 'arm':
436 toolchainprefix = ('%s/arm-linux-androideabi'
437 % os.environ['ANDROID_TOOLCHAIN'])
423 toolsOverride = SetTools(arch, toolchainprefix) 438 toolsOverride = SetTools(arch, toolchainprefix)
424 if toolsOverride: 439 if toolsOverride:
425 printToolOverrides = target_os != 'android' 440 printToolOverrides = target_os != 'android'
426 for k, v in toolsOverride.iteritems(): 441 for k, v in toolsOverride.iteritems():
427 args.append( k + "=" + v) 442 args.append( k + "=" + v)
428 if printToolOverrides: 443 if printToolOverrides:
429 print k + " = " + v 444 print k + " = " + v
430 if not os.path.isfile(toolsOverride['CC.target']): 445 if not os.path.isfile(toolsOverride['CC.target']):
431 if arch == 'arm': 446 if arch == 'arm':
432 print arm_cc_error 447 print arm_cc_error
(...skipping 16 matching lines...) Expand all
449 process.wait() 464 process.wait()
450 if process.returncode != 0: 465 if process.returncode != 0:
451 print "BUILD FAILED" 466 print "BUILD FAILED"
452 return 1 467 return 1
453 468
454 return 0 469 return 0
455 470
456 471
457 if __name__ == '__main__': 472 if __name__ == '__main__':
458 sys.exit(Main()) 473 sys.exit(Main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698