@@ -4,13 +4,11 @@ use std::collections::BTreeSet;
44use std:: env;
55use std:: ffi:: { OsStr , OsString } ;
66use std:: fmt:: { Debug , Write } ;
7- use std:: fs:: { self , File } ;
7+ use std:: fs;
88use std:: hash:: Hash ;
9- use std:: io:: { BufRead , BufReader } ;
109use std:: ops:: Deref ;
1110use std:: path:: { Path , PathBuf } ;
1211use std:: process:: Command ;
13- use std:: sync:: OnceLock ;
1412use std:: time:: { Duration , Instant } ;
1513
1614use crate :: core:: build_steps:: tool:: { self , SourceType } ;
@@ -577,7 +575,7 @@ impl<'a> ShouldRun<'a> {
577575 ///
578576 /// [`path`]: ShouldRun::path
579577 pub fn paths ( mut self , paths : & [ & str ] ) -> Self {
580- let submodules_paths = self . builder . get_all_submodules ( ) ;
578+ let submodules_paths = build_helper :: util :: parse_gitmodules ( & self . builder . src ) ;
581579
582580 self . paths . insert ( PathSet :: Set (
583581 paths
@@ -2238,28 +2236,6 @@ impl<'a> Builder<'a> {
22382236 out
22392237 }
22402238
2241- /// Return paths of all submodules.
2242- pub fn get_all_submodules ( & self ) -> & [ String ] {
2243- static SUBMODULES_PATHS : OnceLock < Vec < String > > = OnceLock :: new ( ) ;
2244-
2245- let init_submodules_paths = |src : & PathBuf | {
2246- let file = File :: open ( src. join ( ".gitmodules" ) ) . unwrap ( ) ;
2247-
2248- let mut submodules_paths = vec ! [ ] ;
2249- for line in BufReader :: new ( file) . lines ( ) . map_while ( Result :: ok) {
2250- let line = line. trim ( ) ;
2251- if line. starts_with ( "path" ) {
2252- let actual_path = line. split ( ' ' ) . last ( ) . expect ( "Couldn't get value of path" ) ;
2253- submodules_paths. push ( actual_path. to_owned ( ) ) ;
2254- }
2255- }
2256-
2257- submodules_paths
2258- } ;
2259-
2260- SUBMODULES_PATHS . get_or_init ( || init_submodules_paths ( & self . src ) )
2261- }
2262-
22632239 /// Ensure that a given step is built *only if it's supposed to be built by default*, returning
22642240 /// its output. This will cache the step, so it's safe (and good!) to call this as often as
22652241 /// needed to ensure that all dependencies are build.
0 commit comments