OLD | NEW |
---|---|
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 subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 gn_args['dart_host_pub_exe'] = "" | 83 gn_args['dart_host_pub_exe'] = "" |
84 | 84 |
85 # We only want the fallback root certs in the standalone VM on | 85 # We only want the fallback root certs in the standalone VM on |
86 # Linux and Windows. | 86 # Linux and Windows. |
87 if gn_args['target_os'] in ['linux', 'win']: | 87 if gn_args['target_os'] in ['linux', 'win']: |
88 gn_args['dart_use_fallback_root_certificates'] = True | 88 gn_args['dart_use_fallback_root_certificates'] = True |
89 | 89 |
90 gn_args['dart_zlib_path'] = "//runtime/bin/zlib" | 90 gn_args['dart_zlib_path'] = "//runtime/bin/zlib" |
91 | 91 |
92 # Use tcmalloc only when targeting Linux and when not using ASAN. | 92 # Use tcmalloc only when targeting Linux and when not using ASAN. |
93 gn_args['dart_use_tcmalloc'] = (gn_args['target_os'] == 'linux' | 93 gn_args['dart_use_tcmalloc'] = ((gn_args['target_os'] == 'linux') |
94 and not args.asan) | 94 and not args.asan |
95 and not args.tsan) | |
siva
2017/01/03 20:53:08
and not args.msan
zra
2017/01/03 22:36:56
Done.
| |
95 | 96 |
96 # Force -mfloat-abi=hard and -mfpu=neon on Linux as we're specifying | 97 # Force -mfloat-abi=hard and -mfpu=neon on Linux as we're specifying |
97 # a gnueabihf compiler in //build/toolchain/linux BUILD.gn. | 98 # a gnueabihf compiler in //build/toolchain/linux BUILD.gn. |
98 # TODO(zra): This will likely need some adjustment to build for armv6 etc. | 99 # TODO(zra): This will likely need some adjustment to build for armv6 etc. |
99 hard_float = (gn_args['target_cpu'].startswith('arm') and | 100 hard_float = (gn_args['target_cpu'].startswith('arm') and |
100 gn_args['target_os'] == 'linux') | 101 (gn_args['target_os'] == 'linux')) |
101 if hard_float: | 102 if hard_float: |
102 gn_args['arm_float_abi'] = 'hard' | 103 gn_args['arm_float_abi'] = 'hard' |
103 gn_args['arm_use_neon'] = True | 104 gn_args['arm_use_neon'] = True |
104 | 105 |
105 gn_args['is_debug'] = mode == 'debug' | 106 gn_args['is_debug'] = mode == 'debug' |
106 gn_args['is_release'] = mode == 'release' | 107 gn_args['is_release'] = mode == 'release' |
107 gn_args['is_product'] = mode == 'product' | 108 gn_args['is_product'] = mode == 'product' |
108 gn_args['dart_debug'] = mode == 'debug' | 109 gn_args['dart_debug'] = mode == 'debug' |
109 | 110 |
110 # This setting is only meaningful for Flutter. Standalone builds of the VM | 111 # This setting is only meaningful for Flutter. Standalone builds of the VM |
111 # should leave this set to 'develop', which causes the build to defer to | 112 # should leave this set to 'develop', which causes the build to defer to |
112 # 'is_debug', 'is_release' and 'is_product'. | 113 # 'is_debug', 'is_release' and 'is_product'. |
113 gn_args['dart_runtime_mode'] = 'develop' | 114 gn_args['dart_runtime_mode'] = 'develop' |
114 | 115 |
115 # TODO(zra): Investigate using clang with these configurations. | 116 # TODO(zra): Investigate using clang with these configurations. |
116 # Clang compiles tcmalloc's inline assembly for ia32 on Linux wrong, so we | 117 # Clang compiles tcmalloc's inline assembly for ia32 on Linux wrong, so we |
117 # don't use clang in that configuration. | 118 # don't use clang in that configuration. Thus, we use gcc for ia32 *unless* |
119 # asan or tsan is specified. | |
siva
2017/01/03 20:53:08
asan,msan or tsan is ...
zra
2017/01/03 22:36:56
Done.
| |
118 has_clang = (host_os != 'win' | 120 has_clang = (host_os != 'win' |
119 and args.os not in ['android'] | 121 and args.os not in ['android'] |
120 and not (gn_args['target_os'] == 'linux' and | |
121 gn_args['host_cpu'] == 'x86' and | |
122 not args.asan) # Use clang for asan builds. | |
123 and not gn_args['target_cpu'].startswith('arm') | 122 and not gn_args['target_cpu'].startswith('arm') |
124 and not gn_args['target_cpu'].startswith('mips')) | 123 and not gn_args['target_cpu'].startswith('mips') |
124 and not ((gn_args['target_os'] == 'linux') | |
125 and (gn_args['host_cpu'] == 'x86') | |
126 and not args.asan | |
127 and not args.tsan)) # Use clang for asan builds. | |
siva
2017/01/03 20:53:08
and not args.msan
# Use clang for all sanitizer b
zra
2017/01/03 22:36:56
Done.
| |
125 gn_args['is_clang'] = args.clang and has_clang | 128 gn_args['is_clang'] = args.clang and has_clang |
126 | 129 |
127 gn_args['is_asan'] = args.asan and gn_args['is_clang'] | 130 gn_args['is_asan'] = args.asan and gn_args['is_clang'] |
131 gn_args['is_tsan'] = args.tsan and gn_args['is_clang'] | |
siva
2017/01/03 20:53:08
msan too...
zra
2017/01/03 22:36:56
Done.
| |
128 | 132 |
129 # Setup the user-defined sysroot. | 133 # Setup the user-defined sysroot. |
130 if gn_args['target_os'] == 'linux' and args.wheezy: | 134 if gn_args['target_os'] == 'linux' and args.wheezy: |
131 gn_args['dart_use_wheezy_sysroot'] = True | 135 gn_args['dart_use_wheezy_sysroot'] = True |
132 else: | 136 else: |
133 if args.target_sysroot: | 137 if args.target_sysroot: |
134 gn_args['target_sysroot'] = args.target_sysroot | 138 gn_args['target_sysroot'] = args.target_sysroot |
135 | 139 |
136 if args.toolchain_prefix: | 140 if args.toolchain_prefix: |
137 gn_args['toolchain_prefix'] = args.toolchain_prefix | 141 gn_args['toolchain_prefix'] = args.toolchain_prefix |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 if host_os.startswith('win'): | 211 if host_os.startswith('win'): |
208 return '--ide=vs' | 212 return '--ide=vs' |
209 elif host_os.startswith('mac'): | 213 elif host_os.startswith('mac'): |
210 return '--ide=xcode' | 214 return '--ide=xcode' |
211 else: | 215 else: |
212 return '--ide=json' | 216 return '--ide=json' |
213 | 217 |
214 | 218 |
215 # Environment variables for default settings. | 219 # Environment variables for default settings. |
216 DART_USE_ASAN = "DART_USE_ASAN" | 220 DART_USE_ASAN = "DART_USE_ASAN" |
221 DART_USE_TSAN = "DART_USE_TSAN" | |
siva
2017/01/03 20:53:08
msan too.
zra
2017/01/03 22:36:56
Done.
| |
217 DART_USE_WHEEZY = "DART_USE_WHEEZY" | 222 DART_USE_WHEEZY = "DART_USE_WHEEZY" |
218 | 223 |
219 def use_asan(): | 224 def use_asan(): |
220 return DART_USE_ASAN in os.environ | 225 return DART_USE_ASAN in os.environ |
221 | 226 |
227 def use_tsan(): | |
228 return DART_USE_TSAN in os.environ | |
222 | 229 |
223 def use_wheezy(): | 230 def use_wheezy(): |
224 return DART_USE_WHEEZY in os.environ | 231 return DART_USE_WHEEZY in os.environ |
225 | 232 |
226 | 233 |
227 def parse_args(args): | 234 def parse_args(args): |
228 args = args[1:] | 235 args = args[1:] |
229 parser = argparse.ArgumentParser(description='A script to run `gn gen`.') | 236 parser = argparse.ArgumentParser( |
237 description='A script to run `gn gen`.', | |
238 formatter_class=argparse.ArgumentDefaultsHelpFormatter) | |
239 common_group = parser.add_argument_group('Common Arguments') | |
240 other_group = parser.add_argument_group('Other Arguments') | |
230 | 241 |
231 parser.add_argument("-v", "--verbose", | 242 common_group.add_argument('--arch', '-a', |
232 help='Verbose output.', | |
233 default=False, action="store_true") | |
234 parser.add_argument('--mode', '-m', | |
235 type=str, | |
236 help='Build variants (comma-separated).', | |
237 metavar='[all,debug,release,product]', | |
238 default='debug') | |
239 parser.add_argument('--os', | |
240 type=str, | |
241 help='Target OSs (comma-separated).', | |
242 metavar='[all,host,android]', | |
243 default='host') | |
244 parser.add_argument('--arch', '-a', | |
245 type=str, | 243 type=str, |
246 help='Target architectures (comma-separated).', | 244 help='Target architectures (comma-separated).', |
247 metavar='[all,ia32,x64,simarm,arm,simarmv6,armv6,simarmv5te,armv5te,' | 245 metavar='[all,ia32,x64,simarm,arm,simarmv6,armv6,simarmv5te,armv5te,' |
248 'simmips,mips,simarm64,arm64,simdbc,armsimdbc]', | 246 'simmips,mips,simarm64,arm64,simdbc,armsimdbc]', |
249 default='x64') | 247 default='x64') |
250 parser.add_argument('--asan', | 248 common_group.add_argument('--mode', '-m', |
249 type=str, | |
250 help='Build variants (comma-separated).', | |
251 metavar='[all,debug,release,product]', | |
252 default='debug') | |
253 common_group.add_argument('--os', | |
254 type=str, | |
255 help='Target OSs (comma-separated).', | |
256 metavar='[all,host,android]', | |
257 default='host') | |
258 common_group.add_argument("-v", "--verbose", | |
259 help='Verbose output.', | |
260 default=False, action="store_true") | |
261 | |
262 other_group.add_argument('--asan', | |
251 help='Build with ASAN', | 263 help='Build with ASAN', |
252 default=use_asan(), | 264 default=use_asan(), |
253 action='store_true') | 265 action='store_true') |
254 parser.add_argument('--no-asan', | 266 other_group.add_argument('--no-asan', |
255 help='Disable ASAN', | 267 help='Disable ASAN', |
256 dest='asan', | 268 dest='asan', |
257 action='store_false') | 269 action='store_false') |
258 parser.add_argument('--wheezy', | 270 other_group.add_argument('--clang', |
271 help='Use Clang', | |
272 default=True, | |
273 action='store_true') | |
274 other_group.add_argument('--no-clang', | |
275 help='Disable Clang', | |
276 dest='clang', | |
277 action='store_false') | |
278 other_group.add_argument('--goma', | |
279 help='Use goma', | |
280 default=True, | |
281 action='store_true') | |
282 other_group.add_argument('--no-goma', | |
283 help='Disable goma', | |
284 dest='goma', | |
285 action='store_false') | |
286 other_group.add_argument('--ide', | |
287 help='Generate an IDE file.', | |
288 default=os_has_ide(HOST_OS), | |
289 action='store_true') | |
290 other_group.add_argument('--target-sysroot', '-s', | |
291 type=str, | |
292 help='Path to the toolchain sysroot') | |
293 other_group.add_argument('--toolchain-prefix', '-t', | |
294 type=str, | |
295 help='Path to the toolchain prefix') | |
296 other_group.add_argument('--tsan', | |
297 help='Build with TSAN', | |
298 default=use_tsan(), | |
299 action='store_true') | |
300 other_group.add_argument('--no-tsan', | |
301 help='Disable TSAN', | |
302 dest='tsan', | |
303 action='store_false') | |
siva
2017/01/03 20:53:08
msan options too.
zra
2017/01/03 22:36:56
Done.
| |
304 other_group.add_argument('--wheezy', | |
259 help='Use the Debian wheezy sysroot on Linux', | 305 help='Use the Debian wheezy sysroot on Linux', |
260 default=use_wheezy(), | 306 default=use_wheezy(), |
261 action='store_true') | 307 action='store_true') |
262 parser.add_argument('--no-wheezy', | 308 other_group.add_argument('--no-wheezy', |
263 help='Disable the Debian wheezy sysroot on Linux', | 309 help='Disable the Debian wheezy sysroot on Linux', |
264 dest='wheezy', | 310 dest='wheezy', |
265 action='store_false') | 311 action='store_false') |
266 parser.add_argument('--goma', | 312 other_group.add_argument('--workers', '-w', |
267 help='Use goma', | |
268 default=True, | |
269 action='store_true') | |
270 parser.add_argument('--no-goma', | |
271 help='Disable goma', | |
272 dest='goma', | |
273 action='store_false') | |
274 parser.add_argument('--clang', | |
275 help='Use Clang', | |
276 default=True, | |
277 action='store_true') | |
278 parser.add_argument('--no-clang', | |
279 help='Disable Clang', | |
280 dest='clang', | |
281 action='store_false') | |
282 parser.add_argument('--ide', | |
283 help='Generate an IDE file.', | |
284 default=os_has_ide(HOST_OS), | |
285 action='store_true') | |
286 parser.add_argument('--target-sysroot', '-s', | |
287 type=str, | |
288 help='Path to the toolchain sysroot') | |
289 parser.add_argument('--toolchain-prefix', '-t', | |
290 type=str, | |
291 help='Path to the toolchain prefix') | |
292 parser.add_argument('--workers', '-w', | |
293 type=int, | 313 type=int, |
294 help='Number of simultaneous GN invocations', | 314 help='Number of simultaneous GN invocations', |
295 dest='workers', | 315 dest='workers', |
296 default=multiprocessing.cpu_count()) | 316 default=multiprocessing.cpu_count()) |
297 | 317 |
298 options = parser.parse_args(args) | 318 options = parser.parse_args(args) |
299 if not process_options(options): | 319 if not process_options(options): |
300 parser.print_help() | 320 parser.print_help() |
301 return None | 321 return None |
302 return options | 322 return options |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 return 1 | 373 return 1 |
354 | 374 |
355 endtime = time.time() | 375 endtime = time.time() |
356 if args.verbose: | 376 if args.verbose: |
357 print ("GN Time: %.3f seconds" % (endtime - starttime)) | 377 print ("GN Time: %.3f seconds" % (endtime - starttime)) |
358 return 0 | 378 return 0 |
359 | 379 |
360 | 380 |
361 if __name__ == '__main__': | 381 if __name__ == '__main__': |
362 sys.exit(main(sys.argv)) | 382 sys.exit(main(sys.argv)) |
OLD | NEW |