Skip to content

Commit fdd9ec6

Browse files
remove ExecutableSectionSize from Context
1 parent 9715450 commit fdd9ec6

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

arduino/builder/builder.go

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ type Builder struct {
6363
// Progress of all various steps
6464
Progress *progress.Struct
6565

66+
// Sizer results
67+
executableSectionsSize ExecutablesFileSections
68+
6669
*BuildOptionsManager
6770
}
6871

@@ -184,3 +187,8 @@ func (b *Builder) GetSketchBuildPath() *paths.Path {
184187
func (b *Builder) GetLibrariesBuildPath() *paths.Path {
185188
return b.librariesBuildPath
186189
}
190+
191+
// ExecutableSectionsSize fixdoc
192+
func (b *Builder) ExecutableSectionsSize() ExecutablesFileSections {
193+
return b.executableSectionsSize
194+
}

arduino/builder/sizer.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,24 @@ func (s ExecutablesFileSections) ToRPCExecutableSectionSizeArray() []*rpc.Execut
5151
}
5252

5353
// Size fixdoc
54-
func (b *Builder) Size(sketchError bool) (ExecutablesFileSections, error) {
54+
func (b *Builder) Size(sketchError bool) error {
5555
if b.onlyUpdateCompilationDatabase || sketchError {
56-
return nil, nil
56+
return nil
5757
}
5858

59+
check := b.checkSize
5960
if b.buildProperties.ContainsKey("recipe.advanced_size.pattern") {
60-
return b.checkSizeAdvanced()
61+
check = b.checkSizeAdvanced
6162
}
6263

63-
return b.checkSize()
64+
result, err := check()
65+
if err != nil {
66+
return err
67+
}
68+
69+
b.executableSectionsSize = result
70+
71+
return nil
6472
}
6573

6674
func (b *Builder) checkSizeAdvanced() (ExecutablesFileSections, error) {

commands/compile/compile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
384384
}
385385
}
386386

387-
r.ExecutableSectionsSize = builderCtx.ExecutableSectionsSize.ToRPCExecutableSectionSizeArray()
387+
r.ExecutableSectionsSize = sketchBuilder.ExecutableSectionsSize().ToRPCExecutableSectionSizeArray()
388388

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

legacy/builder/builder.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ func (s *Builder) Run(ctx *types.Context) error {
202202
}),
203203

204204
types.BareCommand(func(ctx *types.Context) error {
205-
executableSectionsSize, err := ctx.Builder.Size(mainErr != nil)
206-
ctx.ExecutableSectionsSize = executableSectionsSize
207-
return err
205+
return ctx.Builder.Size(mainErr != nil)
208206
}),
209207
}
210208
for _, command := range commands {

legacy/builder/types/context.go

-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ type Context struct {
4949
// C++ Parsing
5050
LineOffset int
5151

52-
// Sizer results
53-
ExecutableSectionsSize builder.ExecutablesFileSections
54-
5552
// Compilation Database to build/update
5653
CompilationDatabase *compilation.Database
5754
}

0 commit comments

Comments
 (0)