-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 a first-class format for declaring external dependencies #3816
Comments
Note that there's some prior work here to draw from as well:
|
I think completely ignoring the I like the solution of |
Ignoring The metadeps approach is nice for modularity, If such libraries could work both at build time ( |
As one possibility: I'd love to see a standardized mechanism to extend the build metadata without writing an explicit That would allow using the crate ecosystem to standardize key portions of build systems into declarative metadata, without privileging any particular implementation or limiting additions. And crates wouldn't need a programmatic So, for instance, a project written in Rust, to bind to a C library, using bindgen at build time, and expose a Python interface could have How does that sound? |
I've looked at my build.rs scripts, and in order to replace them, I'd need these features:
|
This issue came up in discussions the Firefox build team had with @alexcrichton last week. One thing that "build scripts as black boxes" makes difficult is caching build outputs with sccache. Currently we can cache the outputs of rustc invocations, but we still have to run all the build scripts, and some of them spend a lot of time doing things like invoking third-party build systems. If we had a more declarative syntax we could cache the output of build scripts and avoid unnecessary work. For this to work we'd need a full list of inputs and outputs for the build script up-front. I could imagine this being a little tricky for build scripts that are doing things like "build a project using the cmake crate to invoke its cmake build system" (servo-freetype-sys is one example I know of that does this.) |
Another problem is that for build scripts (and Make, etc.) environmental variables are "dependencies" too. It would be good if env vars could be declared as well, so that Cargo would correctly rebuild projects when env vars change. |
Even knowing the list of inputs & outputs after a single invocation of the build script (ie: not up-front) should allow a bit of improvement here as one would be able to avoid running the build script again. Another alternate is allowing a way to ask a build script to "tell me what you need, but avoid doing any work" (though that may not be feasible for a build script to provide). |
There's an RFC for build system integration now up at rust-lang/rfcs#2136 |
This is an issue extracted from the discussion on rust-lang/rust-roadmap-2017#12. The high level idea is that Cargo should support a first-class method of declaring dependencies on external artifacts in a structured format. When combined with #3815 this would easily allow external build systems to resolve these dependencies to internal rules known by those build system. For example Buck/Bazel may have their own copy of OpenSSL compiled, and the openssl-sys crate should be connected to that copy (both literally at compile time but also in the dependency graph).
The purpose of this support is to allow the majority of build scripts in the ecosystem to largely be overwritten and avoided at compile time. Build scripts tend to be difficult to wrangle in restrictive build systems as they can have an unpredictable set of inputs (for an arbitrary build script) and are otherwise difficult to always audit one by one (for any particular build script). By having a first class description of what the build script would otherwise do this can allow external build systems to assume by default that a build script need not be run.
The text was updated successfully, but these errors were encountered: