| OLD | NEW |
| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 utils.ConfigureJava() | 337 utils.ConfigureJava() |
| 338 # Parse the options. | 338 # Parse the options. |
| 339 parser = BuildOptions() | 339 parser = BuildOptions() |
| 340 (options, args) = parser.parse_args() | 340 (options, args) = parser.parse_args() |
| 341 if not ProcessOptions(options, args): | 341 if not ProcessOptions(options, args): |
| 342 parser.print_help() | 342 parser.print_help() |
| 343 return 1 | 343 return 1 |
| 344 # Determine which targets to build. By default we build the "all" target. | 344 # Determine which targets to build. By default we build the "all" target. |
| 345 if len(args) == 0: | 345 if len(args) == 0: |
| 346 if HOST_OS == 'macos': | 346 if HOST_OS == 'macos': |
| 347 target = 'All' | 347 targets = ['All'] |
| 348 else: | 348 else: |
| 349 target = 'all' | 349 targets = ['all'] |
| 350 else: | 350 else: |
| 351 target = args[0] | 351 targets = args |
| 352 | 352 |
| 353 filter_xcodebuild_output = False | 353 filter_xcodebuild_output = False |
| 354 # Remember path | 354 # Remember path |
| 355 old_path = os.environ['PATH'] | 355 old_path = os.environ['PATH'] |
| 356 # Build the targets for each requested configuration. | 356 # Build all targets for each requested configuration. |
| 357 for target_os in options.os: | 357 for target in targets: |
| 358 for mode in options.mode: | 358 for target_os in options.os: |
| 359 for arch in options.arch: | 359 for mode in options.mode: |
| 360 os.environ['DART_BUILD_MODE'] = mode | 360 for arch in options.arch: |
| 361 build_config = utils.GetBuildConf(mode, arch) | 361 os.environ['DART_BUILD_MODE'] = mode |
| 362 if HOST_OS == 'macos': | 362 build_config = utils.GetBuildConf(mode, arch) |
| 363 filter_xcodebuild_output = True | 363 if HOST_OS == 'macos': |
| 364 project_file = 'dart.xcodeproj' | 364 filter_xcodebuild_output = True |
| 365 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): | 365 project_file = 'dart.xcodeproj' |
| 366 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() | 366 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): |
| 367 args = ['xcodebuild', | 367 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() |
| 368 '-project', | 368 args = ['xcodebuild', |
| 369 project_file, | 369 '-project', |
| 370 '-target', | 370 project_file, |
| 371 target, | 371 '-target', |
| 372 '-configuration', | 372 target, |
| 373 build_config, | 373 '-configuration', |
| 374 'SYMROOT=%s' % os.path.abspath('xcodebuild') | |
| 375 ] | |
| 376 elif HOST_OS == 'win32': | |
| 377 project_file = 'dart.sln' | |
| 378 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): | |
| 379 project_file = 'dart-%s.sln' % CurrentDirectoryBaseName() | |
| 380 if target == 'all': | |
| 381 args = [options.devenv + os.sep + options.executable, | |
| 382 '/build', | |
| 383 build_config, | 374 build_config, |
| 384 project_file | 375 'SYMROOT=%s' % os.path.abspath('xcodebuild') |
| 385 ] | 376 ] |
| 377 elif HOST_OS == 'win32': |
| 378 project_file = 'dart.sln' |
| 379 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): |
| 380 project_file = 'dart-%s.sln' % CurrentDirectoryBaseName() |
| 381 if target == 'all': |
| 382 args = [options.devenv + os.sep + options.executable, |
| 383 '/build', |
| 384 build_config, |
| 385 project_file |
| 386 ] |
| 387 else: |
| 388 args = [options.devenv + os.sep + options.executable, |
| 389 '/build', |
| 390 build_config, |
| 391 '/project', |
| 392 target, |
| 393 project_file |
| 394 ] |
| 386 else: | 395 else: |
| 387 args = [options.devenv + os.sep + options.executable, | 396 make = 'make' |
| 388 '/build', | 397 if HOST_OS == 'freebsd': |
| 389 build_config, | 398 make = 'gmake' |
| 390 '/project', | 399 # work around lack of flock |
| 391 target, | 400 os.environ['LINK'] = '$(CXX)' |
| 392 project_file | 401 args = [make, |
| 393 ] | 402 '-j', |
| 394 else: | 403 options.j, |
| 395 make = 'make' | 404 'BUILDTYPE=' + build_config, |
| 396 if HOST_OS == 'freebsd': | 405 ] |
| 397 make = 'gmake' | 406 if target_os != HOST_OS: |
| 398 # work around lack of flock | 407 args += ['builddir_name=' + utils.GetBuildDir(HOST_OS, target_os)] |
| 399 os.environ['LINK'] = '$(CXX)' | 408 if options.verbose: |
| 400 args = [make, | 409 args += ['V=1'] |
| 401 '-j', | 410 |
| 402 options.j, | 411 args += [target] |
| 403 'BUILDTYPE=' + build_config, | 412 |
| 404 ] | |
| 405 if target_os != HOST_OS: | 413 if target_os != HOST_OS: |
| 406 args += ['builddir_name=' + utils.GetBuildDir(HOST_OS, target_os)] | 414 SetCrossCompilationEnvironment( |
| 407 if options.verbose: | 415 HOST_OS, target_os, arch, old_path) |
| 408 args += ['V=1'] | |
| 409 | 416 |
| 410 args += [target] | 417 RunhooksIfNeeded(HOST_OS, mode, arch, target_os) |
| 411 | 418 |
| 412 if target_os != HOST_OS: | 419 toolchainprefix = None |
| 413 SetCrossCompilationEnvironment( | 420 if target_os == 'android': |
| 414 HOST_OS, target_os, arch, old_path) | 421 toolchainprefix = ('%s/i686-linux-android' |
| 415 | 422 % os.environ['ANDROID_TOOLCHAIN']) |
| 416 RunhooksIfNeeded(HOST_OS, mode, arch, target_os) | 423 toolsOverride = SetTools(arch, toolchainprefix) |
| 417 | 424 if toolsOverride: |
| 418 toolchainprefix = None | 425 printToolOverrides = target_os != 'android' |
| 419 if target_os == 'android': | 426 for k, v in toolsOverride.iteritems(): |
| 420 toolchainprefix = ('%s/i686-linux-android' | 427 args.append( k + "=" + v) |
| 421 % os.environ['ANDROID_TOOLCHAIN']) | 428 if printToolOverrides: |
| 422 toolsOverride = SetTools(arch, toolchainprefix) | 429 print k + " = " + v |
| 423 if toolsOverride: | 430 if not os.path.isfile(toolsOverride['CC.target']): |
| 424 printToolOverrides = target_os != 'android' | 431 if arch == 'arm': |
| 425 for k, v in toolsOverride.iteritems(): | 432 print arm_cc_error |
| 426 args.append( k + "=" + v) | 433 else: |
| 427 if printToolOverrides: | 434 print "Couldn't find compiler: %s" % toolsOverride['CC.target'] |
| 428 print k + " = " + v | 435 return 1 |
| 429 if not os.path.isfile(toolsOverride['CC.target']): | |
| 430 if arch == 'arm': | |
| 431 print arm_cc_error | |
| 432 else: | |
| 433 print "Couldn't find compiler: %s" % toolsOverride['CC.target'] | |
| 434 return 1 | |
| 435 | 436 |
| 436 | 437 |
| 437 print ' '.join(args) | 438 print ' '.join(args) |
| 438 process = None | 439 process = None |
| 439 if filter_xcodebuild_output: | 440 if filter_xcodebuild_output: |
| 440 process = subprocess.Popen(args, | 441 process = subprocess.Popen(args, |
| 441 stdin=None, | 442 stdin=None, |
| 442 bufsize=1, # Line buffered. | 443 bufsize=1, # Line buffered. |
| 443 stdout=subprocess.PIPE, | 444 stdout=subprocess.PIPE, |
| 444 stderr=subprocess.STDOUT) | 445 stderr=subprocess.STDOUT) |
| 445 FilterEmptyXcodebuildSections(process) | 446 FilterEmptyXcodebuildSections(process) |
| 446 else: | 447 else: |
| 447 process = subprocess.Popen(args, stdin=None) | 448 process = subprocess.Popen(args, stdin=None) |
| 448 process.wait() | 449 process.wait() |
| 449 if process.returncode != 0: | 450 if process.returncode != 0: |
| 450 print "BUILD FAILED" | 451 print "BUILD FAILED" |
| 451 return 1 | 452 return 1 |
| 452 | 453 |
| 453 return 0 | 454 return 0 |
| 454 | 455 |
| 455 | 456 |
| 456 if __name__ == '__main__': | 457 if __name__ == '__main__': |
| 457 sys.exit(Main()) | 458 sys.exit(Main()) |
| OLD | NEW |