Index: dart/utils/compiler/build_helper.dart |
diff --git a/dart/utils/compiler/build_helper.dart b/dart/utils/compiler/build_helper.dart |
index 04aa0cc48ee5b6cdaf945fdfc4e84e2a26cd51d2..de54347e2a4418b8fc196a78bd2d32b24c7a43dc 100644 |
--- a/dart/utils/compiler/build_helper.dart |
+++ b/dart/utils/compiler/build_helper.dart |
@@ -5,29 +5,40 @@ |
#import('dart:io'); |
#import('dart:uri'); |
+#import('../../lib/compiler/implementation/util/uri_extras.dart'); |
+#import('../../lib/compiler/implementation/filenames.dart'); |
+ |
main() { |
List<String> arguments = new Options().arguments; |
- Uri uri = new Uri(scheme: 'file', path: '${arguments[0]}/'); |
- String dartVmLocation = uri.resolve(arguments[1]).path; |
- Uri productionLauncher = uri.resolve(arguments[2]); |
- Uri developerLauncher = uri.resolve(arguments[3]); |
- String launcherScript = buildScript(uri); |
+ Uri cwd = getCurrentDirectory(); |
+ String productDir = appendSlash(nativeToUriPath(arguments[0])); |
+ String dartVmPath = nativeToUriPath(arguments[1]); |
+ String productionName = nativeToUriPath(arguments[2]); |
+ String developerName = nativeToUriPath(arguments[3]); |
+ String dartDir = appendSlash(nativeToUriPath(arguments[4])); |
+ |
+ Uri dartUri = cwd.resolve(dartDir); |
+ Uri productUri = cwd.resolve(productDir); |
- writeScript(productionLauncher, |
- ['#!$dartVmLocation\n', |
- launcherScript]); |
- writeScript(developerLauncher, |
- ['#!$dartVmLocation --enable_checked_mode\n', |
- launcherScript]); |
+ Uri dartVmUri = productUri.resolve(dartVmPath); |
+ Uri productionUri = productUri.resolve(arguments[2]); |
+ Uri developerUri = productUri.resolve(arguments[3]); |
+ String productionScript = buildScript(dartUri, dartVmUri, ''); |
+ String developerScript = buildScript(dartUri, dartVmUri, |
+ ' --enable_checked_mode'); |
+ |
+ writeScript(productionUri, productionScript); |
+ writeScript(developerUri, developerScript); |
} |
-writeScript(Uri uri, List<String> chunks) { |
- var f = new File(uri.path); |
+writeScript(Uri uri, String script) { |
+ var f = new File(uriPathToNative(uri.path)); |
var stream = f.openSync(FileMode.WRITE); |
- for (String chunk in chunks) { |
- stream.writeStringSync(chunk); |
+ try { |
+ stream.writeStringSync(script); |
+ } finally { |
+ stream.closeSync(); |
} |
- stream.closeSync(); |
// TODO(ahe): Also make a .bat file for Windows. |
@@ -43,11 +54,20 @@ writeScript(Uri uri, List<String> chunks) { |
} |
} |
-buildScript(Uri uri) { |
- String dart2jsPath = |
- uri.resolve('../../lib/compiler/implementation/dart2js.dart').path; |
- String libraryRoot = uri.resolve('../../').path; |
+buildScript(Uri dartUri, Uri dartVmLocation, String options) { |
+ Uri dart2jsUri = dartUri.resolve('lib/compiler/implementation/dart2js.dart'); |
+ String dart2jsPath = relativize(dartVmLocation, dart2jsUri); |
+ String libraryRoot = relativize(dartVmLocation, dartUri); |
+ libraryRoot = uriPathToNative('/../$libraryRoot'); |
+ |
+ print('dartUri = $dartUri'); |
+ print('dartVmLocation = $dartVmLocation'); |
+ print('dart2jsUri = $dart2jsUri'); |
+ print('dart2jsPath = $dart2jsPath'); |
+ print('libraryRoot = $libraryRoot'); |
+ |
return """ |
+#!${dartVmLocation.path}$options |
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
// 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. |
@@ -56,29 +76,25 @@ buildScript(Uri uri) { |
#import('$dart2jsPath'); |
-class Helper { |
- void run() { |
+void main() { |
+ try { |
+ String libraryRoot = @'$libraryRoot'; |
+ String script = new Options().script; |
+ List<String> argv = ['--library-root=\$script\$libraryRoot']; |
+ argv.addAll(new Options().arguments); |
+ compile(argv); |
+ } catch (var exception, var trace) { |
try { |
- List<String> argv = ['--library-root=$libraryRoot']; |
- argv.addAll(new Options().arguments); |
- compile(argv); |
- } catch (var exception, var trace) { |
- try { |
- print('Internal error: \$exception'); |
- } catch (var ignored) { |
- print('Internal error: error while printing exception'); |
- } |
- try { |
- print(trace); |
- } finally { |
- exit(253); // 253 is recognized as a crash by our test scripts. |
- } |
+ print('Internal error: \$exception'); |
+ } catch (var ignored) { |
+ print('Internal error: error while printing exception'); |
+ } |
+ try { |
+ print(trace); |
+ } finally { |
+ exit(253); // 253 is recognized as a crash by our test scripts. |
} |
} |
} |
- |
-void main() { |
- new Helper().run(); |
-} |
"""; |
} |