b2ee421a78
Review URL: https://chromiumcodereview.appspot.com//10690127 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9567 260f80e4-7a28-3924-810f-c04153c831b5
50 lines
1.5 KiB
Dart
50 lines
1.5 KiB
Dart
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#library('sdk_source');
|
|
|
|
#import('io.dart');
|
|
#import('package.dart');
|
|
#import('source.dart');
|
|
|
|
/**
|
|
* A package source that uses libraries from the Dart SDK.
|
|
*
|
|
* This currently uses the "sdkdir" command-line argument to find the SDK.
|
|
*/
|
|
// TODO(nweiz): This should read the SDK directory from an environment variable
|
|
// once we can set those for tests.
|
|
class SdkSource extends Source {
|
|
final String name = "sdk";
|
|
final bool shouldCache = false;
|
|
|
|
/**
|
|
* The root directory of the Dart SDK.
|
|
*/
|
|
final String rootDir;
|
|
|
|
SdkSource(this.rootDir);
|
|
|
|
/**
|
|
* An SDK package has no dependencies. Its version number is inferred from the
|
|
* revision number of the SDK itself.
|
|
*/
|
|
Future<Pubspec> describe(PackageId id) {
|
|
return readTextFile(join(rootDir, "revision")).transform((revision) =>
|
|
new Pubspec("0.0.0-r.${revision.trim()}", <PackageRef>[]));
|
|
}
|
|
|
|
/**
|
|
* Since all the SDK files are already available locally, installation just
|
|
* involves symlinking the SDK library into the packages directory.
|
|
*/
|
|
Future<bool> install(PackageId id, String destPath) {
|
|
var sourcePath = join(rootDir, "lib", id.description);
|
|
return exists(sourcePath).chain((exists) {
|
|
if (!exists) return new Future<bool>.immediate(false);
|
|
return createSymlink(sourcePath, destPath).transform((_) => true);
|
|
});
|
|
}
|
|
}
|