Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: pkg/fletchc/lib/src/guess_configuration.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/fletchc/lib/src/function_codegen.dart ('k') | pkg/fletchc/lib/src/hub/client_commands.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dartino 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.md file.
4
5 library fletchc.src.guess_configuration;
6
7 import 'dart:io' show
8 File,
9 Link,
10 Platform,
11 Process;
12
13 const String _FLETCH_VM = const String.fromEnvironment("fletch-vm");
14
15 Uri get executable {
16 return Uri.base.resolveUri(new Uri.file(Platform.resolvedExecutable));
17 }
18
19 bool _looksLikeFletchVm(Uri uri) {
20 return new File.fromUri(uri).existsSync();
21 }
22
23 // TODO(zerny): Guessing the VM path should only happen once and only if no
24 // prior configuration has happend. Make this a private method in
25 // fletch_compiler.dart
26 Uri guessFletchVm(Uri fletchVm, {bool mustExist: true}) {
27 if (fletchVm == null && _FLETCH_VM != null) {
28 // Use Uri.base here because _FLETCH_VM is a constant relative to the
29 // location of where the Dart VM was started, not relative to the C++
30 // client.
31 fletchVm = Uri.base.resolve(_FLETCH_VM);
32 } else {
33 Uri uri = executable.resolve('fletch-vm');
34 if (new File.fromUri(uri).existsSync()) {
35 fletchVm = uri;
36 }
37 }
38 if (fletchVm == null) {
39 if (!mustExist) return null;
40 throw new StateError("""
41 Unable to guess the location of the fletch VM (fletchVm).
42 Try adding command-line option '-Dfletch-vm=<path to fletch VM>.""");
43 } else if (!_looksLikeFletchVm(fletchVm)) {
44 if (!mustExist) return null;
45 throw new StateError("""
46 No fletch VM at '$fletchVm'.
47 Try adding command-line option '-Dfletch-vm=<path to fletch VM>.""");
48 }
49 return fletchVm;
50 }
51
52 String _cachedFletchVersion;
53
54 String get fletchVersion {
55 if (_cachedFletchVersion != null) return _cachedFletchVersion;
56 _cachedFletchVersion = const String.fromEnvironment('fletch.version');
57 if (_cachedFletchVersion != null) return _cachedFletchVersion;
58 Uri fletchVm = guessFletchVm(null, mustExist: false);
59 if (fletchVm != null) {
60 String vmPath = fletchVm.toFilePath();
61 return _cachedFletchVersion =
62 Process.runSync(vmPath, <String>["--version"]).stdout.trim();
63 }
64 return _cachedFletchVersion = "version information not available";
65 }
OLDNEW
« no previous file with comments | « pkg/fletchc/lib/src/function_codegen.dart ('k') | pkg/fletchc/lib/src/hub/client_commands.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698