68dc77f456
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>
56 lines
1.7 KiB
Bash
Executable File
56 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Compiles code with DDC and runs the resulting code in d8 (the v8 command
|
|
# line tool). Only recent versions of v8/d8 that include es6 modules are
|
|
# supported.
|
|
#
|
|
# The first script supplied should be the one with `main()`.
|
|
#
|
|
# Saves the output in the same directory as the sources for convenient
|
|
# inspection, modification or rerunning the code.
|
|
#
|
|
# TODO(vsm): Investigate what polyfills from dart2js would be useful here:
|
|
# sdk/lib/_internal/js_runtime/lib/preambles/d8.js
|
|
#
|
|
D8=$(type -P d8)
|
|
if [ ! $D8 ]; then
|
|
echo "Please add d8 to your PATH."
|
|
exit 1
|
|
fi
|
|
set -e
|
|
DDC_PATH=$( cd $( dirname "${BASH_SOURCE[0]}" )/.. && pwd )
|
|
BASENAME=$( basename "${1%.*}")
|
|
LIBROOT=$(cd $( dirname "${1%.*}") && pwd)
|
|
|
|
# Build the SDK in a place where we can find it if it's not already there.
|
|
if [ ! -e gen/sdk/ddc_sdk.sum ]; then
|
|
./tool/build_sdk.sh
|
|
fi
|
|
|
|
# D8 uses relative paths. That won't work for the sdk right now as the
|
|
# summary is in a slightly different location.
|
|
# D8/ES6 imports also do not add a ".js" extension, so this is "dart_sdk"
|
|
# instead of "dart_sdk.js".
|
|
if [ ! -f dart_sdk ]; then
|
|
ln -s $DDC_PATH/gen/sdk/es6/dart_sdk.js dart_sdk
|
|
fi
|
|
|
|
dart -c $DDC_PATH/bin/dartdevc.dart --modules=es6 --library-root=$LIBROOT \
|
|
--dart-sdk-summary=$DDC_PATH/gen/sdk/ddc_sdk.sum \
|
|
-o $LIBROOT/$BASENAME.js $*
|
|
pushd $LIBROOT > /dev/null
|
|
echo "
|
|
import { dart, _isolate_helper } from 'dart_sdk';
|
|
import { $BASENAME } from '$BASENAME.js';
|
|
let main = $BASENAME.main;
|
|
dart.ignoreWhitelistedErrors(false);
|
|
try {
|
|
_isolate_helper.startRootIsolate(() => {}, []);
|
|
main();
|
|
} catch(e) {
|
|
console.error(e.toString(), dart.stackTrace(e).toString());
|
|
}" \
|
|
> $LIBROOT/$BASENAME.d8.js
|
|
$D8 --module $BASENAME.d8.js || exit 1
|
|
popd > /dev/null
|