-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Reduce the need for users to write build scripts #14948
Comments
I would draw a distinction between main binary build scripts (e.g. the executable or cdylib) and libraries. I think a build scripts for an executable is far more tolerable than for libraries. They're in direct control of the crate author and don't have any other users. Also a single top-level build script is going to have negligible impact on build times for all but the smallest projects. Which is not to say reducing the need for them is not important too, just that reducing the need for library build scripts will likely have the far bigger impact. |
This is not about trying to remove all build scripts but finding patterns in the community and providing a solution to avoid writing one yourself. In some cases, this will be using an artifact dependency as your build script. This is a general solution that helps libs and bins. And the benefits extend to bins. For smaller projects it democratizes the benefits of build scripts by making it easier to discover what you can do, easier to implement, and with fewer bugs. For larger projects with multiple bins, it makes reuse easier, reduces build times, and makes it easier to audit your own code base. Yes, libs will get more benefits as we prioritize solutions to implement but understanding and tracking the needs of bins takes little away from that but instead gives a better understanding for designing soluations. |
I don't know if this is important enough, but I also have a small use-case: I integrate a version string from an environment variable into my program during compile time. A natural way to do this would be the So I am forced to use a build script with the |
|
Oh that works! 😊 I don't know what went wrong the last time I tested it, sorry for the confusion. |
Cargo might not fully track its own env variables which would be a bug. iirc |
Did you mean |
Like RUSTFLAGS, build scripts are an important escape hatch. Like RUSTFLAGS (#12739), we should find replacements for common uses of build scripts so people don't have to reach to this escape hatch so often
Reducing build scripts would
Uses of build scripts
#[cfg(accessible(::path::to::thing))]
rust#64797#[cfg(version(..))]
rust#64796cfg
values available at runtime (e.g. in--bugreport
,--version
, or crash reports, or for tests building examples)cfg_value!
,cfg_values!
,try_cfg_value!
,try_cfg_values!
(see also mutually exclusive features)TARGET
available at runtime (e.g.--version
, building examples in tests)package.rs
) #12552-sys
crates?The text was updated successfully, but these errors were encountered: