OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # Compiles code with DDC and runs the resulting code in node.js. | 3 # Compiles code with DDC and runs the resulting code in node.js. |
4 # | 4 # |
5 # The first script supplied should be the one with `main()`. | 5 # The first script supplied should be the one with `main()`. |
6 # | 6 # |
7 # Saves the output in the same directory as the sources for convenient | 7 # Saves the output in the same directory as the sources for convenient |
8 # inspection, modification or rerunning the code. | 8 # inspection, modification or rerunning the code. |
9 # | 9 # |
10 set -e | 10 set -e |
11 DDC_PATH=$( cd $( dirname "${BASH_SOURCE[0]}" )/.. && pwd ) | 11 DDC_PATH=$( cd $( dirname "${BASH_SOURCE[0]}" )/.. && pwd ) |
12 BASENAME=$( basename "${1%.*}") | 12 BASENAME=$( basename "${1%.*}") |
13 LIBROOT=$(cd $( dirname "${1%.*}") && pwd) | 13 LIBROOT=$(cd $( dirname "${1%.*}") && pwd) |
14 export NODE_PATH=$DDC_PATH/lib/js/common:$LIBROOT:$NODE_PATH | 14 export NODE_PATH=$DDC_PATH/lib/js/common:$LIBROOT:$NODE_PATH |
15 dart -c $DDC_PATH/bin/dartdevc.dart --modules=node --library-root=$LIBROOT \ | 15 dart -c $DDC_PATH/bin/dartdevc.dart --modules=node --library-root=$LIBROOT \ |
16 --dart-sdk-summary=$DDC_PATH/lib/sdk/ddc_sdk.sum \ | 16 --dart-sdk-summary=$DDC_PATH/lib/sdk/ddc_sdk.sum \ |
17 -o $LIBROOT/$BASENAME.js $* | 17 -o $LIBROOT/$BASENAME.js $* |
18 pushd $LIBROOT > /dev/null | 18 pushd $LIBROOT > /dev/null |
19 # TODO(jmesserly): we could have this output the same content as the devtool | 19 # TODO(jmesserly): we could have this output the same content as the devtool |
20 # script, so you could debug the output without recompiling? | 20 # script, so you could debug the output without recompiling? |
21 echo " | 21 echo " |
22 let sdk = require(\"dart_sdk\"); | 22 let sdk = require(\"dart_sdk\"); |
23 let main = require(\"$BASENAME\").$BASENAME.main; | 23 let main = require(\"$BASENAME\").$BASENAME.main; |
24 sdk._isolate_helper.startRootIsolate(main, []);" \ | 24 sdk.dart.ignoreWhitelistedErrors(false); |
25 try { | |
26 sdk._isolate_helper.startRootIsolate(main, []); | |
27 } catch(e) { | |
28 console.error(e.toString(), sdk.dart.stackTrace(e).toString()); | |
Jennifer Messerly
2017/08/25 18:08:57
This is to make sure the error stack trace prints.
| |
29 process.exit(1); | |
30 }" \ | |
25 > $LIBROOT/$BASENAME.run.js | 31 > $LIBROOT/$BASENAME.run.js |
26 node $BASENAME.run.js | 32 node $BASENAME.run.js || exit 1 |
27 popd > /dev/null | 33 popd > /dev/null |
OLD | NEW |