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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW
« pkg/path/lib/path.dart ('K') | « 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