OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 import 'package:args/args.dart' as args; | 8 import 'package:args/args.dart' as args; |
9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
10 | 10 |
11 args.ArgParser parser = new args.ArgParser(allowTrailingOptions: true) | 11 args.ArgParser parser = new args.ArgParser(allowTrailingOptions: true) |
12 ..addOption("sdk", | 12 ..addOption("sdk", |
13 abbr: "s", | 13 abbr: "s", |
14 help: "Path to the Dart SDK. By default it will be searched at the path\n" | 14 help: "Path to the Dart SDK. By default it will be searched at the path\n" |
15 "'../../../out/ReleaseX64/patched_sdk' relative to the directory\n" | 15 "'../../../out/ReleaseX64/patched_sdk' relative to the directory\n" |
16 "of 'reified_dart'.", | 16 "of 'reified_dart'.", |
17 defaultsTo: null) | 17 defaultsTo: null) |
18 ..addOption("dartk", | 18 ..addOption("dartk", |
19 abbr: "k", | 19 abbr: "k", |
20 help: "Path to 'dartk' executable. By default it will be searched for\n" | 20 help: "Path to 'dartk' executable. By default it will be searched for\n" |
21 "in the same directory as 'reified_dart'.", | 21 "in the tool directory of the kernel package.", |
22 defaultsTo: null) | 22 defaultsTo: null) |
23 ..addOption("dill-output", | 23 ..addOption("dill-output", |
24 abbr: "d", | 24 abbr: "d", |
25 help: "Path to intermediate reified .dill file. If not specified,\n" | 25 help: "Path to intermediate reified .dill file. If not specified,\n" |
26 "the intermediate file is created in a temporary location\n" | 26 "the intermediate file is created in a temporary location\n" |
27 "and is removed after program execution.", | 27 "and is removed after program execution.", |
28 defaultsTo: null); | 28 defaultsTo: null); |
29 | 29 |
30 String getUsage() => """ | 30 String getUsage() => """ |
31 Usage: reified_dart [options] FILE | 31 Usage: reified_dart [options] FILE |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 checkIsDirectory(sdkPath, | 90 checkIsDirectory(sdkPath, |
91 option: "Path to Dart SDK", | 91 option: "Path to Dart SDK", |
92 description: "The --sdk option wasn't specified, " | 92 description: "The --sdk option wasn't specified, " |
93 "so default location was checked."); | 93 "so default location was checked."); |
94 | 94 |
95 return sdkPath; | 95 return sdkPath; |
96 } | 96 } |
97 | 97 |
98 String getDefaultDartk() { | 98 String getDefaultDartk() { |
99 String currentFile = Platform.script.toFilePath(); | 99 String currentFile = Platform.script.toFilePath(); |
100 String dartkPath = path.join(path.dirname(currentFile), "dartk.dart"); | 100 String dartkPath = path.join(path.dirname(currentFile), "../tool/dartk.dart"); |
101 | 101 |
102 checkIsFile(dartkPath, | 102 checkIsFile(dartkPath, |
103 option: "Path to 'dartk'", | 103 option: "Path to 'dartk'", |
104 description: "The --dartk option wasn't specified, " | 104 description: "The --dartk option wasn't specified, " |
105 "so default location was checked."); | 105 "so default location was checked."); |
106 | 106 |
107 return dartkPath; | 107 return dartkPath; |
108 } | 108 } |
109 | 109 |
110 main(List<String> arguments) async { | 110 main(List<String> arguments) async { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 stdout.write(result.stdout); | 166 stdout.write(result.stdout); |
167 stderr.write(result.stderr); | 167 stderr.write(result.stderr); |
168 tempFile?.parent?.delete(recursive: true); | 168 tempFile?.parent?.delete(recursive: true); |
169 if (result.exitCode != 0) { | 169 if (result.exitCode != 0) { |
170 stderr.writeln("ERROR: execution of 'dart' failed with exit code " | 170 stderr.writeln("ERROR: execution of 'dart' failed with exit code " |
171 "${result.exitCode}"); | 171 "${result.exitCode}"); |
172 exit(result.exitCode); | 172 exit(result.exitCode); |
173 } | 173 } |
174 } | 174 } |
OLD | NEW |