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

Side by Side Diff: tools/gn.py

Issue 2858873005: [infra] Roll clang to match the version used by Flutter (Closed)
Patch Set: Fix Mac Android build Created 3 years, 7 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 # Copyright 2016 The Dart project authors. All rights reserved. 2 # Copyright 2016 The Dart project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import multiprocessing 7 import multiprocessing
8 import os 8 import os
9 import shutil
9 import subprocess 10 import subprocess
10 import sys 11 import sys
11 import time 12 import time
12 import utils 13 import utils
13 14
14 HOST_OS = utils.GuessOS() 15 HOST_OS = utils.GuessOS()
15 HOST_ARCH = utils.GuessArchitecture() 16 HOST_ARCH = utils.GuessArchitecture()
16 SCRIPT_DIR = os.path.dirname(sys.argv[0]) 17 SCRIPT_DIR = os.path.dirname(sys.argv[0])
17 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) 18 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
19 GN = os.path.join(DART_ROOT, 'buildtools', 'gn')
18 20
19 # Environment variables for default settings. 21 # Environment variables for default settings.
20 DART_USE_ASAN = "DART_USE_ASAN" # Use instead of --asan 22 DART_USE_ASAN = "DART_USE_ASAN" # Use instead of --asan
21 DART_USE_MSAN = "DART_USE_MSAN" # Use instead of --msan 23 DART_USE_MSAN = "DART_USE_MSAN" # Use instead of --msan
22 DART_USE_TSAN = "DART_USE_TSAN" # Use instead of --tsan 24 DART_USE_TSAN = "DART_USE_TSAN" # Use instead of --tsan
23 DART_USE_WHEEZY = "DART_USE_WHEEZY" # Use instread of --wheezy 25 DART_USE_WHEEZY = "DART_USE_WHEEZY" # Use instread of --wheezy
24 DART_USE_TOOLCHAIN = "DART_USE_TOOLCHAIN" # Use instread of --toolchain-prefix 26 DART_USE_TOOLCHAIN = "DART_USE_TOOLCHAIN" # Use instread of --toolchain-prefix
25 DART_USE_SYSROOT = "DART_USE_SYSROOT" # Use instead of --target-sysroot 27 DART_USE_SYSROOT = "DART_USE_SYSROOT" # Use instead of --target-sysroot
26 28
27 def use_asan(): 29 def UseASAN():
28 return DART_USE_ASAN in os.environ 30 return DART_USE_ASAN in os.environ
29 31
30 32
31 def use_msan(): 33 def UseMSAN():
32 return DART_USE_MSAN in os.environ 34 return DART_USE_MSAN in os.environ
33 35
34 36
35 def use_tsan(): 37 def UseTSAN():
36 return DART_USE_TSAN in os.environ 38 return DART_USE_TSAN in os.environ
37 39
38 40
39 def use_wheezy(): 41 def UseWheezy():
40 return DART_USE_WHEEZY in os.environ 42 return DART_USE_WHEEZY in os.environ
41 43
42 44
43 def toolchain_prefix(args): 45 def ToolchainPrefix(args):
44 if args.toolchain_prefix: 46 if args.toolchain_prefix:
45 return args.toolchain_prefix 47 return args.toolchain_prefix
46 return os.environ.get(DART_USE_TOOLCHAIN) 48 return os.environ.get(DART_USE_TOOLCHAIN)
47 49
48 50
49 def target_sysroot(args): 51 def TargetSysroot(args):
50 if args.target_sysroot: 52 if args.target_sysroot:
51 return args.target_sysroot 53 return args.target_sysroot
52 return os.environ.get(DART_USE_SYSROOT) 54 return os.environ.get(DART_USE_SYSROOT)
53 55
54 56
55 def get_out_dir(mode, arch, target_os): 57 def GetOutDir(mode, arch, target_os):
56 return utils.GetBuildRoot(HOST_OS, mode, arch, target_os) 58 return utils.GetBuildRoot(HOST_OS, mode, arch, target_os)
57 59
58 60
59 def to_command_line(gn_args): 61 def ToCommandLine(gn_args):
60 def merge(key, value): 62 def merge(key, value):
61 if type(value) is bool: 63 if type(value) is bool:
62 return '%s=%s' % (key, 'true' if value else 'false') 64 return '%s=%s' % (key, 'true' if value else 'false')
63 return '%s="%s"' % (key, value) 65 return '%s="%s"' % (key, value)
64 return [merge(x, y) for x, y in gn_args.iteritems()] 66 return [merge(x, y) for x, y in gn_args.iteritems()]
65 67
66 68
67 def host_cpu_for_arch(arch): 69 def HostCpuForArch(arch):
68 if arch in ['ia32', 'arm', 'armv6', 'armv5te', 'mips', 70 if arch in ['ia32', 'arm', 'armv6', 'armv5te', 'mips',
69 'simarm', 'simarmv6', 'simarmv5te', 'simmips', 'simdbc', 71 'simarm', 'simarmv6', 'simarmv5te', 'simmips', 'simdbc',
70 'armsimdbc']: 72 'armsimdbc']:
71 return 'x86' 73 return 'x86'
72 if arch in ['x64', 'arm64', 'simarm64', 'simdbc64', 'armsimdbc64']: 74 if arch in ['x64', 'arm64', 'simarm64', 'simdbc64', 'armsimdbc64']:
73 return 'x64' 75 return 'x64'
74 76
75 77
76 def target_cpu_for_arch(arch, target_os): 78 def TargetCpuForArch(arch, target_os):
77 if arch in ['ia32', 'simarm', 'simarmv6', 'simarmv5te', 'simmips']: 79 if arch in ['ia32', 'simarm', 'simarmv6', 'simarmv5te', 'simmips']:
78 return 'x86' 80 return 'x86'
79 if arch in ['simarm64']: 81 if arch in ['simarm64']:
80 return 'x64' 82 return 'x64'
81 if arch == 'mips': 83 if arch == 'mips':
82 return 'mipsel' 84 return 'mipsel'
83 if arch == 'simdbc': 85 if arch == 'simdbc':
84 return 'arm' if target_os == 'android' else 'x86' 86 return 'arm' if target_os == 'android' else 'x86'
85 if arch == 'simdbc64': 87 if arch == 'simdbc64':
86 return 'arm64' if target_os == 'android' else 'x64' 88 return 'arm64' if target_os == 'android' else 'x64'
87 if arch == 'armsimdbc': 89 if arch == 'armsimdbc':
88 return 'arm' 90 return 'arm'
89 if arch == 'armsimdbc64': 91 if arch == 'armsimdbc64':
90 return 'arm64' 92 return 'arm64'
91 return arch 93 return arch
92 94
93 95
94 def host_os_for_gn(host_os): 96 def HostOsForGn(host_os):
95 if host_os.startswith('macos'): 97 if host_os.startswith('macos'):
96 return 'mac' 98 return 'mac'
97 if host_os.startswith('win'): 99 if host_os.startswith('win'):
98 return 'win' 100 return 'win'
99 return host_os 101 return host_os
100 102
101 103
102 # Where string_map is formatted as X1=Y1,X2=Y2 etc. 104 # Where string_map is formatted as X1=Y1,X2=Y2 etc.
103 # If key is X1, returns Y1. 105 # If key is X1, returns Y1.
104 def parse_string_map(key, string_map): 106 def ParseStringMap(key, string_map):
105 for m in string_map.split(','): 107 for m in string_map.split(','):
106 l = m.split('=') 108 l = m.split('=')
107 if l[0] == key: 109 if l[0] == key:
108 return l[1] 110 return l[1]
109 return None 111 return None
110 112
111 113
112 def to_gn_args(args, mode, arch, target_os): 114 def ToGnArgs(args, mode, arch, target_os):
113 gn_args = {} 115 gn_args = {}
114 116
115 host_os = host_os_for_gn(HOST_OS) 117 host_os = HostOsForGn(HOST_OS)
116 if target_os == 'host': 118 if target_os == 'host':
117 gn_args['target_os'] = host_os 119 gn_args['target_os'] = host_os
118 else: 120 else:
119 gn_args['target_os'] = target_os 121 gn_args['target_os'] = target_os
120 122
121 gn_args['dart_target_arch'] = arch 123 gn_args['dart_target_arch'] = arch
122 gn_args['target_cpu'] = target_cpu_for_arch(arch, target_os) 124 gn_args['target_cpu'] = TargetCpuForArch(arch, target_os)
123 gn_args['host_cpu'] = host_cpu_for_arch(arch) 125 gn_args['host_cpu'] = HostCpuForArch(arch)
124 126
125 # See: runtime/observatory/BUILD.gn. 127 # See: runtime/observatory/BUILD.gn.
126 # This allows the standalone build of the observatory to fall back on 128 # This allows the standalone build of the observatory to fall back on
127 # dart_bootstrap if the prebuilt SDK doesn't work. 129 # dart_bootstrap if the prebuilt SDK doesn't work.
128 gn_args['dart_host_pub_exe'] = "" 130 gn_args['dart_host_pub_exe'] = ""
129 131
130 # We only want the fallback root certs in the standalone VM on 132 # We only want the fallback root certs in the standalone VM on
131 # Linux and Windows. 133 # Linux and Windows.
132 if gn_args['target_os'] in ['linux', 'win']: 134 if gn_args['target_os'] in ['linux', 'win']:
133 gn_args['dart_use_fallback_root_certificates'] = True 135 gn_args['dart_use_fallback_root_certificates'] = True
(...skipping 24 matching lines...) Expand all
158 gn_args['dart_debug'] = mode == 'debug' 160 gn_args['dart_debug'] = mode == 'debug'
159 161
160 # This setting is only meaningful for Flutter. Standalone builds of the VM 162 # This setting is only meaningful for Flutter. Standalone builds of the VM
161 # should leave this set to 'develop', which causes the build to defer to 163 # should leave this set to 'develop', which causes the build to defer to
162 # 'is_debug', 'is_release' and 'is_product'. 164 # 'is_debug', 'is_release' and 'is_product'.
163 gn_args['dart_runtime_mode'] = 'develop' 165 gn_args['dart_runtime_mode'] = 'develop'
164 166
165 # TODO(zra): Investigate using clang with these configurations. 167 # TODO(zra): Investigate using clang with these configurations.
166 # Clang compiles tcmalloc's inline assembly for ia32 on Linux wrong, so we 168 # Clang compiles tcmalloc's inline assembly for ia32 on Linux wrong, so we
167 # don't use clang in that configuration. Thus, we use gcc for ia32 *unless* 169 # don't use clang in that configuration. Thus, we use gcc for ia32 *unless*
168 # asan or tsan is specified. 170 # a clang-based sanitizer is specified.
169 has_clang = (host_os != 'win' 171 has_clang = (host_os != 'win'
170 and args.os not in ['android']
171 and not gn_args['target_cpu'].startswith('arm')
172 and not gn_args['target_cpu'].startswith('mips') 172 and not gn_args['target_cpu'].startswith('mips')
173 and not ((gn_args['target_os'] == 'linux') 173 and not ((gn_args['target_os'] == 'linux')
174 and (gn_args['host_cpu'] == 'x86') 174 and (gn_args['host_cpu'] == 'x86')
175 and not args.asan 175 and not args.asan
176 and not args.msan 176 and not args.msan
177 and not args.tsan)) # Use clang for sanitizer builds. 177 and not args.tsan)) # Use clang for sanitizer builds.
178 gn_args['is_clang'] = args.clang and has_clang 178 gn_args['is_clang'] = args.clang and has_clang
179 179
180 gn_args['is_asan'] = args.asan and gn_args['is_clang'] 180 gn_args['is_asan'] = args.asan and gn_args['is_clang']
181 gn_args['is_msan'] = args.msan and gn_args['is_clang'] 181 gn_args['is_msan'] = args.msan and gn_args['is_clang']
182 gn_args['is_tsan'] = args.tsan and gn_args['is_clang'] 182 gn_args['is_tsan'] = args.tsan and gn_args['is_clang']
183 183
184 # Setup the user-defined sysroot. 184 # Setup the user-defined sysroot.
185 if gn_args['target_os'] == 'linux' and args.wheezy: 185 if gn_args['target_os'] == 'linux' and args.wheezy:
186 gn_args['dart_use_wheezy_sysroot'] = True 186 gn_args['dart_use_wheezy_sysroot'] = True
187 else: 187 else:
188 sysroot = target_sysroot(args) 188 sysroot = TargetSysroot(args)
189 if sysroot: 189 if sysroot:
190 gn_args['target_sysroot'] = parse_string_map(arch, sysroot) 190 gn_args['target_sysroot'] = ParseStringMap(arch, sysroot)
191 191
192 toolchain = toolchain_prefix(args) 192 toolchain = ToolchainPrefix(args)
193 if toolchain: 193 if toolchain:
194 gn_args['toolchain_prefix'] = parse_string_map(arch, toolchain) 194 gn_args['toolchain_prefix'] = ParseStringMap(arch, toolchain)
195 195
196 goma_dir = os.environ.get('GOMA_DIR') 196 goma_dir = os.environ.get('GOMA_DIR')
197 goma_home_dir = os.path.join(os.getenv('HOME', ''), 'goma') 197 goma_home_dir = os.path.join(os.getenv('HOME', ''), 'goma')
198 if args.goma and goma_dir: 198 if args.goma and goma_dir:
199 gn_args['use_goma'] = True 199 gn_args['use_goma'] = True
200 gn_args['goma_dir'] = goma_dir 200 gn_args['goma_dir'] = goma_dir
201 elif args.goma and os.path.exists(goma_home_dir): 201 elif args.goma and os.path.exists(goma_home_dir):
202 gn_args['use_goma'] = True 202 gn_args['use_goma'] = True
203 gn_args['goma_dir'] = goma_home_dir 203 gn_args['goma_dir'] = goma_home_dir
204 else: 204 else:
205 gn_args['use_goma'] = False 205 gn_args['use_goma'] = False
206 gn_args['goma_dir'] = None 206 gn_args['goma_dir'] = None
207 207
208 if args.debug_opt_level: 208 if args.debug_opt_level:
209 gn_args['dart_debug_optimization_level'] = args.debug_opt_level 209 gn_args['dart_debug_optimization_level'] = args.debug_opt_level
210 gn_args['debug_optimization_level'] = args.debug_opt_level 210 gn_args['debug_optimization_level'] = args.debug_opt_level
211 211
212 return gn_args 212 return gn_args
213 213
214 214
215 def process_os_option(os_name): 215 def ProcessOsOption(os_name):
216 if os_name == 'host': 216 if os_name == 'host':
217 return HOST_OS 217 return HOST_OS
218 return os_name 218 return os_name
219 219
220 220
221 def process_options(args): 221 def ProcessOptions(args):
222 if args.arch == 'all': 222 if args.arch == 'all':
223 args.arch = 'ia32,x64,simarm,simarm64,simmips,simdbc64' 223 args.arch = 'ia32,x64,simarm,simarm64,simmips,simdbc64'
224 if args.mode == 'all': 224 if args.mode == 'all':
225 args.mode = 'debug,release,product' 225 args.mode = 'debug,release,product'
226 if args.os == 'all': 226 if args.os == 'all':
227 args.os = 'host,android' 227 args.os = 'host,android'
228 args.mode = args.mode.split(',') 228 args.mode = args.mode.split(',')
229 args.arch = args.arch.split(',') 229 args.arch = args.arch.split(',')
230 args.os = args.os.split(',') 230 args.os = args.os.split(',')
231 for mode in args.mode: 231 for mode in args.mode:
232 if not mode in ['debug', 'release', 'product']: 232 if not mode in ['debug', 'release', 'product']:
233 print "Unknown mode %s" % mode 233 print "Unknown mode %s" % mode
234 return False 234 return False
235 for arch in args.arch: 235 for arch in args.arch:
236 archs = ['ia32', 'x64', 'simarm', 'arm', 'simarmv6', 'armv6', 236 archs = ['ia32', 'x64', 'simarm', 'arm', 'simarmv6', 'armv6',
237 'simarmv5te', 'armv5te', 'simmips', 'mips', 'simarm64', 'arm64', 237 'simarmv5te', 'armv5te', 'simmips', 'mips', 'simarm64', 'arm64',
238 'simdbc', 'simdbc64', 'armsimdbc', 'armsimdbc64'] 238 'simdbc', 'simdbc64', 'armsimdbc', 'armsimdbc64']
239 if not arch in archs: 239 if not arch in archs:
240 print "Unknown arch %s" % arch 240 print "Unknown arch %s" % arch
241 return False 241 return False
242 oses = [process_os_option(os_name) for os_name in args.os] 242 oses = [ProcessOsOption(os_name) for os_name in args.os]
243 for os_name in oses: 243 for os_name in oses:
244 if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']: 244 if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']:
245 print "Unknown os %s" % os_name 245 print "Unknown os %s" % os_name
246 return False 246 return False
247 if os_name != HOST_OS: 247 if os_name != HOST_OS:
248 if os_name != 'android': 248 if os_name != 'android':
249 print "Unsupported target os %s" % os_name 249 print "Unsupported target os %s" % os_name
250 return False 250 return False
251 if not HOST_OS in ['linux']: 251 if not HOST_OS in ['linux', 'macos']:
252 print ("Cross-compilation to %s is not supported on host os %s." 252 print ("Cross-compilation to %s is not supported on host os %s."
253 % (os_name, HOST_OS)) 253 % (os_name, HOST_OS))
254 return False 254 return False
255 if not arch in ['ia32', 'x64', 'arm', 'armv6', 'armv5te', 'arm64', 'mips', 255 if not arch in ['ia32', 'x64', 'arm', 'armv6', 'armv5te', 'arm64', 'mips',
256 'simdbc', 'simdbc64']: 256 'simdbc', 'simdbc64']:
257 print ("Cross-compilation to %s is not supported for architecture %s." 257 print ("Cross-compilation to %s is not supported for architecture %s."
258 % (os_name, arch)) 258 % (os_name, arch))
259 return False 259 return False
260 return True 260 return True
261 261
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 type=str, 296 type=str,
297 help='Target OSs (comma-separated).', 297 help='Target OSs (comma-separated).',
298 metavar='[all,host,android]', 298 metavar='[all,host,android]',
299 default='host') 299 default='host')
300 common_group.add_argument("-v", "--verbose", 300 common_group.add_argument("-v", "--verbose",
301 help='Verbose output.', 301 help='Verbose output.',
302 default=False, action="store_true") 302 default=False, action="store_true")
303 303
304 other_group.add_argument('--asan', 304 other_group.add_argument('--asan',
305 help='Build with ASAN', 305 help='Build with ASAN',
306 default=use_asan(), 306 default=UseASAN(),
307 action='store_true') 307 action='store_true')
308 other_group.add_argument('--no-asan', 308 other_group.add_argument('--no-asan',
309 help='Disable ASAN', 309 help='Disable ASAN',
310 dest='asan', 310 dest='asan',
311 action='store_false') 311 action='store_false')
312 other_group.add_argument('--clang', 312 other_group.add_argument('--clang',
313 help='Use Clang', 313 help='Use Clang',
314 default=True, 314 default=True,
315 action='store_true') 315 action='store_true')
316 other_group.add_argument('--no-clang', 316 other_group.add_argument('--no-clang',
(...skipping 11 matching lines...) Expand all
328 other_group.add_argument('--no-goma', 328 other_group.add_argument('--no-goma',
329 help='Disable goma', 329 help='Disable goma',
330 dest='goma', 330 dest='goma',
331 action='store_false') 331 action='store_false')
332 other_group.add_argument('--ide', 332 other_group.add_argument('--ide',
333 help='Generate an IDE file.', 333 help='Generate an IDE file.',
334 default=os_has_ide(HOST_OS), 334 default=os_has_ide(HOST_OS),
335 action='store_true') 335 action='store_true')
336 other_group.add_argument('--msan', 336 other_group.add_argument('--msan',
337 help='Build with MSAN', 337 help='Build with MSAN',
338 default=use_msan(), 338 default=UseMSAN(),
339 action='store_true') 339 action='store_true')
340 other_group.add_argument('--no-msan', 340 other_group.add_argument('--no-msan',
341 help='Disable MSAN', 341 help='Disable MSAN',
342 dest='msan', 342 dest='msan',
343 action='store_false') 343 action='store_false')
344 other_group.add_argument('--target-sysroot', '-s', 344 other_group.add_argument('--target-sysroot', '-s',
345 type=str, 345 type=str,
346 help='Comma-separated list of arch=/path/to/sysroot mappings') 346 help='Comma-separated list of arch=/path/to/sysroot mappings')
347 other_group.add_argument('--toolchain-prefix', '-t', 347 other_group.add_argument('--toolchain-prefix', '-t',
348 type=str, 348 type=str,
349 help='Comma-separated list of arch=/path/to/toolchain-prefix mappings') 349 help='Comma-separated list of arch=/path/to/toolchain-prefix mappings')
350 other_group.add_argument('--tsan', 350 other_group.add_argument('--tsan',
351 help='Build with TSAN', 351 help='Build with TSAN',
352 default=use_tsan(), 352 default=UseTSAN(),
353 action='store_true') 353 action='store_true')
354 other_group.add_argument('--no-tsan', 354 other_group.add_argument('--no-tsan',
355 help='Disable TSAN', 355 help='Disable TSAN',
356 dest='tsan', 356 dest='tsan',
357 action='store_false') 357 action='store_false')
358 other_group.add_argument('--wheezy', 358 other_group.add_argument('--wheezy',
359 help='Use the Debian wheezy sysroot on Linux', 359 help='Use the Debian wheezy sysroot on Linux',
360 default=use_wheezy(), 360 default=UseWheezy(),
361 action='store_true') 361 action='store_true')
362 other_group.add_argument('--no-wheezy', 362 other_group.add_argument('--no-wheezy',
363 help='Disable the Debian wheezy sysroot on Linux', 363 help='Disable the Debian wheezy sysroot on Linux',
364 dest='wheezy', 364 dest='wheezy',
365 action='store_false') 365 action='store_false')
366 other_group.add_argument('--workers', '-w', 366 other_group.add_argument('--workers', '-w',
367 type=int, 367 type=int,
368 help='Number of simultaneous GN invocations', 368 help='Number of simultaneous GN invocations',
369 dest='workers', 369 dest='workers',
370 # Set to multiprocessing.cpu_count() when GN can be run in parallel. 370 default=multiprocessing.cpu_count())
371 default=1)
372 371
373 options = parser.parse_args(args) 372 options = parser.parse_args(args)
374 if not process_options(options): 373 if not ProcessOptions(options):
375 parser.print_help() 374 parser.print_help()
376 return None 375 return None
377 return options 376 return options
378 377
379 378
380 def run_command(command): 379 # Run the command, if it succeeds returns 0, if it fails, returns the commands
380 # output as a string.
381 def RunCommand(command):
381 try: 382 try:
382 subprocess.check_output( 383 subprocess.check_output(
383 command, cwd=DART_ROOT, stderr=subprocess.STDOUT) 384 command, cwd=DART_ROOT, stderr=subprocess.STDOUT)
384 return 0 385 return 0
385 except subprocess.CalledProcessError as e: 386 except subprocess.CalledProcessError as e:
386 return ("Command failed: " + ' '.join(command) + "\n" + 387 return ("Command failed: " + ' '.join(command) + "\n" +
387 "output: " + e.output) 388 "output: " + e.output)
388 389
389 390
390 def main(argv): 391 def Main(argv):
391 starttime = time.time() 392 starttime = time.time()
392 args = parse_args(argv) 393 args = parse_args(argv)
393 394
394 if sys.platform.startswith(('cygwin', 'win')): 395 if sys.platform.startswith(('cygwin', 'win')):
395 subdir = 'win' 396 subdir = 'win'
396 elif sys.platform == 'darwin': 397 elif sys.platform == 'darwin':
397 subdir = 'mac' 398 subdir = 'mac'
398 elif sys.platform.startswith('linux'): 399 elif sys.platform.startswith('linux'):
399 subdir = 'linux64' 400 subdir = 'linux64'
400 else: 401 else:
401 print 'Unknown platform: ' + sys.platform 402 print 'Unknown platform: ' + sys.platform
402 return 1 403 return 1
404 gn = os.path.join(DART_ROOT, 'buildtools', subdir, 'gn')
403 405
404 commands = [] 406 commands = []
405 for target_os in args.os: 407 for target_os in args.os:
406 for mode in args.mode: 408 for mode in args.mode:
407 for arch in args.arch: 409 for arch in args.arch:
408 command = [ 410 out_dir = GetOutDir(mode, arch, target_os)
409 '%s/buildtools/%s/gn' % (DART_ROOT, subdir), 411 command = [gn, 'gen', out_dir, '--check']
410 'gen', 412 gn_args = ToCommandLine(ToGnArgs(args, mode, arch, target_os))
411 '--check'
412 ]
413 gn_args = to_command_line(to_gn_args(args, mode, arch, target_os))
414 out_dir = get_out_dir(mode, arch, target_os)
415 if args.verbose: 413 if args.verbose:
416 print "gn gen --check in %s" % out_dir 414 print "gn gen --check in %s" % out_dir
417 if args.ide: 415 if args.ide:
418 command.append(ide_switch(HOST_OS)) 416 command.append(ide_switch(HOST_OS))
419 command.append(out_dir)
420 command.append('--args=%s' % ' '.join(gn_args)) 417 command.append('--args=%s' % ' '.join(gn_args))
421 commands.append(command) 418 commands.append(command)
422 419
423 pool = multiprocessing.Pool(args.workers) 420 pool = multiprocessing.Pool(args.workers)
424 results = pool.map(run_command, commands, chunksize=1) 421 results = pool.map(RunCommand, commands, chunksize=1)
425 for r in results: 422 for r in results:
426 if r != 0: 423 if r != 0:
427 print r.strip() 424 print r.strip()
428 return 1 425 return 1
429 426
430 endtime = time.time() 427 endtime = time.time()
431 if args.verbose: 428 if args.verbose:
432 print ("GN Time: %.3f seconds" % (endtime - starttime)) 429 print ("GN Time: %.3f seconds" % (endtime - starttime))
433 return 0 430 return 0
434 431
435 432
436 if __name__ == '__main__': 433 if __name__ == '__main__':
437 sys.exit(main(sys.argv)) 434 sys.exit(Main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698