| 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 #library('sdk_source'); | 5 #library('sdk_source'); |
| 6 | 6 |
| 7 #import('io.dart'); | 7 #import('io.dart'); |
| 8 #import('package.dart'); | 8 #import('package.dart'); |
| 9 #import('source.dart'); | 9 #import('source.dart'); |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * A package source that uses libraries from the Dart SDK. | 12 * A package source that uses libraries from the Dart SDK. |
| 13 * | 13 * |
| 14 * This currently uses the "sdkdir" command-line argument to find the SDK. | 14 * This currently uses the "sdkdir" command-line argument to find the SDK. |
| 15 */ | 15 */ |
| 16 // TODO(nweiz): This should read the SDK directory from an environment variable | 16 // TODO(nweiz): This should read the SDK directory from an environment variable |
| 17 // once we can set those for tests. | 17 // once we can set those for tests. |
| 18 class SdkSource extends Source { | 18 class SdkSource extends Source { |
| 19 final String name = "sdk"; | 19 final String name = "sdk"; |
| 20 final bool shouldCache = false; | 20 final bool shouldCache = false; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * The root directory of the Dart SDK. | 23 * The root directory of the Dart SDK. |
| 24 */ | 24 */ |
| 25 final String rootDir; | 25 final String rootDir; |
| 26 | 26 |
| 27 SdkSource(this.rootDir); | 27 SdkSource(this.rootDir); |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * An SDK package has no dependencies. Its version number is inferred from the |
| 31 * revision number of the SDK itself. |
| 32 */ |
| 33 Future<Pubspec> describe(PackageId id) { |
| 34 return readTextFile(join(rootDir, "revision")).transform((revision) => |
| 35 new Pubspec("0.0.0-r.${revision.trim()}", <PackageRef>[])); |
| 36 } |
| 37 |
| 38 /** |
| 30 * Since all the SDK files are already available locally, installation just | 39 * Since all the SDK files are already available locally, installation just |
| 31 * involves symlinking the SDK library into the packages directory. | 40 * involves symlinking the SDK library into the packages directory. |
| 32 */ | 41 */ |
| 33 Future<bool> install(PackageId id, String destPath) { | 42 Future<bool> install(PackageId id, String destPath) { |
| 34 var sourcePath = join(rootDir, "lib", id.description); | 43 var sourcePath = join(rootDir, "lib", id.description); |
| 35 return exists(sourcePath).chain((exists) { | 44 return exists(sourcePath).chain((exists) { |
| 36 if (!exists) return new Future<bool>.immediate(false); | 45 if (!exists) return new Future<bool>.immediate(false); |
| 37 return createSymlink(sourcePath, destPath).transform((_) => true); | 46 return createSymlink(sourcePath, destPath).transform((_) => true); |
| 38 }); | 47 }); |
| 39 } | 48 } |
| 40 } | 49 } |
| OLD | NEW |