OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library fletchc.fletch_compiler; | 5 library fletchc.fletch_compiler; |
6 | 6 |
7 import 'dart:async' show | 7 import 'dart:async' show |
8 Future; | 8 Future; |
9 | 9 |
10 import 'dart:convert' show | 10 import 'dart:convert' show |
(...skipping 16 matching lines...) Expand all Loading... | |
27 | 27 |
28 import 'package:compiler/src/filenames.dart' show | 28 import 'package:compiler/src/filenames.dart' show |
29 appendSlash; | 29 appendSlash; |
30 | 30 |
31 import 'src/fletch_native_descriptor.dart' show | 31 import 'src/fletch_native_descriptor.dart' show |
32 FletchNativeDescriptor; | 32 FletchNativeDescriptor; |
33 | 33 |
34 import 'src/fletch_backend.dart' show | 34 import 'src/fletch_backend.dart' show |
35 FletchBackend; | 35 FletchBackend; |
36 | 36 |
37 import 'package:compiler/src/apiimpl.dart' as apiimpl; | 37 import 'package:compiler/src/apiimpl.dart' as apiimpl; |
ahe
2015/12/01 10:12:12
I'd change this to:
import 'package:compiler/src/
sigurdm
2015/12/03 14:48:09
Done.
| |
38 | 38 |
39 import 'src/fletch_compiler_implementation.dart' show | 39 import 'src/fletch_compiler_implementation.dart' show |
40 FletchCompilerImplementation, | 40 FletchCompilerImplementation, |
41 OutputProvider; | 41 OutputProvider; |
42 | 42 |
43 import 'fletch_system.dart'; | 43 import 'fletch_system.dart'; |
44 | 44 |
45 import 'incremental/fletchc_incremental.dart' show | 45 import 'incremental/fletchc_incremental.dart' show |
46 IncrementalCompiler, | 46 IncrementalCompiler, |
47 IncrementalMode; | 47 IncrementalMode; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 return "Client"; | 115 return "Client"; |
116 case Category.server: | 116 case Category.server: |
117 return "Server"; | 117 return "Server"; |
118 case Category.embedded: | 118 case Category.embedded: |
119 return "Embedded"; | 119 return "Embedded"; |
120 } | 120 } |
121 }).join(","); | 121 }).join(","); |
122 options.add("--categories=$categoriesOptionValue"); | 122 options.add("--categories=$categoriesOptionValue"); |
123 } | 123 } |
124 | 124 |
125 final bool isVerbose = apiimpl.Compiler.hasOption(options, '--verbose'); | 125 final bool isVerbose = apiimpl.CompilerImpl.hasOption(options, '--verbose'); |
126 | 126 |
127 if (provider == null) { | 127 if (provider == null) { |
128 provider = new CompilerSourceFileProvider() | 128 provider = new CompilerSourceFileProvider() |
129 ..cwd = base; | 129 ..cwd = base; |
130 } | 130 } |
131 | 131 |
132 if (handler == null) { | 132 if (handler == null) { |
133 SourceFileProvider sourceFileProvider = null; | 133 SourceFileProvider sourceFileProvider = null; |
134 if (provider is SourceFileProvider) { | 134 if (provider is SourceFileProvider) { |
135 sourceFileProvider = provider; | 135 sourceFileProvider = provider; |
136 } | 136 } |
137 handler = new FormattingDiagnosticHandler(sourceFileProvider) | 137 handler = new FormattingDiagnosticHandler(sourceFileProvider) |
138 ..throwOnError = false | 138 ..throwOnError = false |
139 ..verbose = isVerbose; | 139 ..verbose = isVerbose; |
140 } | 140 } |
141 | 141 |
142 if (outputProvider == null) { | 142 if (outputProvider == null) { |
143 outputProvider = new OutputProvider(); | 143 outputProvider = new OutputProvider(); |
144 } | 144 } |
145 | 145 |
146 if (libraryRoot == null && _LIBRARY_ROOT != null) { | 146 if (libraryRoot == null && _LIBRARY_ROOT != null) { |
147 libraryRoot = executable.resolve(appendSlash(_LIBRARY_ROOT)); | 147 libraryRoot = executable.resolve(appendSlash(_LIBRARY_ROOT)); |
148 } | 148 } |
149 libraryRoot = _computeValidatedUri( | 149 libraryRoot = _computeValidatedUri( |
150 libraryRoot, name: 'libraryRoot', ensureTrailingSlash: true, | 150 libraryRoot, name: 'libraryRoot', ensureTrailingSlash: true, |
151 base: base); | 151 base: base); |
152 if (libraryRoot == null) { | 152 if (libraryRoot == null) { |
153 libraryRoot = _guessLibraryRoot(); | 153 libraryRoot = _guessLibraryRoot(); |
154 if (libraryRoot == null) { | 154 if (libraryRoot == null) { |
155 throw new StateError(""" | 155 throw new StateError(""" |
156 Unable to guess the location of the Dart SDK (libraryRoot). | 156 Unable to guess the location of the Dart SDK (libraryRoot). |
(...skipping 12 matching lines...) Expand all Loading... | |
169 if (script != null) { | 169 if (script != null) { |
170 packageConfig = script.resolve('.packages'); | 170 packageConfig = script.resolve('.packages'); |
171 } else { | 171 } else { |
172 packageConfig = base.resolve('.packages'); | 172 packageConfig = base.resolve('.packages'); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 fletchVm = guessFletchVm( | 176 fletchVm = guessFletchVm( |
177 _computeValidatedUri(fletchVm, name: 'fletchVm', base: base)); | 177 _computeValidatedUri(fletchVm, name: 'fletchVm', base: base)); |
178 | 178 |
179 if (patchRoot == null && _PATCH_ROOT != null) { | 179 if (patchRoot == null && _PATCH_ROOT != null) { |
180 patchRoot = executable.resolve(appendSlash(_PATCH_ROOT)); | 180 patchRoot = executable.resolve(appendSlash(_PATCH_ROOT)); |
181 } | 181 } |
182 patchRoot = _computeValidatedUri( | 182 patchRoot = _computeValidatedUri( |
183 patchRoot, name: 'patchRoot', ensureTrailingSlash: true, base: base); | 183 patchRoot, name: 'patchRoot', ensureTrailingSlash: true, base: base); |
184 if (patchRoot == null) { | 184 if (patchRoot == null) { |
185 patchRoot = _guessPatchRoot(libraryRoot); | 185 patchRoot = _guessPatchRoot(libraryRoot); |
186 if (patchRoot == null) { | 186 if (patchRoot == null) { |
187 throw new StateError(""" | 187 throw new StateError(""" |
188 Unable to guess the location of the fletch patch files (patchRoot). | 188 Unable to guess the location of the fletch patch files (patchRoot). |
189 Try adding command-line option '-Dfletch-patch-root=<path to fletch patch>."""); | 189 Try adding command-line option '-Dfletch-patch-root=<path to fletch patch>."""); |
190 } | 190 } |
191 } else if (!_looksLikePatchRoot(patchRoot)) { | 191 } else if (!_looksLikePatchRoot(patchRoot)) { |
192 throw new ArgumentError( | 192 throw new ArgumentError( |
193 "[patchRoot]: Fletch patches not found in '$patchRoot'."); | 193 "[patchRoot]: Fletch patches not found in '$patchRoot'."); |
194 } | 194 } |
195 | 195 |
196 if (environment == null) { | 196 if (environment == null) { |
197 environment = <String, dynamic>{}; | 197 environment = <String, dynamic>{}; |
198 } | 198 } |
199 | 199 |
200 if (nativesJson == null && _NATIVES_JSON != null) { | 200 if (nativesJson == null && _NATIVES_JSON != null) { |
201 nativesJson = base.resolve(_NATIVES_JSON); | 201 nativesJson = base.resolve(_NATIVES_JSON); |
202 } | 202 } |
203 nativesJson = _computeValidatedUri( | 203 nativesJson = _computeValidatedUri( |
204 nativesJson, name: 'nativesJson', base: base); | 204 nativesJson, name: 'nativesJson', base: base); |
205 | 205 |
206 if (nativesJson == null) { | 206 if (nativesJson == null) { |
207 nativesJson = _guessNativesJson(); | 207 nativesJson = _guessNativesJson(); |
208 if (nativesJson == null) { | 208 if (nativesJson == null) { |
209 throw new StateError( | 209 throw new StateError( |
210 """ | 210 """ |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 _compiler.context.nativeDescriptors = natives; | 267 _compiler.context.nativeDescriptors = natives; |
268 _compiler.context.setNames(names); | 268 _compiler.context.setNames(names); |
269 } | 269 } |
270 | 270 |
271 Uri get fletchVm => _compiler.fletchVm; | 271 Uri get fletchVm => _compiler.fletchVm; |
272 | 272 |
273 /// Create a new instance of [IncrementalCompiler]. | 273 /// Create a new instance of [IncrementalCompiler]. |
274 IncrementalCompiler newIncrementalCompiler( | 274 IncrementalCompiler newIncrementalCompiler( |
275 IncrementalMode support, | 275 IncrementalMode support, |
276 {List<String> options: const <String>[]}) { | 276 {List<String> options: const <String>[]}) { |
277 // TODO(sigurdm): Remove this hack. | |
278 Uri correctedLibraryRoot = _compiler.libraryRoot.resolve(".."); | |
277 return new IncrementalCompiler( | 279 return new IncrementalCompiler( |
278 libraryRoot: _compiler.libraryRoot, | 280 libraryRoot: correctedLibraryRoot, |
279 patchRoot: _compiler.patchRoot, | 281 patchRoot: _compiler.patchRoot, |
280 packageConfig: _compiler.packageConfig, | 282 packageConfig: _compiler.packageConfig, |
281 fletchVm: _compiler.fletchVm, | 283 fletchVm: _compiler.fletchVm, |
282 nativesJson: _compiler.nativesJson, | 284 nativesJson: _compiler.nativesJson, |
283 inputProvider: _compiler.provider, | 285 inputProvider: _compiler.provider, |
284 diagnosticHandler: _compiler.handler, | 286 diagnosticHandler: _compiler.handler, |
285 options: options, | 287 options: options, |
286 outputProvider: _compiler.userOutputProvider, | 288 outputProvider: _compiler.userOutputProvider, |
287 environment: _compiler.environment, | 289 environment: _compiler.environment, |
288 categories: categories, | 290 categories: categories, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 } | 386 } |
385 | 387 |
386 bool _looksLikeNativesJson(Uri uri) { | 388 bool _looksLikeNativesJson(Uri uri) { |
387 return new File.fromUri(uri).existsSync(); | 389 return new File.fromUri(uri).existsSync(); |
388 } | 390 } |
389 | 391 |
390 Uri _guessNativesJson() { | 392 Uri _guessNativesJson() { |
391 Uri uri = executable.resolve('natives.json'); | 393 Uri uri = executable.resolve('natives.json'); |
392 return _looksLikeNativesJson(uri) ? uri : null; | 394 return _looksLikeNativesJson(uri) ? uri : null; |
393 } | 395 } |
OLD | NEW |