1+ //! Handles the vendoring process for the bootstrap system.
2+ //!
3+ //! This module ensures that all required Cargo dependencies are gathered
4+ //! and stored in the `<src>/<VENDOR_DIR>` directory.
15use std:: path:: PathBuf ;
26
37use crate :: core:: build_steps:: tool:: SUBMODULES_FOR_RUSTBOOK ;
48use crate :: core:: builder:: { Builder , RunConfig , ShouldRun , Step } ;
59use crate :: utils:: exec:: command;
610
11+ /// The name of the directory where vendored dependencies are stored.
712pub const VENDOR_DIR : & str = "vendor" ;
813
914/// Returns the cargo workspaces to vendor for `x vendor` and dist tarballs.
@@ -29,11 +34,19 @@ pub fn default_paths_to_vendor(builder: &Builder<'_>) -> Vec<(PathBuf, Vec<&'sta
2934 . collect ( )
3035}
3136
37+ /// Defines the vendoring step in the bootstrap process.
38+ ///
39+ /// This step executes `cargo vendor` to collect all dependencies
40+ /// and store them in the `<src>/<VENDOR_DIR>` directory.
3241#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
3342pub ( crate ) struct Vendor {
43+ /// Additional paths to synchronize during vendoring.
3444 pub ( crate ) sync_args : Vec < PathBuf > ,
45+ /// Determines whether vendored dependencies use versioned directories.
3546 pub ( crate ) versioned_dirs : bool ,
47+ /// The root directory of the source code.
3648 pub ( crate ) root_dir : PathBuf ,
49+ /// The target directory for storing vendored dependencies.
3750 pub ( crate ) output_dir : PathBuf ,
3851}
3952
@@ -55,6 +68,10 @@ impl Step for Vendor {
5568 } ) ;
5669 }
5770
71+ /// Executes the vendoring process.
72+ ///
73+ /// This function runs `cargo vendor` and ensures all required submodules
74+ /// are initialized before vendoring begins.
5875 fn run ( self , builder : & Builder < ' _ > ) -> Self :: Output {
5976 builder. info ( & format ! ( "Vendoring sources to {:?}" , self . root_dir) ) ;
6077
@@ -94,6 +111,7 @@ impl Step for Vendor {
94111 }
95112}
96113
114+ /// Stores the result of the vendoring step.
97115#[ derive( Debug , Clone ) ]
98116pub ( crate ) struct VendorOutput {
99117 pub ( crate ) config : String ,
0 commit comments