Chromium Code Reviews| Index: utils/pub/sdk.dart |
| diff --git a/utils/pub/sdk.dart b/utils/pub/sdk.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f8db76c173ca4c1a0dc2090b8ae178d5c9ccd560 |
| --- /dev/null |
| +++ b/utils/pub/sdk.dart |
| @@ -0,0 +1,38 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/// Operations relative to the user's installed Dart SDK. |
| +library sdk; |
| + |
| +import 'dart:io'; |
| + |
| +import '../../pkg/path/lib/path.dart' as path; |
| +import 'log.dart' as log; |
| +import 'version.dart'; |
| + |
| +/// Gets the path to the root directory of the SDK. |
| +String get rootDirectory { |
| + // If the environment variable was provided, use it. This is mainly used for |
| + // the pub tests. |
| + var dir = Platform.environment["DART_SDK"]; |
| + if (dir != null) { |
| + log.fine("Using DART_SDK to find SDK at $dir"); |
| + return dir; |
| + } |
| + |
| + var pubDir = path.dirname(new Options().script); |
| + dir = path.normalize(path.join(pubDir, "../../")); |
| + log.fine("Located SDK at $dir"); |
| + 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
|
| +} |
| + |
| +/// Gets the SDK's revision number formatted to be a semantic version. |
| +Version version = _getVersion(); |
| + |
| +/// Determine the SDK revision number. |
| +Version _getVersion() { |
| + var revisionPath = path.join(rootDirectory, "revision"); |
| + 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
|
| + 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
|
| +} |