bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Support periods in label syntax

Open schroederc opened this issue 11 years ago • 9 comments

Kythe needs support for '.' characters in its labels because several of its directories contain the character.

schroederc avatar Apr 13 '15 17:04 schroederc

Just wondering, which directories specifically?

davidzchen avatar Apr 13 '15 21:04 davidzchen

Directories under $GOPATH/src that correspond to domain names (e.g. third_party/go/src/golang.org/x/net).

schroederc avatar Apr 13 '15 21:04 schroederc

We also have an internal request for that - however, we need to be careful with changes to the allowed package names as that can break services and tools that assume the current one. We might be able to allow it in Bazel, but disallow it internally, maybe...

On Mon, Apr 13, 2015 at 11:03 PM, Cody Schroeder [email protected] wrote:

Directories under $GOPATH/src that correspond to domain names (e.g. third_party/go/src/golang.org/x/net https://github.com/google/kythe/tree/master/third_party/go/src/golang.org/x/net ).

— Reply to this email directly or view it on GitHub https://github.com/google/bazel/issues/118#issuecomment-92497638.

ulfbot avatar Apr 14 '15 06:04 ulfbot

Just as a note, this feature is critical for properly supporting Kythe's third_party Go libraries (since packages are stored under directories like github.com and google.golang.org). Otherwise, we have to have 1 large, rather unmaintainable BUILD file for all of our imported libraries. This will likely come up in Bazel's official Go support as well.

schroederc avatar Apr 21 '15 16:04 schroederc

Any progress on this?

schroederc avatar Sep 17 '15 18:09 schroederc

Not really. I'm slowly convincing myself that we should be able to add a couple characters without any problems. The question is - which ones?

Here's EBNF for the currently accepted labels (this will be rolled into the docs):

label =   ( “@” <workspace_name> )? “//” <package_name> “:” <target_name>
        | “:”? <target_name>
        | ( “@” <workspace_name> )? “//” ( <package_name> “/” )? ( [0-9A-Za-z_-]+ )

workspace_name = [0-9A-Z_a-z_.-] ( “/”? [0-9A-Z_a-z_.-] )*
package_name = [0-9A-Za-z_-] ( “/”? [0-9A-Za-z_-] )*
target_name = ( <letter> | [/.+,=~_@-] )+
              except strings starting with “/”,  “./”,  or “../”
              except strings ending in     “/”          or “/..”
              except strings containing    “//”, “/./”, or “/../”
              except strings identical to  “”              “..”
letter = any character for which java.lang.Character.isLetterOrDigit returns true

The consistent thing would be to make package_name closer to target_name, with similar restrictions on the full string (i.e., no "./", no "//", no "/../", etc). Actually, looking at it right now, it looks like the workspace_name is broken, because it allows things like ".", and "./.", and "./../.", which all lead to invalid paths.

ulfjack avatar Sep 17 '15 19:09 ulfjack

I have started work on the Go rules again. I'll work on this shortlty.

hanwen avatar Sep 24 '15 18:09 hanwen

I have a proposal. Let's talk.

On Thursday, 24 September 2015, Han-Wen Nienhuys [email protected] wrote:

I have started work on the Go rules again. I'll work on this shortlty.

— Reply to this email directly or view it on GitHub https://github.com/bazelbuild/bazel/issues/118#issuecomment-143007827.

ulfjack avatar Sep 24 '15 19:09 ulfjack

dots are allowed in package names as of c1caffaabd028493188b7e3419bedf3a9506dfee

hanwen avatar Jan 19 '16 14:01 hanwen