-
Notifications
You must be signed in to change notification settings - Fork 458
Open
Labels
Description
Currently, it only parses WORKSPACE:
buildtools/wspace/workspace.go
Line 123 in 19c62d9
| ws := filepath.Join(root, workspaceFile) |
This is used for example by edit.InterpretLabel():
Lines 41 to 113 in 19c62d9
| // InterpretLabelForWorkspaceLocation returns the name of the BUILD file to | |
| // edit, the full package name, and the rule. It takes a workspace-rooted | |
| // directory to use. | |
| func InterpretLabelForWorkspaceLocation(root, target string) (buildFile, repo, pkg, rule string) { | |
| label := labels.Parse(target) | |
| repo = label.Repository | |
| pkg = label.Package | |
| rule = label.Target | |
| rootDir, relativePath := wspace.FindWorkspaceRoot(root) | |
| if repo != "" { | |
| files, err := wspace.FindRepoBuildFiles(rootDir) | |
| if err == nil { | |
| if buildFile, ok := files[repo]; ok { | |
| return buildFile, repo, pkg, rule | |
| } | |
| } | |
| // TODO(rodrigoq): report error for other repos | |
| } | |
| defaultBuildFileName := "BUILD" | |
| if strings.HasPrefix(target, "//") { | |
| pkgPath := filepath.Join(rootDir, filepath.FromSlash(pkg)) | |
| if wspace.IsRegularFile(pkgPath) { | |
| // allow operation on other files like WORKSPACE | |
| buildFile = pkgPath | |
| pkg = path.Dir(pkg) | |
| return | |
| } | |
| for _, buildFileName := range BuildFileNames { | |
| buildFile = filepath.Join(pkgPath, buildFileName) | |
| if wspace.IsRegularFile(buildFile) { | |
| return | |
| } | |
| } | |
| buildFile = filepath.Join(pkgPath, defaultBuildFileName) | |
| return | |
| } | |
| if wspace.IsRegularFile(filepath.FromSlash(pkg)) { | |
| // allow operation on other files like WORKSPACE | |
| buildFile = pkg | |
| pkg = filepath.Join(relativePath, filepath.FromSlash(path.Dir(pkg))) | |
| return | |
| } | |
| found := false | |
| for _, buildFileName := range BuildFileNames { | |
| buildFile = filepath.Join(pkg, buildFileName) | |
| if wspace.IsRegularFile(buildFile) { | |
| found = true | |
| break | |
| } | |
| } | |
| if !found { | |
| buildFile = filepath.Join(pkg, defaultBuildFileName) | |
| } | |
| pkg = filepath.Join(relativePath, filepath.FromSlash(pkg)) | |
| return | |
| } | |
| // InterpretLabel returns the name of the BUILD file to edit, the full | |
| // package name, and the rule. It uses the pwd for resolving workspace file paths. | |
| func InterpretLabel(target string) (buildFile string, pkg string, rule string) { | |
| buildFile, _, pkg, rule = InterpretLabelForWorkspaceLocation("", target) | |
| return buildFile, pkg, rule | |
| } | |
| // InterpretLabelWithRepo returns the name of the BUILD file to edit, repo name, | |
| // the full package name, and the rule. It uses the pwd for resolving workspace | |
| // file paths. | |
| func InterpretLabelWithRepo(target string) (buildFile string, repo string, pkg string, rule string) { | |
| return InterpretLabelForWorkspaceLocation("", target) | |
| } |
Reactions are currently unavailable