| 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 var code = world.getGeneratedCode(); | 21 var code = world.getGeneratedCode(); |
| 22 if (!options.compileOnly) { | 22 if (options.compileOnly) { |
| 23 if (options.outfile !== null) { |
| 24 print('Compilation succeded. Code generated in: ${options.outfile}'); |
| 25 } else { |
| 26 print('Compilation succeded.'); |
| 27 } |
| 28 } else { |
| 23 process.argv = [argv[0], argv[1]]; | 29 process.argv = [argv[0], argv[1]]; |
| 24 process.argv.addAll(options.childArgs); | 30 process.argv.addAll(options.childArgs); |
| 25 // TODO(jmesserly): we shouldn't force the child process to patch argv. | 31 // 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 | 32 // Instead, we should be injecting code into the child to fix argv's |
| 27 // prototype (and possible the proto of require, process, and console). | 33 // prototype (and possible the proto of require, process, and console). |
| 28 vm.runInNewContext(code, createSandbox()); | 34 vm.runInNewContext(code, createSandbox()); |
| 29 } | 35 } |
| 30 } else { | 36 } else { |
| 31 process.exit(1); | 37 process.exit(1); |
| 32 } | 38 } |
| 33 } | 39 } |
| OLD | NEW |