diff options
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java | 19 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/commands/target-syntax.txt | 14 |
2 files changed, 15 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java index 6677970e2d..caca6344f6 100644 --- a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java +++ b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java @@ -151,12 +151,8 @@ public abstract class TargetPattern { throws TargetParsingException, InterruptedException, TargetPatternResolver.MissingDepException { if (resolver.isPackage(path)) { - // User has specified a package name. Issue a helpful error message. - throw new TargetParsingException("ambiguous target pattern: '" + path + "' is " - + "the name of a package; use '" + path + ":all' to mean \"all " - + "rules in this package\", '" + path + "/...' to mean \"all rules recursively " - + "beneath this package\", or '//" + path + "' to mean \"the default rule in this " - + "package\""); + // User has specified a package name. lookout for default target. + return resolver.getExplicitTarget("//" + path); } List<String> pieces = SLASH_SPLITTER.splitToList(path); @@ -405,14 +401,11 @@ public abstract class TargetPattern { // sufficient to test the first segment. This is really a rather weak check; perhaps we should // just eliminate it. int slashIndex = pattern.indexOf('/'); - if (slashIndex < 0) { - throw new TargetParsingException("ambiguous target pattern: '" + pattern + "' could " - + "potentially be the name of a package; use '" + pattern + ":all' to mean \"all " - + "rules in this package\", '" + pattern + "/...' to mean \"all rules recursively " - + "beneath this package\", or '//" + pattern + "' to mean \"the default rule in this " - + "package\""); + String packageName = pattern; + if (slashIndex > 0) { + packageName = pattern.substring(0, slashIndex); } - String errorMessage = LabelValidator.validatePackageName(pattern.substring(0, slashIndex)); + String errorMessage = LabelValidator.validatePackageName(packageName); if (errorMessage != null) { throw new TargetParsingException("Bad target pattern '" + originalPattern + "': " + errorMessage); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/target-syntax.txt b/src/main/java/com/google/devtools/build/lib/runtime/commands/target-syntax.txt index 1fac4981db..686135f593 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/target-syntax.txt +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/target-syntax.txt @@ -10,9 +10,10 @@ Examples: Specifying a single target: //foo/bar:wiz The single target '//foo/bar:wiz'. - foo/bar/wiz Equivalent to the first existing one of these: - //foo/bar:wiz - //foo:bar/wiz + foo/bar/wiz Equivalent to: + '//foo/bar/wiz:wiz' if foo/bar/wiz is a package, + '//foo/bar:wiz' if foo/bar is a package, + '//foo:bar/wiz' otherwise. //foo/bar Equivalent to '//foo/bar:bar'. Specifying all rules in a package: @@ -39,6 +40,9 @@ Working-directory relative forms: (assume cwd = 'workspace/foo') bar:wiz Equivalent to '//foo/bar:wiz'. :foo Equivalent to '//foo:foo'. + bar Equivalent to '//foo/bar:bar'. + foo/bar Equivalent to '//foo/foo/bar:bar'. + bar:all Equivalent to '//foo/bar:all'. :all Equivalent to '//foo:all'. @@ -52,13 +56,13 @@ Subtractive patterns: Target patterns may be preceded by '-', meaning they should be subtracted from the set of targets accumulated by preceding - patterns. For example: + patterns. (Note that this means order matters.) For example: % blaze build -- foo/... -foo/contrib/... builds everything in 'foo', except 'contrib'. In case a target not under 'contrib' depends on something under 'contrib' though, in order to build the former blaze has to build the latter too. As usual, the '--' is - required to prevent '-b' from being interpreted as an option. + required to prevent '-f' from being interpreted as an option. %{options} |