OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, 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 library precompiler; | |
6 | |
7 import 'dart:io'; | |
8 | |
9 void run(String executable, String arguments, [String workingDirectory]) { | |
10 print("+ $executable ${arguments.join(' ')}"); | |
11 var result = Process.runSync(executable, arguments, | |
12 workingDirectory: workingDirectory); | |
13 stdout.write(result.stdout); | |
14 stderr.write(result.stderr); | |
15 if (result.exitCode != 0) { | |
16 exit(result.exitCode); | |
17 } | |
18 } | |
19 | |
20 void main(List<String> args) { | |
21 var configuration = Platform.environment["DART_CONFIGURATION"]; | |
22 | |
23 var cc, cc_flags, shared, libname; | |
24 if (Platform.isLinux) { | |
25 cc = 'gcc'; | |
26 shared = '-shared'; | |
27 libname = 'libprecompiled.so'; | |
28 } else if (Platform.isMacOS) { | |
29 cc = 'clang'; | |
30 shared = '-dynamiclib'; | |
31 libname = 'libprecompiled.dylib'; | |
32 } else { | |
33 print("Test only supports Linux and Mac"); | |
34 return; | |
35 } | |
36 | |
37 if (configuration.endsWith("X64")) { | |
38 cc_flags = "-m64"; | |
39 } else if (configuration.endsWith("SIMARM64")) { | |
40 cc_flags = "-m64"; | |
41 } else if (configuration.endsWith("SIMARM")) { | |
42 cc_flags = "-m32"; | |
43 } else if (configuration.endsWith("SIMMIPS")) { | |
44 cc_flags = "-m32"; | |
45 } else if (configuration.endsWith("ARM")) { | |
46 cc_flags = ""; | |
47 } else if (configuration.endsWith("MIPS")) { | |
48 cc_flags = "-EL"; | |
49 } else { | |
50 print("Architecture not supported: $configuration"); | |
51 return; | |
52 } | |
53 | |
54 var tmpDir; | |
55 for (var arg in args) { | |
56 if (arg.startsWith("--gen-precompiled-snapshot")) { | |
57 tmpDir = arg.substring("--gen-precompiled-snapshot".length + 1); | |
58 } | |
59 } | |
60 print("Using directory $tmpDir"); | |
61 | |
62 run(args[0], args.sublist(1)); | |
63 run(cc, [shared, cc_flags, "-o", libname, "precompiled.S"], tmpDir); | |
64 } | |
OLD | NEW |