mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 14:53:37 +00:00
Call dart2js directly from sdk/bin.
Review URL: https://codereview.chromium.org//11299206 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15512 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
72f1973922
commit
c17990a886
|
@ -3,24 +3,61 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
# Setting BIN_DIR this way is ugly, but is needed to handle the case where
|
||||
# dart-sdk/bin has been symlinked to. On MacOS, readlink doesn't work
|
||||
# with this case.
|
||||
BIN_DIR="$(cd "${0%/*}" ; pwd -P)"
|
||||
function follow_links() {
|
||||
while [ -h "$1" ]; do
|
||||
# On Mac OS, readlink -f doesn't work.
|
||||
1="$(readlink "$1")"
|
||||
done
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
|
||||
PROG_NAME="$(follow_links "$BASH_SOURCE")"
|
||||
|
||||
# Handle the case where dart-sdk/bin has been symlinked to.
|
||||
BIN_DIR="$(follow_links "$(cd "${PROG_NAME%/*}" ; pwd -P)")"
|
||||
|
||||
SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)"
|
||||
|
||||
DART2JS="$SDK_DIR/lib/_internal/compiler/implementation/dart2js.dart"
|
||||
DART="$BIN_DIR/dart"
|
||||
|
||||
unset EXTRA_OPTIONS
|
||||
declare -a EXTRA_OPTIONS
|
||||
|
||||
unset COLORS
|
||||
if test -t 1; then
|
||||
# Stdout is a terminal.
|
||||
if test 8 -le `tput colors`; then
|
||||
# Stdout has at least 8 colors, so enable colors.
|
||||
COLORS="--enable-diagnostic-colors"
|
||||
EXTRA_OPTIONS[${#EXTRA_OPTIONS[@]}]='--enable-diagnostic-colors'
|
||||
fi
|
||||
fi
|
||||
|
||||
unset SNAPSHOT
|
||||
if test -f "$BIN_DIR/../lib/_internal/compiler/implementation/dart2js.dart.snapshot"; then
|
||||
unset EXTRA_VM_OPTIONS
|
||||
declare -a EXTRA_VM_OPTIONS
|
||||
|
||||
SNAPSHOT="$SDK_DIR/_internal/compiler/implementation/dart2js.dart.snapshot"
|
||||
if test -f "$SNAPSHOT"; then
|
||||
# TODO(ahe): Remove the following line when we are relatively sure it works.
|
||||
echo Using snapshot "$BIN_DIR/../lib/_internal/compiler/implementation/dart2js.dart.snapshot" 1>&2
|
||||
SNAPSHOT="--use_script_snapshot=$BIN_DIR/../lib/_internal/compiler/implementation/dart2js.dart.snapshot"
|
||||
echo Using snapshot "$SNAPSHOT" 1>&2
|
||||
EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]="--use_script_snapshot=$SNAPSHOT"
|
||||
fi
|
||||
exec "$BIN_DIR"/dart --no_use_inlining --heap_growth_rate=32 $SNAPSHOT "$BIN_DIR/../lib/_internal/compiler/implementation/dart2js.dart" $COLORS "$@"
|
||||
|
||||
# Tell the VM to grow the heap more aggressively. This should only
|
||||
# be necessary temporarily until the VM is better at detecting how
|
||||
# applications use memory.
|
||||
# TODO(ahe): Remove this option (http://dartbug.com/6495).
|
||||
EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--heap_growth_rate=512'
|
||||
|
||||
# Tell the VM to don't bother inlining methods. So far inlining isn't
|
||||
# paying off but the VM team is working on fixing that.
|
||||
# TODO(ahe): Remove this option (http://dartbug.com/6495).
|
||||
EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--no_use_inlining'
|
||||
|
||||
case $0 in
|
||||
*_developer)
|
||||
EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--checked'
|
||||
;;
|
||||
esac
|
||||
|
||||
exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$DART2JS" "${EXTRA_OPTIONS[@]}" "$@"
|
||||
|
|
|
@ -12,4 +12,4 @@ set arguments=%*
|
|||
set SNAPSHOTNAME=%SCRIPTPATH%dart2js.snapshot
|
||||
if exist %SNAPSHOTNAME% set SNAPSHOT=--use_script_snapshot=%SNAPSHOTNAME%
|
||||
|
||||
"%SCRIPTPATH%dart" --no_use_inlining --heap_growth_rate=32 %SNAPSHOT% "%SCRIPTPATH%..\lib\_internal\compiler\implementation\dart2js.dart" %arguments%
|
||||
"%SCRIPTPATH%dart" --no_use_inlining --heap_growth_rate=512 %SNAPSHOT% "%SCRIPTPATH%..\lib\_internal\compiler\implementation\dart2js.dart" %arguments%
|
||||
|
|
15
sdk/bin/dart2js_developer.bat
Normal file
15
sdk/bin/dart2js_developer.bat
Normal file
|
@ -0,0 +1,15 @@
|
|||
@echo off
|
||||
REM Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
REM for details. All rights reserved. Use of this source code is governed by a
|
||||
REM BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
set SCRIPTPATH=%~dp0
|
||||
|
||||
REM Does the path have a trailing slash? If so, remove it.
|
||||
if %SCRIPTPATH:~-1%== set SCRIPTPATH=%SCRIPTPATH:~0,-1%
|
||||
|
||||
set arguments=%*
|
||||
set SNAPSHOTNAME=%SCRIPTPATH%dart2js.snapshot
|
||||
if exist %SNAPSHOTNAME% set SNAPSHOT=--use_script_snapshot=%SNAPSHOTNAME%
|
||||
|
||||
"%SCRIPTPATH%dart" --checked --no_use_inlining --heap_growth_rate=512 %SNAPSHOT% "%SCRIPTPATH%..\lib\_internal\compiler\implementation\dart2js.dart" %arguments%
|
|
@ -785,8 +785,13 @@ class RunningProcess {
|
|||
void processExitHandler(int returnCode) {
|
||||
commandCompleteHandler(command, returnCode);
|
||||
}
|
||||
|
||||
Future processFuture = Process.start(command.executable, command.arguments);
|
||||
ProcessOptions options = new ProcessOptions();
|
||||
options.environment = new Map<String, String>.from(Platform.environment);
|
||||
options.environment['DART_CONFIGURATION'] =
|
||||
TestUtils.configurationDir(testCase.configuration);
|
||||
Future processFuture = Process.start(command.executable,
|
||||
command.arguments,
|
||||
options);
|
||||
processFuture.then((Process p) {
|
||||
process = p;
|
||||
process.onExit = processExitHandler;
|
||||
|
|
|
@ -115,28 +115,35 @@ abstract class TestSuite {
|
|||
if (configuration['compiler'] == 'none') {
|
||||
return null; // No separate compiler for dartium tests.
|
||||
}
|
||||
var name = '$buildDir/${compilerName}';
|
||||
var name;
|
||||
switch (configuration['compiler']) {
|
||||
case 'dartc':
|
||||
name = '$buildDir/$executableName';
|
||||
case 'dart2js':
|
||||
case 'dart2dart':
|
||||
var prefix = 'sdk/bin/';
|
||||
String suffix = getExecutableSuffix(configuration['compiler']);
|
||||
if (configuration['host_checked']) {
|
||||
// The script dart2js_developer is not included in the
|
||||
// shipped SDK, that is the script is not installed in
|
||||
// "$buildDir/dart-sdk/bin/"
|
||||
name = '$prefix/dart2js_developer$suffix';
|
||||
} else {
|
||||
if (configuration['use_sdk']) {
|
||||
prefix = '$buildDir/dart-sdk/bin/';
|
||||
}
|
||||
name = '${prefix}dart2js$suffix';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw "Unknown compiler for: ${configuration['compiler']}";
|
||||
}
|
||||
if (!(new File(name)).existsSync() && !configuration['list']) {
|
||||
throw "Executable '$name' does not exist";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the compiler for this suite's configuration. Throws an error
|
||||
* if the configuration does not use a compiler.
|
||||
*/
|
||||
String get compilerName {
|
||||
switch (configuration['compiler']) {
|
||||
case 'dartc':
|
||||
case 'dart2js':
|
||||
case 'dart2dart':
|
||||
return executableName;
|
||||
default:
|
||||
throw "Unknown compiler for: ${configuration['compiler']}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The file name of the executable used to run this suite's tests.
|
||||
*/
|
||||
|
@ -147,19 +154,6 @@ abstract class TestSuite {
|
|||
return 'dart$suffix';
|
||||
case 'dartc':
|
||||
return 'analyzer/bin/dart_analyzer$suffix';
|
||||
case 'dart2js':
|
||||
case 'dart2dart':
|
||||
var prefix = '';
|
||||
if (configuration['use_sdk']) {
|
||||
prefix = 'dart-sdk/bin/';
|
||||
}
|
||||
if (configuration['host_checked']) {
|
||||
// The script dart2js_developer is not in the SDK.
|
||||
return 'dart2js_developer$suffix';
|
||||
} else {
|
||||
return '${prefix}dart2js$suffix';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw "Unknown executable for: ${configuration['compiler']}";
|
||||
}
|
||||
|
@ -695,7 +689,7 @@ class StandardTestSuite extends TestSuite {
|
|||
args = new List.from(args);
|
||||
String tempDir = createOutputDirectory(info.filePath, '');
|
||||
args.add('--out=$tempDir/out.js');
|
||||
List<Command> commands = <Command>[new Command(dartShellFileName, args)];
|
||||
List<Command> commands = <Command>[new Command(compilerPath, args)];
|
||||
if (info.hasCompileError) {
|
||||
// Do not attempt to run the compiled result. A compilation
|
||||
// error should be reported by the compilation command.
|
||||
|
@ -712,7 +706,7 @@ class StandardTestSuite extends TestSuite {
|
|||
String tempDir = createOutputDirectory(info.filePath, '');
|
||||
compilerArguments.add('--out=$tempDir/out.dart');
|
||||
List<Command> commands =
|
||||
<Command>[new Command(dartShellFileName, compilerArguments)];
|
||||
<Command>[new Command(compilerPath, compilerArguments)];
|
||||
if (info.hasCompileError) {
|
||||
// Do not attempt to run the compiled result. A compilation
|
||||
// error should be reported by the compilation command.
|
||||
|
@ -1620,9 +1614,13 @@ class TestUtils {
|
|||
} else if (system == 'windows') {
|
||||
outputDir = 'build/';
|
||||
}
|
||||
return "$outputDir${configurationDir(configuration)}";
|
||||
}
|
||||
|
||||
static String configurationDir(Map configuration) {
|
||||
var mode = (configuration['mode'] == 'debug') ? 'Debug' : 'Release';
|
||||
var arch = configuration['arch'].toUpperCase();
|
||||
return "$outputDir$mode$arch";
|
||||
return '$mode$arch';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue