You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many Rust crates have a build.rs build script that is used for arbitrary build tasks before anything else in the crate is built. We should have equivalents for the common use cases that Rust build scripts are used for.
From the Cargo documentation, some of the tasks that can be handled by build.rs include:
This can be done with Skylark repository rules, though the rules for finding specific libraries still need to be written.
Generating a Rust module from a specification.
The best way to do this could be just building build.rs as a rust_binary then having something like a genrule target that runs the binary and have the expected output file(s) be inputs to the rust_binary or rust_library target that includes the generated file(s).
The key is to make this easy to use for users.
Performing any platform-specific configuration needed for the crate.
I think this can also be done using Skylark repository rules.
The text was updated successfully, but these errors were encountered:
Interim proposal: build build.rs as a rust_binary and then run it in a genrule without sandboxing with full access to the local system. This isn't ideal and there are cases this would not support (since build.rs can perform any arbitrary actions), but this may be a stopgap solution for common cases as better solutions for interfacing with large build systems are being discussed in rust-lang/rust-roadmap-2017#12.
I can add a little bit to this. Two findings from my exploration:
build.rs files emit lots of kinds of cargo::stuff that impacts dependencies. That stuff will need to be propagated in the form of flags and out_dir files. Details here.
Invocation of a build.rs will probably require the whole build to be un-hermetic. This is because many of the typical outputs in (1) are paths to system dependencies, which will become unavailable, and especially unlinkable, in subsequent rules. You can imagine building openssl with cargo, and then trying to link that and finding that gcc cant find -l crypto and -l ssl.
Many Rust crates have a
build.rs
build script that is used for arbitrary build tasks before anything else in the crate is built. We should have equivalents for the common use cases that Rust build scripts are used for.From the Cargo documentation, some of the tasks that can be handled by
build.rs
include:build.rs
as arust_binary
then having something like agenrule
target that runs the binary and have the expected output file(s) be inputs to therust_binary
orrust_library
target that includes the generated file(s).The text was updated successfully, but these errors were encountered: