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

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

Issue 10689169: Use environment variables to find the Dart SDK and the Pub cache directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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
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.
Bob Nystrom 2012/07/12 16:49:27 Remove this TODO.
nweiz 2012/07/12 18:44:30 Done.
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 String get rootDir() {
28 if (_rootDir != null) return _rootDir;
29 throw "Pub can't find the Dart SDK. Please set the DART_SDK environment "
Bob Nystrom 2012/07/12 16:49:27 Instead of checking here, why not having the const
nweiz 2012/07/12 18:44:30 We want pub to work without DART_SDK if it doesn't
Bob Nystrom 2012/07/12 21:07:57 OK, cool.
30 "variable to the Dart SDK directory.";
31 }
32
33 SdkSource(this._rootDir);
28 34
29 /** 35 /**
30 * An SDK package has no dependencies. Its version number is inferred from the 36 * An SDK package has no dependencies. Its version number is inferred from the
31 * revision number of the SDK itself. 37 * revision number of the SDK itself.
32 */ 38 */
33 Future<Pubspec> describe(PackageId id) { 39 Future<Pubspec> describe(PackageId id) {
34 return readTextFile(join(rootDir, "revision")).transform((revision) => 40 return readTextFile(join(rootDir, "revision")).transform((revision) =>
35 new Pubspec("0.0.0-r.${revision.trim()}", <PackageRef>[])); 41 new Pubspec("0.0.0-r.${revision.trim()}", <PackageRef>[]));
36 } 42 }
37 43
38 /** 44 /**
39 * Since all the SDK files are already available locally, installation just 45 * Since all the SDK files are already available locally, installation just
40 * involves symlinking the SDK library into the packages directory. 46 * involves symlinking the SDK library into the packages directory.
41 */ 47 */
42 Future<bool> install(PackageId id, String destPath) { 48 Future<bool> install(PackageId id, String destPath) {
43 var sourcePath = join(rootDir, "lib", id.description); 49 var sourcePath = join(rootDir, "lib", id.description);
44 return exists(sourcePath).chain((exists) { 50 return exists(sourcePath).chain((exists) {
45 if (!exists) return new Future<bool>.immediate(false); 51 if (!exists) return new Future<bool>.immediate(false);
46 return createSymlink(sourcePath, destPath).transform((_) => true); 52 return createSymlink(sourcePath, destPath).transform((_) => true);
47 }); 53 });
48 } 54 }
49 } 55 }
OLDNEW
« utils/pub/pub.dart ('K') | « utils/pub/pub.dart ('k') | utils/tests/pub/pub_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698