-
Notifications
You must be signed in to change notification settings - Fork 2.6k
WIP: Implementation 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? |
pub fn find_build_script_metadata(&self, unit: &Unit) -> Option<UnitHash> { | ||
let script_unit = self.find_build_script_unit(unit)?; | ||
Some(self.get_run_build_script_metadata(&script_unit)) | ||
pub fn find_build_script_metadata(&self, unit: &Unit) -> Option<Vec<UnitHash>> { |
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.
find_build_script_metadata
-> find_build_script_metadatas
to express through the name that this is plural
@@ -45,7 +45,7 @@ pub struct Doctest { | |||
/// The script metadata, if this unit's package has a build script. | |||
/// | |||
/// This is used for indexing [`Compilation::extra_env`]. | |||
pub script_meta: Option<UnitHash>, | |||
pub scripts_meta: Option<Vec<UnitHash>>, |
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.
Always a weird question on whether to pluralize the first part or second. I lean towards the second
@@ -61,7 +61,7 @@ pub struct UnitOutput { | |||
/// The script metadata, if this unit's package has a build script. | |||
/// | |||
/// This is used for indexing [`Compilation::extra_env`]. | |||
pub script_meta: Option<UnitHash>, | |||
pub script_meta: Option<Vec<UnitHash>>, |
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.
Should we also pluralize this?
} | ||
|
||
/// Returns a [`ProcessBuilder`] for running `rustdoc`. | ||
pub fn rustdoc_process( | ||
&self, | ||
unit: &Unit, | ||
script_meta: Option<UnitHash>, | ||
script_meta: &Option<Vec<UnitHash>>, |
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 be switched to Option<&Vec<UnitHash>>,
(accessed via Option::as_ref
) or Option<&[UnitHash]>,
(accessed via Option::as_deref
)
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.
True for all other &Option
s
pub fn find_build_script_units(&self, unit: &Unit) -> Option<Vec<Unit>> { | ||
if unit.mode.is_run_custom_build() { | ||
return Some(unit.clone()); | ||
return Some(vec![unit.clone()]); | ||
} | ||
self.bcx.unit_graph[unit] | ||
|
||
let build_script_units: Vec<Unit> = self.bcx.unit_graph[unit] | ||
.iter() | ||
.find(|unit_dep| { | ||
.filter(|unit_dep| { | ||
unit_dep.unit.mode.is_run_custom_build() | ||
&& unit_dep.unit.pkg.package_id() == unit.pkg.package_id() | ||
}) | ||
.map(|unit_dep| unit_dep.unit.clone()) | ||
.collect(); | ||
if build_script_units.is_empty() { | ||
None | ||
} else { | ||
Some(build_script_units) | ||
} | ||
} |
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 order is this returning units? We should do it in a deterministic order, preferably one controlled by the user.
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.
If this commit is just about changing types, we can always add this in a later commit
66a7106
to
2042b1c
Compare
2042b1c
to
96ca257
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 featureThis PR is WIP and not ready for review yet!