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

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

Issue 12038038: Add support for specifying SDK version constraints in pubspecs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up a bit. 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
« no previous file with comments | « utils/pub/pubspec.dart ('k') | utils/pub/version.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'dart:async'; 7 import 'dart:async';
8 import 'io.dart'; 8 import 'io.dart';
9 import 'package.dart'; 9 import 'package.dart';
10 import 'pubspec.dart'; 10 import 'pubspec.dart';
11 import 'sdk.dart' as sdk; 11 import 'sdk.dart' as sdk;
12 import 'source.dart'; 12 import 'source.dart';
13 import 'version.dart'; 13 import 'version.dart';
14 14
15 /// A package source that uses libraries from the Dart SDK. 15 /// A package source that uses libraries from the Dart SDK.
16 class SdkSource extends Source { 16 class SdkSource extends Source {
17 final String name = "sdk"; 17 final String name = "sdk";
18 final bool shouldCache = false; 18 final bool shouldCache = false;
19 19
20 /// SDK packages are not individually versioned. Instead, their version is 20 /// SDK packages are not individually versioned. Instead, their version is
21 /// inferred from the revision number of the SDK itself. 21 /// inferred from the revision number of the SDK itself.
22 Future<Pubspec> describe(PackageId id) { 22 Future<Pubspec> describe(PackageId id) {
23 return _getPackagePath(id).then((packageDir) { 23 return _getPackagePath(id).then((packageDir) {
24 // TODO(rnystrom): What if packageDir is null? 24 // TODO(rnystrom): What if packageDir is null?
25 return Package.load(id.name, packageDir, systemCache.sources); 25 return Package.load(id.name, packageDir, systemCache.sources);
26 }).then((package) { 26 }).then((package) {
27 // Ignore the pubspec's version, and use the SDK's. 27 // Ignore the pubspec's version, and use the SDK's.
28 return new Pubspec(id.name, sdk.version, package.pubspec.dependencies); 28 return new Pubspec(id.name, sdk.version, package.pubspec.dependencies,
29 package.pubspec.environment);
29 }); 30 });
30 } 31 }
31 32
32 /// Since all the SDK files are already available locally, installation just 33 /// Since all the SDK files are already available locally, installation just
33 /// involves symlinking the SDK library into the packages directory. 34 /// involves symlinking the SDK library into the packages directory.
34 Future<bool> install(PackageId id, String destPath) { 35 Future<bool> install(PackageId id, String destPath) {
35 return _getPackagePath(id).then((path) { 36 return _getPackagePath(id).then((path) {
36 if (path == null) return new Future<bool>.immediate(false); 37 if (path == null) return new Future<bool>.immediate(false);
37 38
38 return createPackageSymlink(id.name, path, destPath).then( 39 return createPackageSymlink(id.name, path, destPath).then(
39 (_) => true); 40 (_) => true);
40 }); 41 });
41 } 42 }
42 43
43 /// Gets the path in the SDK's "pkg" directory to the directory containing 44 /// Gets the path in the SDK's "pkg" directory to the directory containing
44 /// package [id]. Returns `null` if the package could not be found. 45 /// package [id]. Returns `null` if the package could not be found.
45 Future<String> _getPackagePath(PackageId id) { 46 Future<String> _getPackagePath(PackageId id) {
46 var pkgPath = join(sdk.rootDirectory, "pkg", id.description); 47 var pkgPath = join(sdk.rootDirectory, "pkg", id.description);
47 return dirExists(pkgPath).then((found) => found ? pkgPath : null); 48 return dirExists(pkgPath).then((found) => found ? pkgPath : null);
48 } 49 }
49 } 50 }
OLDNEW
« no previous file with comments | « utils/pub/pubspec.dart ('k') | utils/pub/version.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698