Skip to content

Commit 34474dc

Browse files
committed
stop using SketchLoader command in container setup
1 parent a32e90a commit 34474dc

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

legacy/builder/container_setup.go

+30-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
package builder
3131

3232
import (
33+
bldr "github.com/arduino/arduino-cli/arduino/builder"
3334
"github.com/arduino/arduino-cli/legacy/builder/builder_utils"
3435
"github.com/arduino/arduino-cli/legacy/builder/i18n"
3536
"github.com/arduino/arduino-cli/legacy/builder/types"
37+
"github.com/arduino/go-paths-helper"
3638
)
3739

3840
type ContainerSetupHardwareToolsLibsSketchAndProps struct{}
@@ -48,7 +50,34 @@ func (s *ContainerSetupHardwareToolsLibsSketchAndProps) Run(ctx *types.Context)
4850
&ToolsLoader{},
4951
&AddBuildBoardPropertyIfMissing{},
5052
&LibrariesLoader{},
51-
&SketchLoader{},
53+
}
54+
55+
ctx.Progress.Steps = ctx.Progress.Steps / float64(len(commands))
56+
57+
for _, command := range commands {
58+
builder_utils.PrintProgressIfProgressEnabledAndMachineLogger(ctx)
59+
PrintRingNameIfDebug(ctx, command)
60+
err := command.Run(ctx)
61+
if err != nil {
62+
return i18n.WrapError(err)
63+
}
64+
}
65+
66+
// get abs path to sketch
67+
sketchLocation, err := ctx.SketchLocation.Abs()
68+
if err != nil {
69+
return i18n.WrapError(err)
70+
}
71+
72+
// load sketch
73+
sketch, err := bldr.LoadSketch(sketchLocation.String(), ctx.BuildPath.String())
74+
if err != nil {
75+
return i18n.WrapError(err)
76+
}
77+
ctx.SketchLocation = paths.New(sketch.MainFile.Path)
78+
ctx.Sketch = types.SketchToLegacy(sketch)
79+
80+
commands = []types.Command{
5281
&SetupBuildProperties{},
5382
&LoadVIDPIDSpecificProperties{},
5483
&SetCustomBuildProperties{},

legacy/builder/types/types.go

+25
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"strconv"
3535

3636
"github.com/arduino/arduino-cli/arduino/libraries"
37+
"github.com/arduino/arduino-cli/arduino/sketch"
3738
paths "github.com/arduino/go-paths-helper"
3839
)
3940

@@ -123,6 +124,30 @@ type Sketch struct {
123124
AdditionalFiles []SketchFile
124125
}
125126

127+
func SketchToLegacy(sketch *sketch.Sketch) *Sketch {
128+
s := &Sketch{}
129+
s.MainFile = SketchFile{
130+
paths.New(sketch.MainFile.Path),
131+
string(sketch.MainFile.Source),
132+
}
133+
134+
for _, item := range sketch.OtherSketchFiles {
135+
s.OtherSketchFiles = append(s.OtherSketchFiles, SketchFile{
136+
paths.New(item.Path),
137+
string(item.Source),
138+
})
139+
}
140+
141+
for _, item := range sketch.AdditionalFiles {
142+
s.AdditionalFiles = append(s.AdditionalFiles, SketchFile{
143+
paths.New(item.Path),
144+
string(item.Source),
145+
})
146+
}
147+
148+
return s
149+
}
150+
126151
type PlatforKeysRewrite struct {
127152
Rewrites []PlatforKeyRewrite
128153
}

0 commit comments

Comments
 (0)