dart-sdk/tools/patch_sdk.py
Bob Nystrom 68dc77f456 Build DDC's SDK as part of the regular build.
This involves a few main pieces:

- Add code to the GN scripts to generate DDC's patched SDK and then
  compile it to summaries and JS in the build output directory.

- Add support to the underlying DDC build scripts to support controlling
  which files are built where.

- Update test.dart to use the DDC SDK from the build directory.

- Update create_sdk to use the built SDK instead of the checked in one.

- Fix various internal DDC tools to build their own copy of the SDK
  (since they can't easily find the one in the build directory because
  it's path if config-specific) and use those.

- Delete the checked DDC SDK JS and summaries.

I think I got everything working. The built Dart SDK looks fine -- it's
identical to one built using the old build scripts.

The various tools and DDC's little test runner I *think* work, but there
may be a bug or two in there. I tried the various things I could and it
seems like they work but it's hard to tell since they may be kind of
broken right now anyway.

Bug:
Change-Id: Iea77915a5c1cc8450f60ebfbdf8c725c7ea2f32c
Reviewed-on: https://dart-review.googlesource.com/18144
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
2017-11-20 23:24:07 +00:00

64 lines
1.9 KiB
Python
Executable file

#!/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.
import argparse
import os
import subprocess
import sys
import utils
usage = """patch_sdk.py [options]"""
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
"""
def BuildArguments():
result = argparse.ArgumentParser(usage=usage)
result.add_argument("-q", "--quiet",
help="emit no output",
default=False,
action="store_true")
result.add_argument("--dart-executable",
help="dart executable",
default=None)
result.add_argument("--script",
help="patch script to run",
default=None)
return result
def main():
# Parse the options.
parser = BuildArguments()
(options, args) = parser.parse_known_args()
if utils.CheckedInSdkCheckExecutable():
options.dart_executable = utils.CheckedInSdkExecutable()
elif options.dart_executable is not None:
if not options.quiet:
DisplayBootstrapWarning()
options.dart_executable = os.path.abspath(options.dart_executable)
else:
print >> sys.stderr, 'ERROR: cannot locate dart executable'
return -1
if options.script is not None:
dart_file = options.script
else:
dart_file = os.path.join(os.path.dirname(__file__), 'patch_sdk.dart')
subprocess.check_call([options.dart_executable, dart_file] + args)
return 0
if __name__ == '__main__':
sys.exit(main())