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

Add the CARGO_CRATE_NAME env var #537

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cargo/cargo_build_script.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def _build_script_impl(ctx):
crate_name = ctx.label.name
if crate_name.endswith("_build_script"):
crate_name = crate_name.replace("_build_script", "")
crate_name = crate_name.replace("_", "-")

pkg_name = crate_name.replace("_", "-")

toolchain_tools = [
# Needed for rustc to function.
Expand All @@ -68,7 +69,8 @@ def _build_script_impl(ctx):

env.update({
"CARGO_MANIFEST_DIR": manifest_dir,
"CARGO_PKG_NAME": crate_name,
"CARGO_PKG_NAME": pkg_name,
"CARGO_CRATE_NAME": crate_name,
arlyon marked this conversation as resolved.
Show resolved Hide resolved
"HOST": toolchain.exec_triple,
"OPT_LEVEL": compilation_mode_opt_level,
"RUSTC": toolchain.rustc.path,
Expand Down Expand Up @@ -134,7 +136,7 @@ def _build_script_impl(ctx):
# See https://doc.rust-lang.org/cargo/reference/build-scripts.html#-sys-packages
# for details.
args = ctx.actions.args()
args.add_all([script.path, crate_name, links, out_dir.path, env_out.path, flags_out.path, link_flags.path, dep_env_out.path])
args.add_all([script.path, pkg_name, links, out_dir.path, env_out.path, flags_out.path, link_flags.path, dep_env_out.path])
build_script_inputs = []
for dep in ctx.attr.deps:
if DepInfo in dep and dep[DepInfo].dep_env:
Expand Down
1 change: 1 addition & 0 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def _get_rustc_env(ctx, toolchain):
"CARGO_PKG_DESCRIPTION": "",
"CARGO_PKG_HOMEPAGE": "",
"CARGO_PKG_NAME": ctx.label.name,
"CARGO_CRATE_NAME": ctx.label.name.replace("-", "_"),
"CARGO_PKG_VERSION_MAJOR": major,
"CARGO_PKG_VERSION_MINOR": minor,
"CARGO_PKG_VERSION_PATCH": patch,
Expand Down