-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Implementation and tests for multiple-build-scripts
#15704
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
base: master
Are you sure you want to change the base?
Conversation
Bad copy/paste? |
2042b1c
to
96ca257
Compare
4b8bdec
to
934c3b2
Compare
I am marking this PR Ready for Review. Please do let me know if I have missed anything |
r? @weihanglo rustbot has assigned @weihanglo. Use |
multiple-build-scripts
r? @epage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have multiple build scripts working, we need to update
fn rerun_untracks_other_files() { |
if let Some(meta_vec) = script_metas { | ||
for meta in meta_vec { | ||
if let Some(env) = self.extra_env.get(meta) { | ||
for (k, v) in env { | ||
cmd.env(k, v); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should happen when two build scripts output conflicting information?
- Last one specified wins (current behavior, see also feat: Implementation and tests for
multiple-build-scripts
#15704 (comment) - First one specified wins
- Error
- Unspecified
Whichever route we go, we should have a test for it. In fact, environment variable tests are probably the best way to test multiple build scripts ran.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While performing experiments, I don't know why, last one specified doesn't win. Rather, the lexicographically smallest build script wins.
For example, I have 2 build scripts, build1.rs
and build2.rs
, building files a.cpp
and b.cpp
(using cc
), such that both a.cpp
and b.cpp
has functions foo
, but foo
is different in these files.
So, if we run it, no matter the order in Cargo.toml
, build1.rs
always wins, and hence, a.cpp
always wins. Also, changing a.cpp
to d.cpp
doesn't change anything, but if we change build1.rs
to build3.rs
, build2.rs
wins.
And it is deterministic, and not random, I have tested it like 50 times on my system ( I made a little bash script that cargo clean
and then cargo run
). I am not completely sure why though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, it is exactly opposite in environment variables. The lexicographically largest script, ie, build3.rs
always wins.
Also, another case we need to handle is |
934c3b2
to
d6e4d74
Compare
Hi Everyone!
This is PR for the implementation of the first milestone of GSoC Project : Build Script Delegation
This will provide actual implementation for #15630
What does this PR try to resolve?
Now, multiple build scripts are parsed, this PR aims to implement the functioning the feature. This PR will allow users to use multiple build scripts, and is backward compatible with single script as well as boolean values.
Motivation : This will help users to maintain separate smaller and cleaner build scripts instead of one large build script. This is also necessary for build script delegation.
How to test and review this PR?
There is a feature gate
multiple-build-scripts
that can be passed viacargo-features
inCargo.toml
. So, you have to addPreferably on the top of the
Cargo.toml
and use nightly toolchain to use the feature