Skip to content

Cargo build scripts executing rustc #237

@vitalyd

Description

@vitalyd

I'm not sure if this issue/question is more appropriate for this repo/project or cargo raze, but I'll file it here as it'll likely touch upon rules_rust anyway.

There are Cargo projects with a custom build.rs that wants to execute rustc, e.g. to get the compiler version. For example, protobuf.

Is there a way to get the path, in a genrule, to rustc of the current (i.e. selected/executing) Rust toolchain?

Somewhat relatedly, the aforementioned build.rs also wants the CARGO_PKG_VERSION envvar. This is set in the toolchain, but the genrule does not (re)export it: https://github.com/google/cargo-raze/blob/8138a751a0960f7975a3d5b969667e0e68f53a7e/impl/src/templates/partials/build_script.template#L28-L52

I found that if I manually added export CARGO_PKG_VERSION=$$(CARGO_PKG_VERSION) to the genrule, it worked. Not sure that's the right/expected way to do that. Should raze export all these CARGO_* envvars to build rules? Sorry, this one is very likely a raze issue, but it's so closely related to the above that I thought I'd plop it here :).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions