Skip to content

Commit

Permalink
Call PushProgress at every CompleteStep call
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Oct 2, 2023
1 parent 9dda230 commit ff46bc4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 32 deletions.
28 changes: 0 additions & 28 deletions arduino/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,16 @@ func (b *Builder) preprocess() error {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.RunRecipe("recipe.hooks.prebuild", ".pattern", false); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.prepareSketchBuildPath(); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

b.logIfVerbose(false, tr("Detecting libraries used..."))
err := b.libsDetector.FindIncludes(
Expand All @@ -302,18 +299,15 @@ func (b *Builder) preprocess() error {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

b.warnAboutArchIncompatibleLibraries(b.libsDetector.ImportedLibraries())
b.Progress.CompleteStep()
b.Progress.PushProgress()

b.logIfVerbose(false, tr("Generating function prototypes..."))
if err := b.preprocessSketch(b.libsDetector.IncludeFolders()); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

return nil
}
Expand Down Expand Up @@ -342,11 +336,9 @@ func (b *Builder) Build() error {

b.libsDetector.PrintUsedAndNotUsedLibraries(buildErr != nil)
b.Progress.CompleteStep()
b.Progress.PushProgress()

b.printUsedLibraries(b.libsDetector.ImportedLibraries())
b.Progress.CompleteStep()
b.Progress.PushProgress()

if buildErr != nil {
return buildErr
Expand All @@ -355,13 +347,11 @@ func (b *Builder) Build() error {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.size(); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

return nil
}
Expand All @@ -373,112 +363,94 @@ func (b *Builder) build() error {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.buildSketch(b.libsDetector.IncludeFolders()); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.RunRecipe("recipe.hooks.sketch.postbuild", ".pattern", true); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

b.logIfVerbose(false, tr("Compiling libraries..."))
if err := b.RunRecipe("recipe.hooks.libraries.prebuild", ".pattern", false); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.removeUnusedCompiledLibraries(b.libsDetector.ImportedLibraries()); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.buildLibraries(b.libsDetector.IncludeFolders(), b.libsDetector.ImportedLibraries()); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.RunRecipe("recipe.hooks.libraries.postbuild", ".pattern", true); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

b.logIfVerbose(false, tr("Compiling core..."))
if err := b.RunRecipe("recipe.hooks.core.prebuild", ".pattern", false); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.buildCore(); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.RunRecipe("recipe.hooks.core.postbuild", ".pattern", true); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

b.logIfVerbose(false, tr("Linking everything together..."))
if err := b.RunRecipe("recipe.hooks.linking.prelink", ".pattern", false); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.link(); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.RunRecipe("recipe.hooks.linking.postlink", ".pattern", true); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.RunRecipe("recipe.hooks.objcopy.preobjcopy", ".pattern", false); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.RunRecipe("recipe.objcopy.", ".pattern", true); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.RunRecipe("recipe.hooks.objcopy.postobjcopy", ".pattern", true); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.mergeSketchWithBootloader(); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if err := b.RunRecipe("recipe.hooks.postbuild", ".pattern", true); err != nil {
return err
}
b.Progress.CompleteStep()
b.Progress.PushProgress()

if b.compilationDatabase != nil {
b.compilationDatabase.SaveToFile()
Expand Down
1 change: 0 additions & 1 deletion arduino/builder/compilation.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func (b *Builder) compileFiles(
queue <- source

b.Progress.CompleteStep()
b.Progress.PushProgress()
}
close(queue)
wg.Wait()
Expand Down
4 changes: 2 additions & 2 deletions arduino/builder/internal/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ func (p *Struct) RemoveSubSteps() {
// CompleteStep fixdoc
func (p *Struct) CompleteStep() {
p.Progress += p.StepAmount
p.pushProgress()
}

// PushProgress fixdoc
func (p *Struct) PushProgress() {
func (p *Struct) pushProgress() {
if p.callback != nil {
p.callback(&rpc.TaskProgress{
Percent: p.Progress,
Expand Down
1 change: 0 additions & 1 deletion arduino/builder/libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (b *Builder) compileLibraries(libraries libraries.List, includes []string)
objectFiles.AddAll(libraryObjectFiles)

b.Progress.CompleteStep()
b.Progress.PushProgress()
}

return objectFiles, nil
Expand Down

0 comments on commit ff46bc4

Please sign in to comment.