| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Operations relative to the user's installed Dart SDK. | 5 /// Operations relative to the user's installed Dart SDK. |
| 6 library pub.sdk; | 6 library pub.sdk; |
| 7 | 7 |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
| 11 import 'package:pub_semver/pub_semver.dart'; | 11 import 'package:pub_semver/pub_semver.dart'; |
| 12 | 12 |
| 13 import 'io.dart'; | 13 import 'io.dart'; |
| 14 | 14 |
| 15 /// The path to the root directory of the SDK. | 15 /// The path to the root directory of the SDK. |
| 16 /// | 16 /// |
| 17 /// Note that if pub is running from source within the Dart repo (for example | 17 /// Note that if pub is running from source within the Dart repo (for example |
| 18 /// when building Observatory), this will be the repo's "sdk/" directory, which | 18 /// when building Observatory), this will be the repo's "sdk/" directory, which |
| 19 /// doesn't look exactly like the built SDK. | 19 /// doesn't look exactly like the built SDK. |
| 20 final String rootDirectory = (() { | 20 final String rootDirectory = (() { |
| 21 if (runningFromDartRepo) return p.join(dartRepoRoot, 'sdk'); | 21 if (runningFromDartRepo) return p.join(dartRepoRoot, 'sdk'); |
| 22 | 22 |
| 23 var dartSdk = Platform.environment["DART_SDK"]; | |
| 24 if (dartSdk != null) return dartSdk; | |
| 25 | |
| 26 // The Dart exectuable is in "/path/to/sdk/bin/dart", so two levels up is | 23 // The Dart exectuable is in "/path/to/sdk/bin/dart", so two levels up is |
| 27 // "/path/to/sdk". | 24 // "/path/to/sdk". |
| 28 var aboveExecutable = p.dirname(p.dirname(Platform.executable)); | 25 var aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable)); |
| 29 assert(fileExists(p.join(aboveExecutable, 'version'))); | 26 assert(fileExists(p.join(aboveExecutable, 'version'))); |
| 30 return aboveExecutable; | 27 return aboveExecutable; |
| 31 })(); | 28 })(); |
| 32 | 29 |
| 33 /// The SDK's revision number formatted to be a semantic version. | 30 /// The SDK's revision number formatted to be a semantic version. |
| 34 /// | 31 /// |
| 35 /// This can be set so that the version solver tests can artificially select | 32 /// This can be set so that the version solver tests can artificially select |
| 36 /// different SDK versions. | 33 /// different SDK versions. |
| 37 Version version = _getVersion(); | 34 Version version = _getVersion(); |
| 38 | 35 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 var version = "$major.$minor.$patch"; | 67 var version = "$major.$minor.$patch"; |
| 71 if (channel == "be") { | 68 if (channel == "be") { |
| 72 // TODO(rnystrom): tools/utils.py includes the svn commit here. Should we? | 69 // TODO(rnystrom): tools/utils.py includes the svn commit here. Should we? |
| 73 version += "-edge"; | 70 version += "-edge"; |
| 74 } else if (channel == "dev") { | 71 } else if (channel == "dev") { |
| 75 version += "-dev.$prerelease.$prereleasePatch"; | 72 version += "-dev.$prerelease.$prereleasePatch"; |
| 76 } | 73 } |
| 77 | 74 |
| 78 return new Version.parse(version); | 75 return new Version.parse(version); |
| 79 } | 76 } |
| OLD | NEW |