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

Side by Side Diff: tools/build.py

Issue 2117593002: Fuchsia: Initial check-in. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 5 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
« no previous file with comments | « runtime/vm/vm_sources.gypi ('k') | tools/fuchsia_link.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 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 result.add_option("-v", "--verbose", 53 result.add_option("-v", "--verbose",
54 help='Verbose output.', 54 help='Verbose output.',
55 default=False, action="store_true") 55 default=False, action="store_true")
56 result.add_option("-a", "--arch", 56 result.add_option("-a", "--arch",
57 help='Target architectures (comma-separated).', 57 help='Target architectures (comma-separated).',
58 metavar='[all,ia32,x64,simarm,arm,simarmv6,armv6,simarmv5te,armv5te,' 58 metavar='[all,ia32,x64,simarm,arm,simarmv6,armv6,simarmv5te,armv5te,'
59 'simmips,mips,simarm64,arm64,simdbc,armsimdbc]', 59 'simmips,mips,simarm64,arm64,simdbc,armsimdbc]',
60 default=utils.GuessArchitecture()) 60 default=utils.GuessArchitecture())
61 result.add_option("--os", 61 result.add_option("--os",
62 help='Target OSs (comma-separated).', 62 help='Target OSs (comma-separated).',
63 metavar='[all,host,android]', 63 metavar='[all,host,android,fuchsia]',
64 default='host') 64 default='host')
65 result.add_option("-t", "--toolchain", 65 result.add_option("-t", "--toolchain",
66 help='Cross-compiler toolchain path', 66 help='Cross-compiler toolchain path',
67 default=None) 67 default=None)
68 result.add_option("-j", 68 result.add_option("-j",
69 help='The number of parallel jobs to run.', 69 help='The number of parallel jobs to run.',
70 metavar=HOST_CPUS, 70 metavar=HOST_CPUS,
71 default=str(HOST_CPUS)) 71 default=str(HOST_CPUS))
72 (vs_directory, vs_executable) = utils.GuessVisualStudioPath() 72 (vs_directory, vs_executable) = utils.GuessVisualStudioPath()
73 result.add_option("--devenv", 73 result.add_option("--devenv",
(...skipping 28 matching lines...) Expand all
102 return False 102 return False
103 for arch in options.arch: 103 for arch in options.arch:
104 archs = ['ia32', 'x64', 'simarm', 'arm', 'simarmv6', 'armv6', 104 archs = ['ia32', 'x64', 'simarm', 'arm', 'simarmv6', 'armv6',
105 'simarmv5te', 'armv5te', 'simmips', 'mips', 'simarm64', 'arm64', 105 'simarmv5te', 'armv5te', 'simmips', 'mips', 'simarm64', 'arm64',
106 'simdbc', 'simdbc64', 'armsimdbc'] 106 'simdbc', 'simdbc64', 'armsimdbc']
107 if not arch in archs: 107 if not arch in archs:
108 print "Unknown arch %s" % arch 108 print "Unknown arch %s" % arch
109 return False 109 return False
110 options.os = [ProcessOsOption(os_name) for os_name in options.os] 110 options.os = [ProcessOsOption(os_name) for os_name in options.os]
111 for os_name in options.os: 111 for os_name in options.os:
112 if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']: 112 if not os_name in ['android', 'freebsd', 'fuchsia', 'linux', 'macos', 'win32 ']:
113 print "Unknown os %s" % os_name 113 print "Unknown os %s" % os_name
114 return False 114 return False
115 if os_name != HOST_OS: 115 if os_name != HOST_OS:
116 if os_name != 'android': 116 if os_name != 'android' and os_name != 'fuchsia':
117 print "Unsupported target os %s" % os_name 117 print "Unsupported target os %s" % os_name
118 return False 118 return False
119 if not HOST_OS in ['linux']: 119 if not HOST_OS in ['linux']:
120 print ("Cross-compilation to %s is not supported on host os %s." 120 print ("Cross-compilation to %s is not supported on host os %s."
121 % (os_name, HOST_OS)) 121 % (os_name, HOST_OS))
122 return False 122 return False
123 if not arch in ['ia32', 'x64', 'arm', 'armv6', 'armv5te', 'arm64', 'mips', 123 if not arch in ['ia32', 'x64', 'arm', 'armv6', 'armv5te', 'arm64', 'mips',
124 'simdbc', 'simdbc64']: 124 'simdbc', 'simdbc64']:
125 print ("Cross-compilation to %s is not supported for architecture %s." 125 print ("Cross-compilation to %s is not supported for architecture %s."
126 % (os_name, arch)) 126 % (os_name, arch))
(...skipping 14 matching lines...) Expand all
141 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) 141 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch)
142 if arch == 'arm' or arch == 'simdbc': 142 if arch == 'arm' or arch == 'simdbc':
143 return os.path.join(android_toolchain, 'arm-linux-androideabi') 143 return os.path.join(android_toolchain, 'arm-linux-androideabi')
144 if arch == 'arm64' or arch == 'simdbc64': 144 if arch == 'arm64' or arch == 'simdbc64':
145 return os.path.join(android_toolchain, 'aarch64-linux-android') 145 return os.path.join(android_toolchain, 'aarch64-linux-android')
146 if arch == 'ia32': 146 if arch == 'ia32':
147 return os.path.join(android_toolchain, 'i686-linux-android') 147 return os.path.join(android_toolchain, 'i686-linux-android')
148 if arch == 'x64': 148 if arch == 'x64':
149 return os.path.join(android_toolchain, 'x86_64-linux-android') 149 return os.path.join(android_toolchain, 'x86_64-linux-android')
150 150
151 if target_os == 'fuchsia':
152 fuchsia_toolchain = GetFuchsiaToolchainDir(HOST_OS, arch)
153 if arch == 'arm64':
154 return os.path.join(fuchsia_toolchain, 'aarch64-elf')
155 if arch == 'x64':
156 return os.path.join(fuchsia_toolchain, 'x86_64-elf')
157
151 # If no cross compiler is specified, only try to figure one out on Linux. 158 # If no cross compiler is specified, only try to figure one out on Linux.
152 if not HOST_OS in ['linux']: 159 if not HOST_OS in ['linux']:
153 raise Exception('Unless --toolchain is used cross-building is only ' 160 raise Exception('Unless --toolchain is used cross-building is only '
154 'supported on Linux.') 161 'supported on Linux.')
155 162
156 # For ARM Linux, by default use the Linux distribution's cross-compiler. 163 # For ARM Linux, by default use the Linux distribution's cross-compiler.
157 if arch == 'arm' or arch == 'armsimdbc': 164 if arch == 'arm' or arch == 'armsimdbc':
158 # To use a non-hf compiler, specify on the command line with --toolchain. 165 # To use a non-hf compiler, specify on the command line with --toolchain.
159 return (DEFAULT_ARM_CROSS_COMPILER_PATH + "/arm-linux-gnueabihf") 166 return (DEFAULT_ARM_CROSS_COMPILER_PATH + "/arm-linux-gnueabihf")
160 if arch == 'arm64': 167 if arch == 'arm64':
161 return (DEFAULT_ARM_CROSS_COMPILER_PATH + "/aarch64-linux-gnu") 168 return (DEFAULT_ARM_CROSS_COMPILER_PATH + "/aarch64-linux-gnu")
162 169
163 # TODO(zra): Find default MIPS Linux cross-compiler. 170 # TODO(zra): Find default MIPS Linux cross-compiler.
164 171
165 return None 172 return None
166 173
167 174
168 def SetTools(arch, target_os, options): 175 def SetTools(arch, target_os, options):
169 toolsOverride = None 176 toolsOverride = None
170 177
171 toolchainprefix = GetToolchainPrefix(target_os, arch, options) 178 toolchainprefix = GetToolchainPrefix(target_os, arch, options)
172 179
173 # Override the Android toolchain's linker to handle some complexity in the 180 # Override the Android toolchain's linker to handle some complexity in the
174 # linker arguments that gyp has trouble with. 181 # linker arguments that gyp has trouble with.
175 linker = "" 182 linker = ""
176 if target_os == 'android': 183 if target_os == 'android':
177 linker = os.path.join(DART_ROOT, 'tools', 'android_link.py') 184 linker = os.path.join(DART_ROOT, 'tools', 'android_link.py')
185 elif target_os == 'fuchsia':
186 linker = os.path.join(DART_ROOT, 'tools', 'fuchsia_link.py')
178 elif toolchainprefix: 187 elif toolchainprefix:
179 linker = toolchainprefix + "-g++" 188 linker = toolchainprefix + "-g++"
180 189
181 if toolchainprefix: 190 if toolchainprefix:
182 toolsOverride = { 191 toolsOverride = {
183 "CC.target" : toolchainprefix + "-gcc", 192 "CC.target" : toolchainprefix + "-gcc",
184 "CXX.target" : toolchainprefix + "-g++", 193 "CXX.target" : toolchainprefix + "-g++",
185 "AR.target" : toolchainprefix + "-ar", 194 "AR.target" : toolchainprefix + "-ar",
186 "LINK.target": linker, 195 "LINK.target": linker,
187 "NM.target" : toolchainprefix + "-nm", 196 "NM.target" : toolchainprefix + "-nm",
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 toolchain_arch = 'x86_64-4.9' 228 toolchain_arch = 'x86_64-4.9'
220 toolchain_dir = 'linux-x86_64' 229 toolchain_dir = 'linux-x86_64'
221 android_toolchain = os.path.join(android_ndk_root, 230 android_toolchain = os.path.join(android_ndk_root,
222 'toolchains', toolchain_arch, 231 'toolchains', toolchain_arch,
223 'prebuilt', toolchain_dir, 'bin') 232 'prebuilt', toolchain_dir, 'bin')
224 CheckDirExists(android_toolchain, 'Android toolchain') 233 CheckDirExists(android_toolchain, 'Android toolchain')
225 234
226 return android_toolchain 235 return android_toolchain
227 236
228 237
238 def GetFuchsiaToolchainDir(host_os, target_arch):
239 global THIRD_PARTY_ROOT
240 if host_os not in ['linux']:
241 raise Exception('Unsupported host os %s' % host_os)
242 if target_arch not in ['x64', 'arm64',]:
243 raise Exception('Unsupported target architecture %s' % target_arch)
244
245 # Set up path to the Android NDK.
246 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools')
247 fuchsia_tools = os.path.join(THIRD_PARTY_ROOT, 'fuchsia_tools')
248 CheckDirExists(fuchsia_tools, 'Fuchsia tools')
249
250 toolchain_arch = 'x86_64-elf-5.3.0-Linux-x86_64'
251 if target_arch == 'arm64':
252 toolchain_arch = 'aarch64-elf-5.3.0-Linux-x86_64'
253 fuchsia_toolchain = os.path.join(
254 fuchsia_tools, 'toolchains', toolchain_arch, 'bin')
255 CheckDirExists(fuchsia_toolchain, 'Fuchsia toolchain')
256
257 return fuchsia_toolchain
258
259
229 def Execute(args): 260 def Execute(args):
230 process = subprocess.Popen(args) 261 process = subprocess.Popen(args)
231 process.wait() 262 process.wait()
232 if process.returncode != 0: 263 if process.returncode != 0:
233 raise Exception(args[0] + " failed") 264 raise Exception(args[0] + " failed")
234 265
235 266
236 def CurrentDirectoryBaseName(): 267 def CurrentDirectoryBaseName():
237 """Returns the name of the current directory""" 268 """Returns the name of the current directory"""
238 return os.path.relpath(os.curdir, start=os.pardir) 269 return os.path.relpath(os.curdir, start=os.pardir)
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 else: 589 else:
559 if BuildOneConfig(options, target, target_os, 590 if BuildOneConfig(options, target, target_os,
560 mode, arch, cross_build) != 0: 591 mode, arch, cross_build) != 0:
561 return 1 592 return 1
562 593
563 return 0 594 return 0
564 595
565 596
566 if __name__ == '__main__': 597 if __name__ == '__main__':
567 sys.exit(Main()) 598 sys.exit(Main())
OLDNEW
« no previous file with comments | « runtime/vm/vm_sources.gypi ('k') | tools/fuchsia_link.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698