Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library('minfrog'); | 5 #library('minfrog'); |
| 6 | 6 |
| 7 #import('lib/node/node.dart'); | 7 #import('lib/node/node.dart'); |
| 8 #import('file_system_node.dart'); | 8 #import('file_system_node.dart'); |
| 9 #import('lang.dart'); | 9 #import('lang.dart'); |
| 10 | 10 |
| 11 void main() { | 11 void main() { |
| 12 // Get the home directory from our executable. | 12 // Get the home directory from our executable. |
| 13 var homedir = path.dirname(fs.realpathSync(process.argv[1])); | 13 var homedir = path.dirname(fs.realpathSync(process.argv[1])); |
| 14 | 14 |
| 15 // Note: we create a copy of argv here because the one that is passed in is | 15 // Note: we create a copy of argv here because the one that is passed in is |
| 16 // potentially a JS Array object from outside the sandbox. Hence it will have | 16 // potentially a JS Array object from outside the sandbox. Hence it will have |
| 17 // the wrong prototype. | 17 // the wrong prototype. |
| 18 var argv = new List.from(process.argv); | 18 var argv = new List.from(process.argv); |
| 19 | 19 |
| 20 if (compile(homedir, argv, new NodeFileSystem())) { | 20 if (compile(homedir, argv, new NodeFileSystem())) { |
| 21 if (options.outfile !== null) { | |
|
Jennifer Messerly
2011/12/06 22:50:03
I won't add this message unless doing "compileOnly
Siggi Cherem (dart-lang)
2011/12/06 23:37:38
The other opinion I heard earlier today was that p
| |
| 22 print('Compilation succeded. Code generated in ${options.outfile}'); | |
| 23 } else { | |
| 24 print('Compilation succeded.'); | |
| 25 } | |
| 21 var code = world.getGeneratedCode(); | 26 var code = world.getGeneratedCode(); |
| 22 if (!options.compileOnly) { | 27 if (!options.compileOnly) { |
| 23 process.argv = [argv[0], argv[1]]; | 28 process.argv = [argv[0], argv[1]]; |
| 24 process.argv.addAll(options.childArgs); | 29 process.argv.addAll(options.childArgs); |
| 25 // TODO(jmesserly): we shouldn't force the child process to patch argv. | 30 // TODO(jmesserly): we shouldn't force the child process to patch argv. |
| 26 // Instead, we should be injecting code into the child to fix argv's | 31 // Instead, we should be injecting code into the child to fix argv's |
| 27 // prototype (and possible the proto of require, process, and console). | 32 // prototype (and possible the proto of require, process, and console). |
| 28 vm.runInNewContext(code, createSandbox()); | 33 vm.runInNewContext(code, createSandbox()); |
| 29 } | 34 } |
| 30 } else { | 35 } else { |
| 31 process.exit(1); | 36 process.exit(1); |
| 32 } | 37 } |
| 33 } | 38 } |
| OLD | NEW |