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

Unified Diff: pkg/analyzer/lib/src/generated/bazel.dart

Issue 2401993002: Automatically detect 'blaze' or 'bazel' symlink prefix. (Closed)
Patch Set: Created 4 years, 2 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 | pkg/analyzer/test/generated/bazel_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/bazel.dart
diff --git a/pkg/analyzer/lib/src/generated/bazel.dart b/pkg/analyzer/lib/src/generated/bazel.dart
index 017bd4c98fddfb97d12ab586b6b9a8a0f4202c80..f3d8dd59acea315b64bdfb03763a26433fa51669 100644
--- a/pkg/analyzer/lib/src/generated/bazel.dart
+++ b/pkg/analyzer/lib/src/generated/bazel.dart
@@ -177,11 +177,11 @@ class BazelWorkspace {
* Return `null` if a workspace markers, such as the `WORKSPACE` file, or
* the sibling `READONLY` folder cannot be found.
*
- * The [symlinkPrefix] is the prefix for names of symlinks like `bazel-bin`,
- * `bazel-genfiles`, etc.
+ * Return `null` if the workspace does not have `bazel-genfiles` or
+ * `blaze-genfiles` folders, so we don't know where to search generated files.
*/
static BazelWorkspace find(ResourceProvider provider, String path,
- {String symlinkPrefix: 'bazel', String readonlySuffix}) {
+ {String readonlySuffix}) {
Context context = provider.pathContext;
// Ensure that the path is absolute and normalized.
@@ -203,6 +203,10 @@ class BazelWorkspace {
if (readonlyFolder.exists) {
String root = folder.path;
String readonly = readonlyFolder.path;
+ String symlinkPrefix = _findSymlinkPrefix(provider, root);
+ if (symlinkPrefix == null) {
+ return null;
+ }
return new BazelWorkspace._(
provider,
root,
@@ -215,6 +219,10 @@ class BazelWorkspace {
// Found the WORKSPACE file, must be a non-git workspace.
if (folder.getChildAssumingFile(_WORKSPACE).exists) {
String root = folder.path;
+ String symlinkPrefix = _findSymlinkPrefix(provider, root);
+ if (symlinkPrefix == null) {
+ return null;
+ }
return new BazelWorkspace._(
provider,
root,
@@ -227,4 +235,20 @@ class BazelWorkspace {
folder = parent;
}
}
+
+ /**
+ * Return the symlink prefix for folders `X-bin` or `X-genfiles` by probing
+ * the internal `blaze-genfiles` and `bazel-genfiles`. Return `null` if
+ * neither of the folders exists.
+ */
+ static String _findSymlinkPrefix(ResourceProvider provider, String root) {
+ Context context = provider.pathContext;
+ if (provider.getFolder(context.join(root, 'blaze-genfiles')).exists) {
+ return 'blaze';
+ }
+ if (provider.getFolder(context.join(root, 'bazel-genfiles')).exists) {
+ return 'bazel';
+ }
+ return null;
+ }
}
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/bazel_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698