Skip to content

Commit

Permalink
remove ExecutableSectionSize from Context
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Sep 12, 2023
1 parent 9715450 commit fdd9ec6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
8 changes: 8 additions & 0 deletions arduino/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ type Builder struct {
// Progress of all various steps
Progress *progress.Struct

// Sizer results
executableSectionsSize ExecutablesFileSections

*BuildOptionsManager
}

Expand Down Expand Up @@ -184,3 +187,8 @@ func (b *Builder) GetSketchBuildPath() *paths.Path {
func (b *Builder) GetLibrariesBuildPath() *paths.Path {
return b.librariesBuildPath
}

// ExecutableSectionsSize fixdoc
func (b *Builder) ExecutableSectionsSize() ExecutablesFileSections {
return b.executableSectionsSize
}
16 changes: 12 additions & 4 deletions arduino/builder/sizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,24 @@ func (s ExecutablesFileSections) ToRPCExecutableSectionSizeArray() []*rpc.Execut
}

// Size fixdoc
func (b *Builder) Size(sketchError bool) (ExecutablesFileSections, error) {
func (b *Builder) Size(sketchError bool) error {
if b.onlyUpdateCompilationDatabase || sketchError {
return nil, nil
return nil
}

check := b.checkSize
if b.buildProperties.ContainsKey("recipe.advanced_size.pattern") {
return b.checkSizeAdvanced()
check = b.checkSizeAdvanced
}

return b.checkSize()
result, err := check()
if err != nil {
return err
}

b.executableSectionsSize = result

return nil
}

func (b *Builder) checkSizeAdvanced() (ExecutablesFileSections, error) {
Expand Down
2 changes: 1 addition & 1 deletion commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
}
}

r.ExecutableSectionsSize = builderCtx.ExecutableSectionsSize.ToRPCExecutableSectionSizeArray()
r.ExecutableSectionsSize = sketchBuilder.ExecutableSectionsSize().ToRPCExecutableSectionSizeArray()

logrus.Tracef("Compile %s for %s successful", sk.Name, fqbnIn)

Expand Down
4 changes: 1 addition & 3 deletions legacy/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ func (s *Builder) Run(ctx *types.Context) error {
}),

types.BareCommand(func(ctx *types.Context) error {
executableSectionsSize, err := ctx.Builder.Size(mainErr != nil)
ctx.ExecutableSectionsSize = executableSectionsSize
return err
return ctx.Builder.Size(mainErr != nil)
}),
}
for _, command := range commands {
Expand Down
3 changes: 0 additions & 3 deletions legacy/builder/types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ type Context struct {
// C++ Parsing
LineOffset int

// Sizer results
ExecutableSectionsSize builder.ExecutablesFileSections

// Compilation Database to build/update
CompilationDatabase *compilation.Database
}

0 comments on commit fdd9ec6

Please sign in to comment.