Files
sdk/pkg/dev_compiler/tool/ddw
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

48 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
#
# Compiles code with DDC and runs the resulting code in node.js with devtool,
# an Electron-based debugger and browser environment.
#
# 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
echo "
// Fix the node.js search paths that Electron cleared out.
const Module = require('module');
const originalResolveFilename = Module._resolveFilename;
Module._resolveFilename = function (request, parent, isMain) {
let paths = parent.paths;
const ddcPath = \"$DDC_PATH/lib/js/common\";
if (paths[0] != ddcPath) {
paths.splice(0, 0, ddcPath, \"$LIBROOT\");
}
return originalResolveFilename(request, parent, isMain);
};
let sdk = require(\"dart_sdk\");
let main = require(\"$BASENAME\").$BASENAME.main;
sdk._isolate_helper.startRootIsolate(main, []);" \
> $LIBROOT/$BASENAME.run.js
devtool $LIBROOT/$BASENAME.run.js
popd > /dev/null