-
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip-changelog] legacy: Builder refactorization (part 2) (#2298)
* remove unused LibraryDir from legacy context * remove unused WatchedLocation from legacy context * remove unused IgnoreSketchFolderNameErrors from legacy context * remove CanUseCachedTools from legacy context * remove UseArduinoPreprocessor from legacy context * make the CoreBuilder command a function * remove the use of context from builder_utils * mvoe types.ProgressStruct in a dedicated pkg * move ExecCommand under arduino/utils * move LogIfVerbose from utils to legacy builder * move some legacy constans in builder package * move builder_utils under arduino/builder/utils pkg * appease golint * move coreBuildCachePath in the arduino Builder * refactor Linker command in a function * refactor SketchBuilder in a function * refactor LibrariesBuilder in a function * refactor Sizer in a function * remove empty file * remove unused struct FailIfBuildPathEqualsSketchPath
- Loading branch information
1 parent
1c110e9
commit b8024c3
Showing
28 changed files
with
1,166 additions
and
853 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package builder | ||
|
||
import "github.com/arduino/go-paths-helper" | ||
|
||
// CoreBuildCachePath fixdoc | ||
func (b *Builder) CoreBuildCachePath() *paths.Path { | ||
return b.coreBuildCachePath | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package progress | ||
|
||
// Struct fixdoc | ||
type Struct struct { | ||
Progress float32 | ||
StepAmount float32 | ||
Parent *Struct | ||
} | ||
|
||
// AddSubSteps fixdoc | ||
func (p *Struct) AddSubSteps(steps int) { | ||
p.Parent = &Struct{ | ||
Progress: p.Progress, | ||
StepAmount: p.StepAmount, | ||
Parent: p.Parent, | ||
} | ||
if p.StepAmount == 0.0 { | ||
p.StepAmount = 100.0 | ||
} | ||
p.StepAmount /= float32(steps) | ||
} | ||
|
||
// RemoveSubSteps fixdoc | ||
func (p *Struct) RemoveSubSteps() { | ||
p.Progress = p.Parent.Progress | ||
p.StepAmount = p.Parent.StepAmount | ||
p.Parent = p.Parent.Parent | ||
} | ||
|
||
// CompleteStep fixdoc | ||
func (p *Struct) CompleteStep() { | ||
p.Progress += p.StepAmount | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
// Arduino software without disclosing the source code of your own applications. | ||
// To purchase a commercial license, send an email to [email protected]. | ||
|
||
package types | ||
package progress | ||
|
||
import ( | ||
"fmt" | ||
|
@@ -23,7 +23,7 @@ import ( | |
) | ||
|
||
func TestProgress(t *testing.T) { | ||
p := &ProgressStruct{} | ||
p := &Struct{} | ||
p.AddSubSteps(3) | ||
require.Equal(t, float32(0.0), p.Progress) | ||
require.InEpsilon(t, 33.33333, p.StepAmount, 0.00001) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package builder | ||
|
||
import rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" | ||
|
||
// ExecutableSectionSize represents a section of the executable output file | ||
type ExecutableSectionSize struct { | ||
Name string `json:"name"` | ||
Size int `json:"size"` | ||
MaxSize int `json:"max_size"` | ||
} | ||
|
||
// ExecutablesFileSections is an array of ExecutablesFileSection | ||
type ExecutablesFileSections []ExecutableSectionSize | ||
|
||
// ToRPCExecutableSectionSizeArray transforms this array into a []*rpc.ExecutableSectionSize | ||
func (s ExecutablesFileSections) ToRPCExecutableSectionSizeArray() []*rpc.ExecutableSectionSize { | ||
res := []*rpc.ExecutableSectionSize{} | ||
for _, section := range s { | ||
res = append(res, &rpc.ExecutableSectionSize{ | ||
Name: section.Name, | ||
Size: int64(section.Size), | ||
MaxSize: int64(section.MaxSize), | ||
}) | ||
} | ||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.