Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium 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 """A simple script to make building/testing Mojo components easier.""" | 6 """A simple script to make building/testing Mojo components easier.""" |
| 7 | 7 |
| 8 import argparse | 8 import argparse |
| 9 from copy import deepcopy | 9 from copy import deepcopy |
| 10 import logging | 10 import logging |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 _verbose_count = 0 | 24 _verbose_count = 0 |
| 25 | 25 |
| 26 | 26 |
| 27 def _args_to_config(args): | 27 def _args_to_config(args): |
| 28 # Default to host OS. | 28 # Default to host OS. |
| 29 target_os = None | 29 target_os = None |
| 30 if args.android: | 30 if args.android: |
| 31 target_os = Config.OS_ANDROID | 31 target_os = Config.OS_ANDROID |
| 32 elif args.ios: | 32 elif args.ios: |
| 33 target_os = Config.OS_IOS | 33 target_os = Config.OS_IOS |
| 34 elif args.fnl: | |
| 35 target_os = Config.OS_FNL | |
| 34 | 36 |
| 35 target_cpu = args.target_cpu | 37 target_cpu = args.target_cpu |
| 36 | 38 |
| 37 additional_args = {} | 39 additional_args = {} |
| 38 | 40 |
| 39 if 'clang' in args: | 41 if 'clang' in args: |
| 40 additional_args['is_clang'] = args.clang | 42 additional_args['is_clang'] = args.clang |
| 41 | 43 |
| 42 if 'asan' in args and args.asan: | 44 if 'asan' in args and args.asan: |
| 43 additional_args['sanitizer'] = Config.SANITIZER_ASAN | 45 additional_args['sanitizer'] = Config.SANITIZER_ASAN |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 if 'master_name' in args: | 83 if 'master_name' in args: |
| 82 additional_args['master_name'] = args.master_name | 84 additional_args['master_name'] = args.master_name |
| 83 if 'test_results_server' in args: | 85 if 'test_results_server' in args: |
| 84 additional_args['test_results_server'] = args.test_results_server | 86 additional_args['test_results_server'] = args.test_results_server |
| 85 | 87 |
| 86 if 'gn_args' in args: | 88 if 'gn_args' in args: |
| 87 additional_args['gn_args'] = args.gn_args | 89 additional_args['gn_args'] = args.gn_args |
| 88 | 90 |
| 89 is_debug = args.debug and not args.official | 91 is_debug = args.debug and not args.official |
| 90 | 92 |
| 93 if args.target_sysroot != None: | |
|
viettrungluu
2015/09/15 23:48:22
nit: |'target_sysroot' in args|
Or maybe |'target
cdotstout
2015/09/16 22:01:00
Done.
| |
| 94 additional_args['target_sysroot'] = os.path.join(Paths().src_root, | |
|
viettrungluu
2015/09/15 23:48:23
Hmmm, this implies that target_sysroot is relative
cdotstout
2015/09/16 22:01:00
Done.
| |
| 95 args.target_sysroot) | |
| 96 | |
| 97 if target_os == Config.OS_FNL: | |
|
viettrungluu
2015/09/15 23:48:23
I'm not a fan of having exits in random functions,
cdotstout
2015/09/16 22:01:00
Done.
viettrungluu
2015/09/16 22:19:46
You didn't add a check in main(). You can if you w
cdotstout
2015/09/16 22:27:09
I didn't put it in main() because doing so forces
| |
| 98 if 'target_sysroot' not in additional_args: | |
| 99 print "Must specify target_sysroot for FNL" | |
| 100 sys.exit(1) | |
| 101 | |
| 91 return Config(target_os=target_os, target_cpu=target_cpu, | 102 return Config(target_os=target_os, target_cpu=target_cpu, |
| 92 is_debug=is_debug, is_official_build=args.official, | 103 is_debug=is_debug, is_official_build=args.official, |
| 93 dcheck_always_on=args.dcheck_always_on, | 104 dcheck_always_on=args.dcheck_always_on, |
| 94 is_simulator=args.simulator, **additional_args) | 105 is_simulator=args.simulator, **additional_args) |
| 95 | 106 |
| 96 | 107 |
| 97 def _get_out_dir(config): | 108 def _get_out_dir(config): |
| 98 """Gets the build output directory (e.g., out/Debug), relative to src, for the | 109 """Gets the build output directory (e.g., out/Debug), relative to src, for the |
| 99 given config.""" | 110 given config.""" |
| 100 | 111 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 # The official build is a release build suitable for distribution, with a | 248 # The official build is a release build suitable for distribution, with a |
| 238 # different package name. | 249 # different package name. |
| 239 debug_group.add_argument('--official', help='Official build', default=False, | 250 debug_group.add_argument('--official', help='Official build', default=False, |
| 240 dest='official', action='store_true') | 251 dest='official', action='store_true') |
| 241 | 252 |
| 242 os_group = parent_parser.add_mutually_exclusive_group() | 253 os_group = parent_parser.add_mutually_exclusive_group() |
| 243 os_group.add_argument('--android', help='Build for Android', | 254 os_group.add_argument('--android', help='Build for Android', |
| 244 action='store_true') | 255 action='store_true') |
| 245 os_group.add_argument('--ios', help='Build for iOS', | 256 os_group.add_argument('--ios', help='Build for iOS', |
| 246 action='store_true') | 257 action='store_true') |
| 258 os_group.add_argument('--fnl', help='Build for FNL', | |
| 259 action='store_true') | |
| 247 | 260 |
| 248 parent_parser.add_argument('--simulator', | 261 parent_parser.add_argument('--simulator', |
| 249 help='Build for a simulator of the target', | 262 help='Build for a simulator of the target', |
| 250 action='store_true') | 263 action='store_true') |
| 251 | 264 |
| 252 parent_parser.add_argument('--target-cpu', | 265 parent_parser.add_argument('--target-cpu', |
| 253 help='CPU architecture to build for.', | 266 help='CPU architecture to build for.', |
| 254 choices=['x64', 'x86', 'arm']) | 267 choices=['x64', 'x86', 'arm']) |
| 255 | 268 |
| 269 parent_parser.add_argument('--target-sysroot', | |
| 270 help='Location of sysroot for target', | |
| 271 dest='target_sysroot') | |
| 272 | |
| 256 subparsers = parser.add_subparsers() | 273 subparsers = parser.add_subparsers() |
| 257 | 274 |
| 258 sync_parser = subparsers.add_parser('sync', parents=[parent_parser], | 275 sync_parser = subparsers.add_parser('sync', parents=[parent_parser], |
| 259 help='Sync using gclient (does not run gn).') | 276 help='Sync using gclient (does not run gn).') |
| 260 sync_parser.set_defaults(func=_sync) | 277 sync_parser.set_defaults(func=_sync) |
| 261 | 278 |
| 262 gn_parser = subparsers.add_parser('gn', parents=[parent_parser], | 279 gn_parser = subparsers.add_parser('gn', parents=[parent_parser], |
| 263 help='Run gn for mojo (does not sync).') | 280 help='Run gn for mojo (does not sync).') |
| 264 gn_parser.set_defaults(func=_gn) | 281 gn_parser.set_defaults(func=_gn) |
| 265 gn_parser.add_argument('--args', help='Specify extra args', | 282 gn_parser.add_argument('--args', help='Specify extra args', |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 | 318 |
| 302 pytest_parser = subparsers.add_parser('pytest', parents=[parent_parser], | 319 pytest_parser = subparsers.add_parser('pytest', parents=[parent_parser], |
| 303 help='Run Python unit tests (does not build).') | 320 help='Run Python unit tests (does not build).') |
| 304 pytest_parser.set_defaults(func=_pytest) | 321 pytest_parser.set_defaults(func=_pytest) |
| 305 | 322 |
| 306 args = parser.parse_args() | 323 args = parser.parse_args() |
| 307 global _verbose_count | 324 global _verbose_count |
| 308 _verbose_count = args.verbose_count | 325 _verbose_count = args.verbose_count |
| 309 InitLogging(_verbose_count) | 326 InitLogging(_verbose_count) |
| 310 | 327 |
| 311 if args.simulator and not args.ios: | 328 if args.simulator and not args.ios: |
|
viettrungluu
2015/09/16 22:19:46
Similar to this one.
cdotstout
2015/09/16 22:27:09
Acknowledged.
| |
| 312 sys.exit("Currently, the simulator target is only configured for iOS") | 329 sys.exit("Currently, the simulator target is only configured for iOS") |
| 313 | 330 |
| 314 return args.func(_args_to_config(args)) | 331 return args.func(_args_to_config(args)) |
| 315 | 332 |
| 316 | 333 |
| 317 if __name__ == '__main__': | 334 if __name__ == '__main__': |
| 318 sys.exit(main()) | 335 sys.exit(main()) |
| OLD | NEW |