@@ -41,8 +41,7 @@ func PrintProgressIfProgressEnabledAndMachineLogger(ctx *types.Context) {
4141
4242 log := ctx .GetLogger ()
4343 if log .Name () == "machine" {
44- log .Println (constants .LOG_LEVEL_INFO , constants .MSG_PROGRESS , strconv .FormatFloat (ctx .Progress .Progress , 'f' , 2 , 32 ))
45- ctx .Progress .Progress += ctx .Progress .Steps
44+ log .Println (constants .LOG_LEVEL_INFO , constants .MSG_PROGRESS , strconv .FormatFloat (float64 (ctx .Progress .Progress ), 'f' , 2 , 32 ))
4645 }
4746}
4847
@@ -69,33 +68,42 @@ func CompileFilesRecursive(ctx *types.Context, sourcePath *paths.Path, buildPath
6968}
7069
7170func CompileFiles (ctx * types.Context , sourcePath * paths.Path , recurse bool , buildPath * paths.Path , buildProperties * properties.Map , includes []string ) (paths.PathList , error ) {
72- sObjectFiles , err := compileFilesWithExtensionWithRecipe ( ctx , sourcePath , recurse , buildPath , buildProperties , includes , ".S" , constants . RECIPE_S_PATTERN )
71+ sSources , err := findFilesInFolder ( sourcePath , ".S" , recurse )
7372 if err != nil {
7473 return nil , errors .WithStack (err )
7574 }
76- cObjectFiles , err := compileFilesWithExtensionWithRecipe ( ctx , sourcePath , recurse , buildPath , buildProperties , includes , ".c" , constants . RECIPE_C_PATTERN )
75+ cSources , err := findFilesInFolder ( sourcePath , ".c" , recurse )
7776 if err != nil {
7877 return nil , errors .WithStack (err )
7978 }
80- cppObjectFiles , err := compileFilesWithExtensionWithRecipe ( ctx , sourcePath , recurse , buildPath , buildProperties , includes , ".cpp" , constants . RECIPE_CPP_PATTERN )
79+ cppSources , err := findFilesInFolder ( sourcePath , ".cpp" , recurse )
8180 if err != nil {
8281 return nil , errors .WithStack (err )
8382 }
83+
84+ ctx .Progress .AddSubSteps (len (sSources ) + len (cSources ) + len (cppSources ))
85+ defer ctx .Progress .RemoveSubSteps ()
86+
87+ sObjectFiles , err := compileFilesWithRecipe (ctx , sourcePath , sSources , buildPath , buildProperties , includes , constants .RECIPE_S_PATTERN )
88+ if err != nil {
89+ return nil , errors .WithStack (err )
90+ }
91+ cObjectFiles , err := compileFilesWithRecipe (ctx , sourcePath , cSources , buildPath , buildProperties , includes , constants .RECIPE_C_PATTERN )
92+ if err != nil {
93+ return nil , errors .WithStack (err )
94+ }
95+ cppObjectFiles , err := compileFilesWithRecipe (ctx , sourcePath , cppSources , buildPath , buildProperties , includes , constants .RECIPE_CPP_PATTERN )
96+ if err != nil {
97+ return nil , errors .WithStack (err )
98+ }
99+
84100 objectFiles := paths .NewPathList ()
85101 objectFiles .AddAll (sObjectFiles )
86102 objectFiles .AddAll (cObjectFiles )
87103 objectFiles .AddAll (cppObjectFiles )
88104 return objectFiles , nil
89105}
90106
91- func compileFilesWithExtensionWithRecipe (ctx * types.Context , sourcePath * paths.Path , recurse bool , buildPath * paths.Path , buildProperties * properties.Map , includes []string , extension string , recipe string ) (paths.PathList , error ) {
92- sources , err := findFilesInFolder (sourcePath , extension , recurse )
93- if err != nil {
94- return nil , errors .WithStack (err )
95- }
96- return compileFilesWithRecipe (ctx , sourcePath , sources , buildPath , buildProperties , includes , recipe )
97- }
98-
99107func findFilesInFolder (sourcePath * paths.Path , extension string , recurse bool ) (paths.PathList , error ) {
100108 files , err := utils .ReadDirFiltered (sourcePath .String (), utils .FilterFilesWithExtensions (extension ))
101109 if err != nil {
@@ -164,11 +172,8 @@ func compileFilesWithRecipe(ctx *types.Context, sourcePath *paths.Path, sources
164172 var errorsList []error
165173 var errorsMux sync.Mutex
166174
167- ctx .Progress .Steps = ctx .Progress .Steps / float64 (len (sources ))
168-
169175 queue := make (chan * paths.Path )
170176 job := func (source * paths.Path ) {
171- PrintProgressIfProgressEnabledAndMachineLogger (ctx )
172177 objectFile , err := compileFileWithRecipe (ctx , sourcePath , source , buildPath , buildProperties , includes , recipe )
173178 if err != nil {
174179 errorsMux .Lock ()
@@ -206,6 +211,9 @@ func compileFilesWithRecipe(ctx *types.Context, sourcePath *paths.Path, sources
206211 break
207212 }
208213 queue <- source
214+
215+ ctx .Progress .CompleteStep ()
216+ PrintProgressIfProgressEnabledAndMachineLogger (ctx )
209217 }
210218 close (queue )
211219 wg .Wait ()
0 commit comments