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

Unified Diff: pkg/docgen/lib/docgen.dart

Issue 148893004: Docgen snapshot needs to use dart-sdk as its SDK root in a downloaded SDK (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also find the root directory more robustly, and tolerate not having MDN docs Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/lib/docgen.dart
diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart
index bb500908213638ded4d20475edf6d514986893cd..024106838cfb91c71975e7a7355fad354d4cd56a 100644
--- a/pkg/docgen/lib/docgen.dart
+++ b/pkg/docgen/lib/docgen.dart
@@ -147,8 +147,13 @@ Future<MirrorSystem> getMirrorSystem(List<Uri> libraries,
if (libraries.isEmpty) throw new StateError('No Libraries.');
// Finds the root of SDK library based off the location of docgen.
+ // We have two different places to look, depending if we're in a development
+ // repo or in a built SDK, either sdk or dart-sdk respectively
var root = _Generator._rootDirectory;
var sdkRoot = path.normalize(path.absolute(path.join(root, 'sdk')));
+ if (!new Directory(sdkRoot).existsSync()) {
+ sdkRoot = path.normalize(path.absolute(path.join(root, 'dart-sdk')));
+ }
_Generator.logger.info('SDK Root: ${sdkRoot}');
return _Generator._analyzeLibraries(libraries, sdkRoot,
packageRoot: packageRoot);
@@ -457,14 +462,28 @@ class _Generator {
}
/// Helper accessor to determine the full pathname of the root of the dart
- /// checkout.
+ /// checkout. We can be in one of three situations:
+ /// 1) Running from pkg/docgen/bin/docgen.dart
+ /// 2) Running from a snapshot in a build,
+ /// e.g. xcodebuild/ReleaseIA32/dart-sdk/bin
+ /// 3) Running from a built distribution,
+ /// e.g. ...somename/dart-sdk/bin/snapshots
static String get _rootDirectory {
var scriptDir = path.absolute(path.dirname(Platform.script.toFilePath()));
var root = scriptDir;
- while(path.basename(root) != 'dart') {
+ var base = path.basename(root);
+ // When we find dart-sdk or sdk we are one level below the root.
+ while (base != 'dart-sdk' && base != 'sdk' && base != 'pkg') {
root = path.dirname(root);
+ base = path.basename(root);
+ if (root == base) {
+ // We have reached the root of the filesystem without finding anything.
+ throw new FileSystemException(
+ "Cannot find SDK directory starting from ",
+ scriptDir);
+ }
}
- return root;
+ return path.dirname(root);
}
/// Analyzes set of libraries and provides a mirror system which can be used
@@ -1520,7 +1539,13 @@ abstract class OwnedIndexable extends Indexable {
// Reading in MDN related json file.
var root = _Generator._rootDirectory;
var mdnPath = path.join(root, 'utils/apidoc/mdn/database.json');
- Indexable._mdn = JSON.decode(new File(mdnPath).readAsStringSync());
+ var mdnFile = new File(mdnPath);
+ if (mdnFile.existsSync()) {
+ Indexable._mdn = JSON.decode(mdnFile.readAsStringSync());
+ } else {
+ _Generator.logger.warning("Cannot find MDN docs expected at $mdnPath");
+ Indexable._mdn = {};
+ }
}
var domAnnotation = this.annotations.firstWhere(
(e) => e.mirror.qualifiedName == 'metadata.DomName',
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698