2016-10-27 08:09:22 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
|
|
# for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
2016-10-31 13:13:33 +00:00
|
|
|
import argparse
|
2016-10-27 08:09:22 +00:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import utils
|
|
|
|
|
2016-10-31 13:13:33 +00:00
|
|
|
usage = """patch_sdk.py [options]"""
|
|
|
|
|
2016-11-01 16:34:27 +00:00
|
|
|
def DisplayBootstrapWarning():
|
|
|
|
print """\
|
|
|
|
|
|
|
|
|
|
|
|
WARNING: Your system cannot run the checked-in Dart SDK. Using the
|
|
|
|
bootstrap Dart executable will make debug builds slow.
|
|
|
|
Please see the Wiki for instructions on replacing the checked-in Dart SDK.
|
|
|
|
|
|
|
|
https://github.com/dart-lang/sdk/wiki/The-checked-in-SDK-in-tools
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2016-10-31 13:13:33 +00:00
|
|
|
def BuildArguments():
|
|
|
|
result = argparse.ArgumentParser(usage=usage)
|
2016-12-13 21:02:52 +00:00
|
|
|
result.add_argument("-q", "--quiet",
|
|
|
|
help="emit no output",
|
|
|
|
default=False,
|
|
|
|
action="store_true")
|
|
|
|
result.add_argument("--dart-executable",
|
|
|
|
help="dart executable",
|
|
|
|
default=None)
|
2017-11-20 23:24:07 +00:00
|
|
|
result.add_argument("--script",
|
|
|
|
help="patch script to run",
|
|
|
|
default=None)
|
2016-10-31 13:13:33 +00:00
|
|
|
return result
|
|
|
|
|
2016-10-27 08:09:22 +00:00
|
|
|
def main():
|
2016-10-31 13:13:33 +00:00
|
|
|
# Parse the options.
|
|
|
|
parser = BuildArguments()
|
|
|
|
(options, args) = parser.parse_known_args()
|
2016-11-01 16:34:27 +00:00
|
|
|
if utils.CheckedInSdkCheckExecutable():
|
|
|
|
options.dart_executable = utils.CheckedInSdkExecutable()
|
|
|
|
elif options.dart_executable is not None:
|
2016-12-13 21:02:52 +00:00
|
|
|
if not options.quiet:
|
|
|
|
DisplayBootstrapWarning()
|
2016-10-31 13:13:33 +00:00
|
|
|
options.dart_executable = os.path.abspath(options.dart_executable)
|
|
|
|
else:
|
2016-11-01 16:34:27 +00:00
|
|
|
print >> sys.stderr, 'ERROR: cannot locate dart executable'
|
|
|
|
return -1
|
2017-11-20 23:24:07 +00:00
|
|
|
|
|
|
|
if options.script is not None:
|
|
|
|
dart_file = options.script
|
|
|
|
else:
|
|
|
|
dart_file = os.path.join(os.path.dirname(__file__), 'patch_sdk.dart')
|
|
|
|
|
2017-06-22 19:41:28 +00:00
|
|
|
subprocess.check_call([options.dart_executable, dart_file] + args)
|
2016-11-01 16:34:27 +00:00
|
|
|
return 0
|
2016-10-27 08:09:22 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-11-01 16:34:27 +00:00
|
|
|
sys.exit(main())
|