Files
sdk/pkg/dev_compiler/tool/ddc
T
Vijay Menon 7b42a5383a Modify ddc/ddw to optionally run in kernel mode
Notes:
- must run tool/kernel_sdk.dart first to create sdk dill file
- seems to require full paths for now: ddc -k /Users/vsm/test/hello.dart

TBR=jmesserly@google.com

Change-Id: I2342a77c2edd3160e00bc4187edcf9defeb1fa27
Reviewed-on: https://dart-review.googlesource.com/14860
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
2017-10-19 20:18:57 +00:00

53 lines
1.6 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)
export NODE_PATH=$DDC_PATH/lib/js/common:$LIBROOT:$NODE_PATH
if [ "$KERNEL" = true ]; then
dart -c $DDC_PATH/bin/dartdevk.dart \
-o $BASENAME.js $*
else
dart -c $DDC_PATH/bin/dartdevc.dart --modules=node --library-root=$LIBROOT \
--dart-sdk-summary=$DDC_PATH/lib/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