mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:09:04 +00:00
Add --version option to dart2js and add version information (if available) to generated code.
Remove the 'Using snapshot ...' comment from sdk/bin/dart2js since we are now relatively sure it works. R=ahe@google.com, ngeoffray@google.com BUG=http://dartbug.com/4439, http://dartbug.com/9848 Review URL: https://codereview.chromium.org//15957006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23355 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
284544c8ca
commit
3c95824799
|
@ -41,9 +41,6 @@ unset EXTRA_VM_OPTIONS
|
|||
declare -a EXTRA_VM_OPTIONS
|
||||
|
||||
if test -f "$SNAPSHOT"; then
|
||||
# TODO(ahe): Remove the following line when we are relatively sure it works.
|
||||
echo Using snapshot "$SNAPSHOT" 1>&2
|
||||
|
||||
EXTRA_OPTIONS[${#EXTRA_OPTIONS[@]}]="--library-root=$SDK_DIR"
|
||||
fi
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ if _%DART2JS_DEVELOPER_MODE%_ == _1_ (
|
|||
)
|
||||
|
||||
if exist "%SNAPSHOT%" (
|
||||
echo Using snapshot "%SNAPSHOT%" >&2
|
||||
set EXTRA_OPTIONS=%EXTRA_OPTIONS% "--library-root=%SDK_DIR%"
|
||||
)
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ void compile(List<String> argv) {
|
|||
List<String> options = new List<String>();
|
||||
bool explicitOut = false;
|
||||
bool wantHelp = false;
|
||||
bool wantVersion = false;
|
||||
String outputLanguage = 'JavaScript';
|
||||
bool stripArgumentSet = false;
|
||||
bool analyzeOnly = false;
|
||||
|
@ -197,6 +198,7 @@ void compile(List<String> argv) {
|
|||
(_) => diagnosticHandler.showWarnings = false),
|
||||
new OptionHandler('--output-type=dart|--output-type=js', setOutputType),
|
||||
new OptionHandler('--verbose', setVerbose),
|
||||
new OptionHandler('--version', (_) => wantVersion = true),
|
||||
new OptionHandler('--library-root=.+', setLibraryRoot),
|
||||
new OptionHandler('--out=.+|-o.+', setOutput),
|
||||
new OptionHandler('--allow-mock-compilation', passThrough),
|
||||
|
@ -235,7 +237,9 @@ void compile(List<String> argv) {
|
|||
];
|
||||
|
||||
parseCommandLine(handlers, argv);
|
||||
if (wantHelp) helpAndExit(diagnosticHandler.verbose);
|
||||
if (wantHelp || wantVersion) {
|
||||
helpAndExit(wantHelp, wantVersion, diagnosticHandler.verbose);
|
||||
}
|
||||
|
||||
if (outputLanguage != OUTPUT_LANGUAGE_DART && stripArgumentSet) {
|
||||
helpAndFail('Error: --force-strip may only be used with '
|
||||
|
@ -413,6 +417,9 @@ Supported options:
|
|||
-v, --verbose
|
||||
Display verbose information.
|
||||
|
||||
--version
|
||||
Display version information.
|
||||
|
||||
-p<path>, --package-root=<path>
|
||||
Where to find packages, that is, "package:..." imports.
|
||||
|
||||
|
@ -487,11 +494,19 @@ be removed in a future version:
|
|||
'''.trim());
|
||||
}
|
||||
|
||||
void helpAndExit(bool verbose) {
|
||||
if (verbose) {
|
||||
verboseHelp();
|
||||
} else {
|
||||
help();
|
||||
void helpAndExit(bool wantHelp, bool wantVersion, bool verbose) {
|
||||
if (wantVersion) {
|
||||
var version = (BUILD_ID == null)
|
||||
? '<non-SDK build>'
|
||||
: BUILD_ID;
|
||||
print('Dart-to-JavaScript compiler (dart2js) version: $version');
|
||||
}
|
||||
if (wantHelp) {
|
||||
if (verbose) {
|
||||
verboseHelp();
|
||||
} else {
|
||||
help();
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -2948,7 +2948,7 @@ if (typeof document !== "undefined" && document.readyState !== "complete") {
|
|||
|
||||
computeNeededClasses();
|
||||
|
||||
mainBuffer.add(GENERATED_BY);
|
||||
mainBuffer.add(buildGeneratedBy());
|
||||
addComment(HOOKS_API_USAGE, mainBuffer);
|
||||
mainBuffer.add('function ${namer.isolateName}()$_{}\n');
|
||||
mainBuffer.add('init()$N$n');
|
||||
|
@ -3173,7 +3173,7 @@ if (typeof document !== "undefined" && document.readyState !== "complete") {
|
|||
void emitDeferredPreambleWhenEmpty(CodeBuffer buffer) {
|
||||
if (!buffer.isEmpty) return;
|
||||
|
||||
buffer.write(GENERATED_BY);
|
||||
buffer.write(buildGeneratedBy());
|
||||
|
||||
buffer.write('var old${namer.CURRENT_ISOLATE}$_='
|
||||
'$_${namer.CURRENT_ISOLATE}$N');
|
||||
|
@ -3186,6 +3186,12 @@ if (typeof document !== "undefined" && document.readyState !== "complete") {
|
|||
'$_${namer.isolateName}.prototype$N$n');
|
||||
}
|
||||
|
||||
String buildGeneratedBy() {
|
||||
var suffix = '';
|
||||
if (BUILD_ID != null) suffix = ' version: $BUILD_ID';
|
||||
return '// Generated by dart2js, the Dart to JavaScript compiler$suffix.\n';
|
||||
}
|
||||
|
||||
String buildSourceMap(CodeBuffer buffer, SourceFile compiledFile) {
|
||||
SourceMapBuilder sourceMapBuilder =
|
||||
new SourceMapBuilder(compiler.sourceMapUri);
|
||||
|
@ -3214,10 +3220,6 @@ if (typeof document !== "undefined" && document.readyState !== "complete") {
|
|||
}
|
||||
}
|
||||
|
||||
const String GENERATED_BY = """
|
||||
// Generated by dart2js, the Dart to JavaScript compiler.
|
||||
""";
|
||||
|
||||
const String HOOKS_API_USAGE = """
|
||||
// The code supports the following hooks:
|
||||
// dartPrint(message) - if this function is defined it is called
|
||||
|
|
|
@ -13,6 +13,7 @@ import '../elements/modelx.dart' show FunctionElementX;
|
|||
|
||||
// TODO(ahe): There seems to be a bug in the VM, so we have to hide "js".
|
||||
import '../dart2jslib.dart' hide Selector, TypedSelector, js;
|
||||
import '../dart2js.dart' show BUILD_ID;
|
||||
import '../dart_types.dart';
|
||||
import '../js/js.dart' as jsAst;
|
||||
import '../js/js.dart' show js; // TODO(ahe): VM bug, see above.
|
||||
|
|
Loading…
Reference in a new issue