Files
sdk/pkg/dev_compiler/tool/ddw
T
Bob Nystrom 68dc77f456 Build DDC's SDK as part of the regular build.
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>
2017-11-20 23:24:07 +00:00

58 lines
1.7 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
# 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
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/gen/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