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

Unified Diff: utils/pub/sdk.dart

Issue 11871028: Clean up code that locates SDK and SDK version. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/root_source.dart ('k') | utils/pub/sdk/pub » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
+
+/// 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();
+ return new Version.parse("0.0.0-r.${revision.trim()}");
+}
« no previous file with comments | « utils/pub/root_source.dart ('k') | utils/pub/sdk/pub » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698