| 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 shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 import time | 12 import time |
| 13 import utils | 13 import utils |
| 14 | 14 |
| 15 HOST_OS = utils.GuessOS() | 15 HOST_OS = utils.GuessOS() |
| 16 HOST_ARCH = utils.GuessArchitecture() | 16 HOST_ARCH = utils.GuessArchitecture() |
| 17 SCRIPT_DIR = os.path.dirname(sys.argv[0]) | 17 SCRIPT_DIR = os.path.dirname(sys.argv[0]) |
| 18 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') | 19 GN = os.path.join(DART_ROOT, 'buildtools', 'gn') |
| 20 | 20 |
| 21 # Environment variables for default settings. | 21 # Environment variables for default settings. |
| 22 DART_USE_ASAN = "DART_USE_ASAN" # Use instead of --asan | 22 DART_USE_ASAN = "DART_USE_ASAN" # Use instead of --asan |
| 23 DART_USE_MSAN = "DART_USE_MSAN" # Use instead of --msan | 23 DART_USE_MSAN = "DART_USE_MSAN" # Use instead of --msan |
| 24 DART_USE_TSAN = "DART_USE_TSAN" # Use instead of --tsan | 24 DART_USE_TSAN = "DART_USE_TSAN" # Use instead of --tsan |
| 25 DART_USE_WHEEZY = "DART_USE_WHEEZY" # Use instread of --wheezy | 25 DART_USE_WHEEZY = "DART_USE_WHEEZY" # Use instread of --wheezy |
| 26 DART_USE_TOOLCHAIN = "DART_USE_TOOLCHAIN" # Use instread of --toolchain-prefix | 26 DART_USE_TOOLCHAIN = "DART_USE_TOOLCHAIN" # Use instread of --toolchain-prefix |
| 27 DART_USE_SYSROOT = "DART_USE_SYSROOT" # Use instead of --target-sysroot | 27 DART_USE_SYSROOT = "DART_USE_SYSROOT" # Use instead of --target-sysroot |
| 28 # use instead of --platform-sdk |
| 29 DART_MAKE_PLATFORM_SDK = "DART_MAKE_PLATFORM_SDK" |
| 28 | 30 |
| 29 def UseASAN(): | 31 def UseASAN(): |
| 30 return DART_USE_ASAN in os.environ | 32 return DART_USE_ASAN in os.environ |
| 31 | 33 |
| 32 | 34 |
| 33 def UseMSAN(): | 35 def UseMSAN(): |
| 34 return DART_USE_MSAN in os.environ | 36 return DART_USE_MSAN in os.environ |
| 35 | 37 |
| 36 | 38 |
| 37 def UseTSAN(): | 39 def UseTSAN(): |
| 38 return DART_USE_TSAN in os.environ | 40 return DART_USE_TSAN in os.environ |
| 39 | 41 |
| 40 | 42 |
| 41 def UseWheezy(): | 43 def UseWheezy(): |
| 42 return DART_USE_WHEEZY in os.environ | 44 return DART_USE_WHEEZY in os.environ |
| 43 | 45 |
| 44 | 46 |
| 45 def ToolchainPrefix(args): | 47 def ToolchainPrefix(args): |
| 46 if args.toolchain_prefix: | 48 if args.toolchain_prefix: |
| 47 return args.toolchain_prefix | 49 return args.toolchain_prefix |
| 48 return os.environ.get(DART_USE_TOOLCHAIN) | 50 return os.environ.get(DART_USE_TOOLCHAIN) |
| 49 | 51 |
| 50 | 52 |
| 51 def TargetSysroot(args): | 53 def TargetSysroot(args): |
| 52 if args.target_sysroot: | 54 if args.target_sysroot: |
| 53 return args.target_sysroot | 55 return args.target_sysroot |
| 54 return os.environ.get(DART_USE_SYSROOT) | 56 return os.environ.get(DART_USE_SYSROOT) |
| 55 | 57 |
| 56 | 58 |
| 59 def MakePlatformSDK(): |
| 60 return DART_MAKE_PLATFORM_SDK in os.environ |
| 61 |
| 62 |
| 57 def GetOutDir(mode, arch, target_os): | 63 def GetOutDir(mode, arch, target_os): |
| 58 return utils.GetBuildRoot(HOST_OS, mode, arch, target_os) | 64 return utils.GetBuildRoot(HOST_OS, mode, arch, target_os) |
| 59 | 65 |
| 60 | 66 |
| 61 def ToCommandLine(gn_args): | 67 def ToCommandLine(gn_args): |
| 62 def merge(key, value): | 68 def merge(key, value): |
| 63 if type(value) is bool: | 69 if type(value) is bool: |
| 64 return '%s=%s' % (key, 'true' if value else 'false') | 70 return '%s=%s' % (key, 'true' if value else 'false') |
| 65 return '%s="%s"' % (key, value) | 71 return '%s="%s"' % (key, value) |
| 66 return [merge(x, y) for x, y in gn_args.iteritems()] | 72 return [merge(x, y) for x, y in gn_args.iteritems()] |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 196 |
| 191 dont_use_clang = DontUseClang(args, gn_args['target_os'], | 197 dont_use_clang = DontUseClang(args, gn_args['target_os'], |
| 192 gn_args['host_cpu'], | 198 gn_args['host_cpu'], |
| 193 gn_args['target_cpu']) | 199 gn_args['target_cpu']) |
| 194 gn_args['is_clang'] = args.clang and not dont_use_clang | 200 gn_args['is_clang'] = args.clang and not dont_use_clang |
| 195 | 201 |
| 196 gn_args['is_asan'] = args.asan and gn_args['is_clang'] | 202 gn_args['is_asan'] = args.asan and gn_args['is_clang'] |
| 197 gn_args['is_msan'] = args.msan and gn_args['is_clang'] | 203 gn_args['is_msan'] = args.msan and gn_args['is_clang'] |
| 198 gn_args['is_tsan'] = args.tsan and gn_args['is_clang'] | 204 gn_args['is_tsan'] = args.tsan and gn_args['is_clang'] |
| 199 | 205 |
| 206 gn_args['dart_platform_sdk'] = args.platform_sdk |
| 207 |
| 200 # Setup the user-defined sysroot. | 208 # Setup the user-defined sysroot. |
| 201 if gn_args['target_os'] == 'linux' and args.wheezy and not crossbuild: | 209 if gn_args['target_os'] == 'linux' and args.wheezy and not crossbuild: |
| 202 gn_args['dart_use_wheezy_sysroot'] = True | 210 gn_args['dart_use_wheezy_sysroot'] = True |
| 203 else: | 211 else: |
| 204 sysroot = TargetSysroot(args) | 212 sysroot = TargetSysroot(args) |
| 205 if sysroot: | 213 if sysroot: |
| 206 gn_args['target_sysroot'] = ParseStringMap(arch, sysroot) | 214 gn_args['target_sysroot'] = ParseStringMap(arch, sysroot) |
| 207 | 215 |
| 208 toolchain = ToolchainPrefix(args) | 216 toolchain = ToolchainPrefix(args) |
| 209 if toolchain: | 217 if toolchain: |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 default=os_has_ide(HOST_OS), | 358 default=os_has_ide(HOST_OS), |
| 351 action='store_true') | 359 action='store_true') |
| 352 other_group.add_argument('--msan', | 360 other_group.add_argument('--msan', |
| 353 help='Build with MSAN', | 361 help='Build with MSAN', |
| 354 default=UseMSAN(), | 362 default=UseMSAN(), |
| 355 action='store_true') | 363 action='store_true') |
| 356 other_group.add_argument('--no-msan', | 364 other_group.add_argument('--no-msan', |
| 357 help='Disable MSAN', | 365 help='Disable MSAN', |
| 358 dest='msan', | 366 dest='msan', |
| 359 action='store_false') | 367 action='store_false') |
| 368 other_group.add_argument('--platform-sdk', |
| 369 help='Directs the create_sdk target to create a smaller "Platform" SDK', |
| 370 default=MakePlatformSDK(), |
| 371 action='store_true') |
| 360 other_group.add_argument('--target-sysroot', '-s', | 372 other_group.add_argument('--target-sysroot', '-s', |
| 361 type=str, | 373 type=str, |
| 362 help='Comma-separated list of arch=/path/to/sysroot mappings') | 374 help='Comma-separated list of arch=/path/to/sysroot mappings') |
| 363 other_group.add_argument('--toolchain-prefix', '-t', | 375 other_group.add_argument('--toolchain-prefix', '-t', |
| 364 type=str, | 376 type=str, |
| 365 help='Comma-separated list of arch=/path/to/toolchain-prefix mappings') | 377 help='Comma-separated list of arch=/path/to/toolchain-prefix mappings') |
| 366 other_group.add_argument('--tsan', | 378 other_group.add_argument('--tsan', |
| 367 help='Build with TSAN', | 379 help='Build with TSAN', |
| 368 default=UseTSAN(), | 380 default=UseTSAN(), |
| 369 action='store_true') | 381 action='store_true') |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 return 1 | 453 return 1 |
| 442 | 454 |
| 443 endtime = time.time() | 455 endtime = time.time() |
| 444 if args.verbose: | 456 if args.verbose: |
| 445 print ("GN Time: %.3f seconds" % (endtime - starttime)) | 457 print ("GN Time: %.3f seconds" % (endtime - starttime)) |
| 446 return 0 | 458 return 0 |
| 447 | 459 |
| 448 | 460 |
| 449 if __name__ == '__main__': | 461 if __name__ == '__main__': |
| 450 sys.exit(Main(sys.argv)) | 462 sys.exit(Main(sys.argv)) |
| OLD | NEW |