@@ -649,23 +649,19 @@ impl<'a> Target<'a> {
649
649
log ( LogLevel :: Error , & format ! ( "Could not read directory: {}" , root_path) ) ;
650
650
std:: process:: exit ( 1 ) ;
651
651
} ) ;
652
-
653
- // Convert src_only and src_exclude to a Vec<&str> for easier comparison
654
652
let src_only: Vec < & str > = self . target_config . src_only . iter ( ) . map ( AsRef :: as_ref) . collect ( ) ;
655
653
let src_exclude: Vec < & str > = self . target_config . src_exclude . iter ( ) . map ( AsRef :: as_ref) . collect ( ) ;
656
654
657
655
// Iterate over all entrys
658
656
for entry in root_entries {
659
657
let entry = entry. unwrap ( ) ;
660
658
let path = entry. path ( ) . to_str ( ) . unwrap ( ) . to_string ( ) . replace ( "\\ " , "/" ) ; // if windows's path
661
-
662
659
// Exclusion logic: Check if the path is in src_exclude
663
660
let exclude = src_exclude. iter ( ) . any ( |& excluded| path. contains ( excluded) ) ;
664
661
if exclude {
665
662
log ( LogLevel :: Debug , & format ! ( "Excluding (in src_exclude): {}" , path) ) ;
666
663
continue ;
667
664
}
668
-
669
665
if entry. path ( ) . is_dir ( ) {
670
666
srcs. append ( & mut self . get_srcs ( & path) ) ;
671
667
} else {
@@ -675,12 +671,10 @@ impl<'a> Target<'a> {
675
671
} else {
676
672
true // If src_only is empty, include all
677
673
} ;
678
-
679
674
if !include {
680
675
log ( LogLevel :: Debug , & format ! ( "Excluding (not in src_only): {}" , path) ) ;
681
676
continue ;
682
677
}
683
-
684
678
if path. ends_with ( ".cpp" ) || path. ends_with ( ".c" ) {
685
679
self . add_src ( path) ;
686
680
}
@@ -726,31 +720,35 @@ impl<'a> Target<'a> {
726
720
if include_substrings. is_empty ( ) {
727
721
return result;
728
722
}
729
- for include_substring in include_substrings {
730
- let mut dep_paths = Vec :: new ( ) ;
731
- self . target_config . include_dir . iter ( ) . for_each ( |include| {
732
- let dep_path = format ! ( "{}/{}" , include, & include_substring) ;
733
- dep_paths. push ( dep_path. clone ( ) ) ;
734
- } ) ;
735
- if self . dependant_includes . contains_key ( & include_substring) {
736
- continue ;
723
+ let dep_paths: Vec < String > = include_substrings. par_iter ( ) . flat_map ( |include_substring| {
724
+ self . target_config . include_dir . par_iter ( ) . filter_map ( move |include| {
725
+ let dep_path = format ! ( "{}/{}" , include, include_substring) ;
726
+ if Path :: new ( & dep_path) . is_file ( ) {
727
+ Some ( dep_path)
728
+ } else {
729
+ None
730
+ }
731
+ } )
732
+ } ) . collect ( ) ;
733
+
734
+ for dep_path in dep_paths {
735
+ if !self . dependant_includes . contains_key ( dep_path. as_str ( ) ) {
736
+ result. push ( dep_path. clone ( ) ) ;
737
+ self . dependant_includes . insert ( dep_path. clone ( ) , result. clone ( ) ) ;
738
+ let mut recursive_includes = self . get_dependant_includes ( & dep_path) ;
739
+ result. append ( & mut recursive_includes) ;
737
740
}
738
- // append current includes
739
- result. extend ( dep_paths. clone ( ) ) ;
740
- self . dependant_includes . insert ( include_substring, result. clone ( ) ) ;
741
- // append recursive includes
742
- dep_paths. iter ( ) . for_each ( |dep_path| result. append ( & mut self . get_dependant_includes ( dep_path) ) )
743
741
}
744
- //log(LogLevel::Debug, &format!("dependant_includes: {:#?}", self.dependant_includes));
745
- } ;
742
+ }
746
743
result. into_iter ( ) . unique ( ) . collect ( )
747
744
}
748
745
749
746
/// Returns a list of substrings that contain "#include \"" in the source file
750
747
fn get_include_substrings ( & self , path : & str ) -> Option < Vec < String > > {
751
748
let file = std:: fs:: File :: open ( path) ;
752
749
if file. is_err ( ) {
753
- log ( LogLevel :: Warn , & format ! ( "Failed to get include substrings for file: {}" , path) ) ;
750
+ // If the software is self-developed, enable this debug option
751
+ //log(LogLevel::Debug, &format!("Failed to get include substrings for file: {}", path));
754
752
return None ;
755
753
}
756
754
let mut file = file. unwrap ( ) ;
0 commit comments