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

Side by Side Diff: pkg/docgen/lib/src/package_helpers.dart

Issue 737033002: Let docgen detect a dart-sdk directory that's differently named, and do it correctly on bleeding ed… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: A much better implementation, actually use the --sdk value Created 6 years, 1 month 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 | « pkg/docgen/lib/src/generator.dart ('k') | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 docgen.package_helpers; 5 library docgen.package_helpers;
6 6
7 import 'exports/source_mirrors.dart'; 7 import 'exports/source_mirrors.dart';
8 import 'generator.dart' show pubScript; 8 import 'generator.dart' show pubScript;
9 9
10 import 'dart:io'; 10 import 'dart:io';
11 import 'package:path/path.dart' as path; 11 import 'package:path/path.dart' as path;
12 import 'package:yaml/yaml.dart'; 12 import 'package:yaml/yaml.dart';
13 13
14 /// Helper accessor to determine the full pathname of the root of the dart 14 /// Helper accessor to determine the full pathname of the root of the dart
15 /// checkout. We can be in one of three situations: 15 /// checkout if we are running without the --sdk parameter specified. That
16 /// 1) Running from pkg/docgen/bin/docgen.dart 16 /// normally means we are running directly from source, and we expect to
17 /// 2) Running from a snapshot in a build, 17 /// find the root as the directory above 'pkg'. The only other time this
18 /// e.g. xcodebuild/ReleaseIA32/dart-sdk/bin 18 /// would happen is running a snapshot directly, rather than from the
19 /// 3) Running from a built distribution, 19 /// dartdocgen script, where we look for the dart-sdk directory. If not
20 /// e.g. ...somename/dart-sdk/bin/snapshots 20 /// using the script and not in a normal directory structure, you'll need
21 /// to pass the --sdk parameter.
21 String get rootDirectory { 22 String get rootDirectory {
22 if (_rootDirectoryCache != null) return _rootDirectoryCache; 23 if (_rootDirectoryCache != null) return _rootDirectoryCache;
23 var scriptDir = path.absolute(path.dirname(Platform.script.toFilePath())); 24 var scriptDir = path.absolute(path.dirname(Platform.script.toFilePath()));
24 var root = scriptDir; 25 var root = scriptDir;
25 var base = path.basename(root); 26 var base = path.basename(root);
26 // When we find dart-sdk or sdk we are one level below the root. 27 while (base != 'dart-sdk' && base != 'pkg') {
27 while (base != 'dart-sdk' && base != 'sdk' && base != 'pkg') {
28 root = path.dirname(root); 28 root = path.dirname(root);
29 base = path.basename(root); 29 base = path.basename(root);
30 if (root == base) { 30 if (root == base) {
31 // We have reached the root of the filesystem without finding anything. 31 // We have reached the root of the filesystem without finding anything.
32 throw new FileSystemException("Cannot find SDK directory starting from ", 32 throw new FileSystemException("Cannot find SDK directory starting from ",
33 scriptDir); 33 scriptDir);
34 } 34 }
35 } 35 }
36 _rootDirectoryCache = path.dirname(root); 36 _rootDirectoryCache = path.dirname(root);
37 return _rootDirectoryCache; 37 return _rootDirectoryCache;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 while (!_pubspecFor(dir).existsSync()) { 117 while (!_pubspecFor(dir).existsSync()) {
118 var newDir = path.dirname(dir); 118 var newDir = path.dirname(dir);
119 if (newDir == dir) return null; 119 if (newDir == dir) return null;
120 dir = newDir; 120 dir = newDir;
121 } 121 }
122 return dir; 122 return dir;
123 } 123 }
124 124
125 File _pubspecFor(String directoryName) => 125 File _pubspecFor(String directoryName) =>
126 new File(path.join(directoryName, 'pubspec.yaml')); 126 new File(path.join(directoryName, 'pubspec.yaml'));
OLDNEW
« no previous file with comments | « pkg/docgen/lib/src/generator.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698