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 /// Operations relative to the user's installed Dart SDK. | |
6 library sdk; | |
7 | |
8 import 'dart:io'; | |
9 | |
10 import '../../pkg/path/lib/path.dart' as path; | |
11 import 'log.dart' as log; | |
12 import 'version.dart'; | |
13 | |
14 /// Gets the path to the root directory of the SDK. | |
15 String get rootDirectory { | |
16 // If the environment variable was provided, use it. This is mainly used for | |
17 // the pub tests. | |
18 var dir = Platform.environment["DART_SDK"]; | |
19 if (dir != null) { | |
20 log.fine("Using DART_SDK to find SDK at $dir"); | |
21 return dir; | |
22 } | |
23 | |
24 var pubDir = path.dirname(new Options().script); | |
25 dir = path.normalize(path.join(pubDir, "../../")); | |
26 log.fine("Located SDK at $dir"); | |
27 return dir; | |
nweiz
2013/01/19 00:35:47
I wonder if we should do some sanity checks here s
Bob Nystrom
2013/01/22 23:53:19
I don't think we've hit issues with this in the wi
| |
28 } | |
29 | |
30 /// Gets the SDK's revision number formatted to be a semantic version. | |
31 Version version = _getVersion(); | |
32 | |
33 /// Determine the SDK revision number. | |
34 Version _getVersion() { | |
35 var revisionPath = path.join(rootDirectory, "revision"); | |
36 var revision = new File(revisionPath).readAsStringSync(); | |
nweiz
2013/01/19 00:35:47
Oh synchronous file IO, how lovely you are...
Bob Nystrom
2013/01/22 23:53:19
Oh yeah. I thought about making this async and the
| |
37 return new Version.parse("0.0.0-r.${revision.trim()}"); | |
nweiz
2013/01/19 00:35:47
Another place it would be good to do some validati
Bob Nystrom
2013/01/22 23:53:19
Ditto previous comment. I don't mind making this m
| |
38 } | |
OLD | NEW |