28ae7ff5b0
- Fix kernel invocation via ddc/ddw tools - Remove sdk_expected_errors file - it's often out of date Change-Id: I07bc073e7ebaffd39ff31b9438fd632e14aeac73 Reviewed-on: https://dart-review.googlesource.com/29640 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Vijay Menon <vsm@google.com>
65 lines
1.8 KiB
Bash
Executable File
65 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Compiles code with DDC and runs the resulting code in node.js.
|
|
#
|
|
# 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.
|
|
set -e
|
|
|
|
DDC_PATH=$( cd $( dirname "${BASH_SOURCE[0]}" )/.. && pwd )
|
|
|
|
KERNEL=false
|
|
if [ "$1" = "-k" ]; then
|
|
KERNEL=true
|
|
shift
|
|
fi
|
|
|
|
BASENAME=$( basename "${1%.*}")
|
|
LIBROOT=$(cd $( dirname "${1%.*}") && pwd)
|
|
|
|
# TODO(vsm): Change this to use the regular built version of the summaries
|
|
# and the SDK.
|
|
export NODE_PATH=$DDC_PATH/gen/sdk/common:$LIBROOT:$NODE_PATH
|
|
|
|
# Build the SDK in a place where we can find it if it's not already there.
|
|
if [ ! -e $DDC_PATH/gen/sdk/ddc_sdk.sum ]; then
|
|
$DDC_PATH/tool/build_sdk.sh
|
|
fi
|
|
|
|
if [ "$KERNEL" = true ]; then
|
|
dart -c $DDC_PATH/bin/dartdevk.dart --modules=node \
|
|
-o $BASENAME.js $*
|
|
else
|
|
dart -c $DDC_PATH/bin/dartdevc.dart --modules=node --library-root=$LIBROOT \
|
|
--dart-sdk-summary=$DDC_PATH/gen/sdk/ddc_sdk.sum \
|
|
-o $LIBROOT/$BASENAME.js $*
|
|
fi
|
|
|
|
pushd $LIBROOT > /dev/null
|
|
# TODO(jmesserly): we could have this output the same content as the devtool
|
|
# script, so you could debug the output without recompiling?
|
|
echo "
|
|
let source_maps;
|
|
try {
|
|
source_maps = require('source-map-support');
|
|
source_maps.install();
|
|
} catch(e) {
|
|
}
|
|
let sdk = require(\"dart_sdk\");
|
|
let main = require(\"./$BASENAME\").$BASENAME.main;
|
|
sdk.dart.ignoreWhitelistedErrors(false);
|
|
try {
|
|
sdk._isolate_helper.startRootIsolate(main, []);
|
|
} catch(e) {
|
|
if (!source_maps) {
|
|
console.log('For Dart source maps: npm install source-map-support');
|
|
}
|
|
console.error(e.toString(), sdk.dart.stackTrace(e).toString());
|
|
process.exit(1);
|
|
}" \
|
|
> $LIBROOT/$BASENAME.run.js
|
|
node $BASENAME.run.js || exit 1
|
|
popd > /dev/null
|