| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('minfrogc'); | 5 #library('minfrogc'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 #import('file_system_vm.dart'); | 8 #import('file_system_vm.dart'); |
| 9 #import('lang.dart'); | 9 #import('lang.dart'); |
| 10 | 10 |
| 11 main() { | 11 main() { |
| 12 List<String> argv = (new Options()).arguments; | 12 List<String> argv = (new Options()).arguments; |
| 13 if (!internalMain(argv)) { |
| 14 print("Compilation failed"); |
| 15 exit(1); |
| 16 } |
| 17 } |
| 13 | 18 |
| 19 bool internalMain(List<String> argv) { |
| 14 // Infer --out if there is none defined. | 20 // Infer --out if there is none defined. |
| 15 var outFileDefined = false; | 21 var outFileDefined = false; |
| 16 for (var arg in argv) { | 22 for (var arg in argv) { |
| 17 if (arg.startsWith('--out=')) outFileDefined = true; | 23 if (arg.startsWith('--out=')) outFileDefined = true; |
| 18 } | 24 } |
| 19 | 25 |
| 20 if (!outFileDefined) { | 26 if (!outFileDefined) { |
| 21 argv.insertRange(0, 1, "--out=${argv[argv.length-1]}.js"); | 27 argv.insertRange(0, 1, "--out=${argv[argv.length-1]}.js"); |
| 22 } | 28 } |
| 23 | 29 |
| 24 // TODO(dgrove) we're simulating node by placing the arguments to frogc | 30 // TODO(dgrove) we're simulating node by placing the arguments to frogc |
| 25 // starting at index 2. | 31 // starting at index 2. |
| 26 argv.insertRange(0, 2, null); | 32 argv.insertRange(0, 2, null); |
| 27 | 33 |
| 28 // TODO(dgrove) Until we have a way of getting the executable's path, we'll | 34 // TODO(dgrove) Until we have a way of getting the executable's path, we'll |
| 29 // run from '.' | 35 // run from '.' |
| 30 var homedir = (new File('.')).fullPathSync(); | 36 var homedir = (new File('.')).fullPathSync(); |
| 31 | 37 |
| 32 if (!compile(homedir, argv, new VMFileSystem())) { | 38 return compile(homedir, argv, new VMFileSystem()); |
| 33 print("Compilation failed"); | 39 } |
| 34 exit(1); | |
| 35 } | |
| 36 } | |
| OLD | NEW |