-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add option to include submodules from vendoring #137583
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
Open
erickt
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
erickt:exclude-submodules-from-vendoring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+47
−14
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,6 +2,7 @@ | |||||
//! | ||||||
//! This module ensures that all required Cargo dependencies are gathered | ||||||
//! and stored in the `<src>/<VENDOR_DIR>` directory. | ||||||
use std::collections::BTreeSet; | ||||||
use std::path::PathBuf; | ||||||
|
||||||
use crate::core::build_steps::tool::SUBMODULES_FOR_RUSTBOOK; | ||||||
|
@@ -16,21 +17,32 @@ pub const VENDOR_DIR: &str = "vendor"; | |||||
/// Returns a `Vec` of `(path_to_manifest, submodules_required)` where | ||||||
/// `path_to_manifest` is the cargo workspace, and `submodules_required` is | ||||||
/// the set of submodules that must be available. | ||||||
pub fn default_paths_to_vendor(builder: &Builder<'_>) -> Vec<(PathBuf, Vec<&'static str>)> { | ||||||
pub fn default_paths_to_vendor( | ||||||
builder: &Builder<'_>, | ||||||
excluded_submodules: &BTreeSet<String>, | ||||||
) -> Vec<(PathBuf, Vec<&'static str>)> { | ||||||
[ | ||||||
("src/tools/cargo/Cargo.toml", vec!["src/tools/cargo"]), | ||||||
("src/tools/rust-analyzer/Cargo.toml", vec![]), | ||||||
("compiler/rustc_codegen_cranelift/Cargo.toml", vec![]), | ||||||
("compiler/rustc_codegen_gcc/Cargo.toml", vec![]), | ||||||
("library/Cargo.toml", vec![]), | ||||||
("src/bootstrap/Cargo.toml", vec![]), | ||||||
("src/tools/rustbook/Cargo.toml", SUBMODULES_FOR_RUSTBOOK.into()), | ||||||
("src/tools/rustc-perf/Cargo.toml", vec!["src/tools/rustc-perf"]), | ||||||
("src/tools/opt-dist/Cargo.toml", vec![]), | ||||||
("src/doc/book/packages/trpl/Cargo.toml", vec![]), | ||||||
("src/tools/cargo/Cargo.toml", &["src/tools/cargo"][..]), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Just a small nit. |
||||||
("src/tools/rust-analyzer/Cargo.toml", &[]), | ||||||
("compiler/rustc_codegen_cranelift/Cargo.toml", &[]), | ||||||
("compiler/rustc_codegen_gcc/Cargo.toml", &[]), | ||||||
("library/Cargo.toml", &[]), | ||||||
("src/bootstrap/Cargo.toml", &[]), | ||||||
("src/tools/rustbook/Cargo.toml", SUBMODULES_FOR_RUSTBOOK), | ||||||
("src/tools/rustc-perf/Cargo.toml", &["src/tools/rustc-perf"]), | ||||||
("src/tools/opt-dist/Cargo.toml", &[]), | ||||||
("src/doc/book/packages/trpl/Cargo.toml", &[]), | ||||||
] | ||||||
.into_iter() | ||||||
.map(|(path, submodules)| (builder.src.join(path), submodules)) | ||||||
.filter_map(|(path, submodules)| { | ||||||
for submodule in submodules { | ||||||
if excluded_submodules.contains(&**submodule) { | ||||||
return None; | ||||||
} | ||||||
} | ||||||
|
||||||
Some((builder.src.join(path), submodules.into())) | ||||||
}) | ||||||
.collect() | ||||||
} | ||||||
|
||||||
|
@@ -82,7 +94,11 @@ impl Step for Vendor { | |||||
cmd.arg("--versioned-dirs"); | ||||||
} | ||||||
|
||||||
let to_vendor = default_paths_to_vendor(builder); | ||||||
let to_vendor = default_paths_to_vendor( | ||||||
builder, | ||||||
&builder.config.dist_exclude_submodules_from_vendoring, | ||||||
); | ||||||
|
||||||
// These submodules must be present for `x vendor` to work. | ||||||
for (_, submodules) in &to_vendor { | ||||||
for submodule in submodules { | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -339,6 +339,7 @@ pub struct Config { | |||||
pub dist_compression_profile: String, | ||||||
pub dist_include_mingw_linker: bool, | ||||||
pub dist_vendor: bool, | ||||||
pub dist_exclude_submodules_from_vendoring: BTreeSet<String>, | ||||||
|
||||||
// libstd features | ||||||
pub backtrace: bool, // support for RUST_BACKTRACE | ||||||
|
@@ -1001,6 +1002,7 @@ define_config! { | |||||
compression_profile: Option<String> = "compression-profile", | ||||||
include_mingw_linker: Option<bool> = "include-mingw-linker", | ||||||
vendor: Option<bool> = "vendor", | ||||||
exclude_submodules_from_vendoring: Option<BTreeSet<String>> = "exclude-submodules-from-vendoring", | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -2227,10 +2229,13 @@ impl Config { | |||||
compression_profile, | ||||||
include_mingw_linker, | ||||||
vendor, | ||||||
exclude_submodules_from_vendoring, | ||||||
} = dist; | ||||||
config.dist_sign_folder = sign_folder.map(PathBuf::from); | ||||||
config.dist_upload_addr = upload_addr; | ||||||
config.dist_compression_formats = compression_formats; | ||||||
config.dist_exclude_submodules_from_vendoring = | ||||||
exclude_submodules_from_vendoring.unwrap_or_else(BTreeSet::new); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
set(&mut config.dist_compression_profile, compression_profile); | ||||||
set(&mut config.rust_dist_src, src_tarball); | ||||||
set(&mut config.dist_include_mingw_linker, include_mingw_linker); | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It seems to me that all callers of
exclude_submodules
pass the same argument to it. Can we remove the argument and accessbuilder.config.dist_exclude_submodules_from_vendoring
directly inside of the function?