Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support hyphens in target names #295

Merged
merged 3 commits into from
Feb 25, 2020
Merged

Support hyphens in target names #295

merged 3 commits into from
Feb 25, 2020

Conversation

dtolnay
Copy link
Contributor

@dtolnay dtolnay commented Feb 23, 2020

This PR makes it possible to define and depend on Rust targets whose name contains hyphen instead of underscore, primarily intended for case-matching names of third party libraries.

Example:

rust_library(
    name = "thiserror-impl",
    srcs = glob(["vendor/thiserror-impl-1.0.11/src/**/*.rs"]),
    crate_type = "proc-macro",
    deps = [
        "//third-party:proc-macro2",
        "//third-party:quote",
        "//third-party:syn",
    ],
)

Tested with dtolnay/cxx#37.

rust/private/rust.bzl Outdated Show resolved Hide resolved
rust/private/rustc.bzl Outdated Show resolved Hide resolved
@@ -110,12 +111,13 @@ def _rust_library_impl(ctx):
output_hash,
)
rust_lib = ctx.actions.declare_file(rust_lib_name)
crate_name = ctx.label.name.replace("-", "_")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove one more by passing crate_name to L108

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of them is ctx.attr.name, the other is ctx.label.name. Are those interchangeable?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 99% sure they are, but not entirely.. I think the difference is that ctx.label is the full label

@mfarrugi mfarrugi merged commit 5a679d4 into bazelbuild:master Feb 25, 2020
@dtolnay dtolnay deleted the hyphen branch February 25, 2020 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants