Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #import('dart:io'); | |
| 6 #import('dart:uri'); | |
| 7 | |
| 8 main() { | |
| 9 List<String> arguments = new Options().arguments; | |
| 10 Uri uri = new Uri(scheme: 'file', path: '${arguments[0]}/'); | |
| 11 String dartVmLocation = uri.resolve(arguments[1]).path; | |
| 12 String productionLauncherLocation = uri.resolve(arguments[2]).path; | |
| 13 String developerLauncherLocation = uri.resolve(arguments[3]).path; | |
| 14 String productionLaunch = '#!$dartVmLocation\n'; | |
| 15 String developerLaunch = '#!$dartVmLocation --enable_checked_mode\n'; | |
| 16 String launcherScript = """ | |
| 
 
ngeoffray
2012/03/17 16:00:56
Maybe move this variable into its own method: buil
 
ahe
2012/03/17 16:16:46
Next CL.
 
 | |
| 17 | |
| 18 #import('dart:io'); | |
| 19 | |
| 20 #import('${uri.resolve('../../frog/file_system_vm.dart').path}', prefix: 'fs'); | |
| 21 #import('${uri.resolve('../../frog/lang.dart').path}', prefix: 'lang'); | |
| 22 #import('${uri.resolve('../../frog/leg/frog_leg.dart').path}', prefix: 'leg'); | |
| 23 | |
| 24 void main() { | |
| 25 lang.legCompile = leg.compile; | |
| 26 try { | |
| 27 | |
| 28 List<String> argv = (new Options()).arguments; | |
| 29 | |
| 30 // Infer --out if there is none defined. | |
| 31 var outFileDefined = false; | |
| 32 for (var arg in argv) { | |
| 33 if (arg.startsWith('--out=')) outFileDefined = true; | |
| 34 } | |
| 35 | |
| 36 if (!outFileDefined) { | |
| 37 argv.insertRange(0, 1, '--out=' + argv[argv.length-1] + '.js'); | |
| 38 } | |
| 39 | |
| 40 // TODO(dgrove) we're simulating node by placing the arguments to frogc | |
| 41 // starting at index 2. | |
| 42 argv.insertRange(0, 4, null); | |
| 43 | |
| 44 argv[2] = '--leg'; | |
| 45 argv[3] = '--libdir=${uri.resolve('../../frog/lib').path}'; | |
| 46 | |
| 47 // TODO(dgrove) Until we have a way of getting the executable's path, we'll | |
| 48 // run from '.' | |
| 49 var homedir = (new File('.')).fullPathSync(); | |
| 50 | |
| 51 if (!lang.compile(homedir, argv, new fs.VMFileSystem())) { | |
| 52 print('Compilation failed'); | |
| 53 exit(1); | |
| 54 } | |
| 55 } catch (var exception, var trace) { | |
| 56 try { | |
| 57 print('Internal error: \$exception'); | |
| 58 } catch (var ignored) { | |
| 59 print('Internal error: error while printing exception'); | |
| 60 } | |
| 61 try { | |
| 62 print(trace); | |
| 63 } finally { | |
| 
 
ngeoffray
2012/03/17 16:00:56
Please add a comment that 253 is recognized by tes
 
ahe
2012/03/17 16:16:46
Next CL.
 
 | |
| 64 exit(253); | |
| 65 } | |
| 66 } | |
| 67 } | |
| 68 """; | |
| 69 var f = new File(productionLauncherLocation); | |
| 70 var stream = f.openSync(FileMode.WRITE); | |
| 71 stream.writeStringSync(productionLaunch); | |
| 72 stream.writeStringSync(launcherScript); | |
| 73 stream.closeSync(); | |
| 74 f = new File(developerLauncherLocation); | |
| 75 stream = f.openSync(FileMode.WRITE); | |
| 76 stream.writeStringSync(developerLaunch); | |
| 77 stream.writeStringSync(launcherScript); | |
| 78 stream.closeSync(); | |
| 79 // TODO(ahe): Make scripts executable. | |
| 
 
ngeoffray
2012/03/17 16:00:56
Why not doing it now? Are we missing the API?
 
ahe
2012/03/17 16:16:46
I think there is API for running "chmod +x", but I
 
ahe
2012/03/17 16:21:37
Adding a little more insight into my thinking: run
 
 | |
| 80 // TODO(ahe): Also make .bat files for Windows. | |
| 81 } | |
| OLD | NEW |