-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Accessing each build script's OUT_DIR
#15891
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
75ff71c
to
0d5b7b0
Compare
c0d23d2
to
6c8bc08
Compare
5581004
to
c9e3081
Compare
65b6c7f
to
4117277
Compare
16fb171
to
8f929ff
Compare
8f929ff
to
1ab5374
Compare
1ab5374
to
b5150ef
Compare
r? @weihanglo rustbot has assigned @weihanglo. Use |
r? @epage |
OUT_DIR
OUT_DIR
* `<script-name>_OUT_DIR` --- If the package has build script(s), this is set to the folder where the | ||
build script should place its output. The `<script-name>` is the file-stem of the build script, exactly as-is. | ||
For example, `bar_OUT_DIR` for script at `foo/bar.rs`. (Only set during compilation.) |
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.
This should probably be on unstable.md
let out_dir = &build_runner.files().build_script_out_dir(&dep.unit); | ||
let target_name = dep.unit.target.name(); | ||
let out_dir_prefix = target_name | ||
.strip_prefix("build-script-") | ||
.unwrap_or(target_name); | ||
let out_dir_name = format!("{out_dir_prefix}_OUT_DIR"); | ||
cmd.env(&out_dir_name, &out_dir); |
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.
Doesn't is need a feature gate?
err_msg += &format!( | ||
"\nBuild Scripts : {} have the same file stem, that is {}", | ||
paths.join(", "), | ||
stem | ||
); |
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.
err_msg += &format!( | |
"\nBuild Scripts : {} have the same file stem, that is {}", | |
paths.join(", "), | |
stem | |
); | |
write!(&mut err_msg, " for stem `{stem}`: {}", paths.join(", "))?; |
- generally better to use
write!
to append formatted text - duplicating the error message
- needs indentation to set apart from the rest of the message
} | ||
|
||
#[cargo_test] | ||
fn multiple_out_dirs() { |
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.
Shouldn't this test be added before the validation?
This PR is continuation of my work on GSoC Project : Build Script Delegation
What does this PR try to resolve?
Through this PR, I want the user to be able to access each build script's
OUT_DIR
.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 featureThen, you can access the
OUT_DIR
of given build script by accessing it like a compile time environment variable, for example: