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

Side by Side Diff: utils/pub/sdk.dart

Issue 14297021: Move pub into sdk/lib/_internal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Disallow package: imports of pub. Created 7 years, 8 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
« no previous file with comments | « utils/pub/safe_http_server.dart ('k') | utils/pub/sdk/pub » ('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) 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 'package:pathos/path.dart' as path;
11
12 import 'io.dart';
13 import 'log.dart' as log;
14 import 'version.dart';
15
16 /// Matches an Eclipse-style SDK version number. This is four dotted numbers
17 /// (major, minor, patch, build) with an optional suffix attached to the build
18 /// number.
19 final _versionPattern = new RegExp(r'^(\d+)\.(\d+)\.(\d+)\.(\d+.*)$');
20
21 /// Gets the path to the root directory of the SDK.
22 String get rootDirectory {
23 // If the environment variable was provided, use it. This is mainly used for
24 // the pub tests.
25 var dir = Platform.environment["DART_SDK"];
26 if (dir != null) {
27 log.fine("Using DART_SDK to find SDK at $dir");
28 return dir;
29 }
30
31 var pubDir = path.dirname(new Options().script);
32 dir = path.normalize(path.join(pubDir, "../../"));
33 log.fine("Located SDK at $dir");
34 return dir;
35 }
36
37 /// Gets the SDK's revision number formatted to be a semantic version.
38 Version version = _getVersion();
39
40 /// Is `true` if the current SDK is an unreleased bleeding edge version.
41 bool get isBleedingEdge {
42 // The live build is locked to the magical old number "0.1.2+<stuff>".
43 return version.major == 0 && version.minor == 1 && version.patch == 2;
44 }
45
46 /// Determine the SDK's version number.
47 Version _getVersion() {
48 var revisionPath = path.join(rootDirectory, "version");
49 var version = readTextFile(revisionPath).trim();
50
51 // Given a version file like: 0.1.2.0_r17495
52 // We create a semver like: 0.1.2+0.r17495
53 var match = _versionPattern.firstMatch(version);
54 if (match == null) {
55 throw new FormatException("The Dart SDK's 'version' file was not in a "
56 "format pub could recognize. Found: $version");
57 }
58
59 // Semantic versions cannot use "_".
60 var build = match[4].replaceAll('_', '.');
61
62 return new Version(
63 int.parse(match[1]), int.parse(match[2]), int.parse(match[3]),
64 build: build);
65 }
OLDNEW
« no previous file with comments | « utils/pub/safe_http_server.dart ('k') | utils/pub/sdk/pub » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698