|
16 | 16 | package builder |
17 | 17 |
|
18 | 18 | import ( |
19 | | - "github.com/arduino/arduino-cli/legacy/builder/types" |
| 19 | + "github.com/arduino/arduino-cli/arduino/sketch" |
| 20 | + "github.com/arduino/go-paths-helper" |
| 21 | + properties "github.com/arduino/go-properties-orderedmap" |
20 | 22 | "github.com/pkg/errors" |
21 | 23 | ) |
22 | 24 |
|
23 | | -type ContainerBuildOptions struct{} |
24 | | - |
25 | | -func (s *ContainerBuildOptions) Run(ctx *types.Context) error { |
| 25 | +func ContainerBuildOptions( |
| 26 | + hardwareDirs, builtInToolsDirs, otherLibrariesDirs paths.PathList, |
| 27 | + builtInLibrariesDirs, buildPath *paths.Path, |
| 28 | + sketch *sketch.Sketch, |
| 29 | + customBuildProperties []string, |
| 30 | + fqbn string, |
| 31 | + clean bool, |
| 32 | + buildProperties *properties.Map, |
| 33 | +) (string, string, string, error) { |
26 | 34 | buildOptionsJSON, err := CreateBuildOptionsMap( |
27 | | - ctx.HardwareDirs, ctx.BuiltInToolsDirs, ctx.OtherLibrariesDirs, |
28 | | - ctx.BuiltInLibrariesDirs, ctx.Sketch, ctx.CustomBuildProperties, |
29 | | - ctx.FQBN.String(), ctx.BuildProperties.Get("compiler.optimization_flags"), |
| 35 | + hardwareDirs, builtInToolsDirs, otherLibrariesDirs, |
| 36 | + builtInLibrariesDirs, sketch, customBuildProperties, |
| 37 | + fqbn, buildProperties.Get("compiler.optimization_flags"), |
30 | 38 | ) |
31 | 39 | if err != nil { |
32 | | - return errors.WithStack(err) |
| 40 | + return "", "", "", errors.WithStack(err) |
33 | 41 | } |
34 | | - ctx.BuildOptionsJson = buildOptionsJSON |
35 | 42 |
|
36 | | - buildOptionsJsonPrevious, err := LoadPreviousBuildOptionsMap(ctx.BuildPath) |
| 43 | + buildOptionsJSONPrevious, err := LoadPreviousBuildOptionsMap(buildPath) |
37 | 44 | if err != nil { |
38 | | - return errors.WithStack(err) |
| 45 | + return "", "", "", errors.WithStack(err) |
39 | 46 | } |
40 | | - ctx.BuildOptionsJsonPrevious = buildOptionsJsonPrevious |
41 | 47 |
|
42 | 48 | infoOut, err := WipeoutBuildPathIfBuildOptionsChanged( |
43 | | - ctx.Clean, |
44 | | - ctx.BuildPath, |
45 | | - ctx.BuildOptionsJson, |
46 | | - ctx.BuildOptionsJsonPrevious, |
47 | | - ctx.BuildProperties, |
| 49 | + clean, |
| 50 | + buildPath, |
| 51 | + buildOptionsJSON, |
| 52 | + buildOptionsJSONPrevious, |
| 53 | + buildProperties, |
48 | 54 | ) |
49 | 55 | if err != nil { |
50 | | - return errors.WithStack(err) |
51 | | - } |
52 | | - if infoOut != "" { |
53 | | - ctx.Info(infoOut) |
| 56 | + return "", "", "", errors.WithStack(err) |
54 | 57 | } |
55 | 58 |
|
56 | | - return StoreBuildOptionsMap(ctx.BuildPath, ctx.BuildOptionsJson) |
| 59 | + return buildOptionsJSON, buildOptionsJSONPrevious, infoOut, StoreBuildOptionsMap(buildPath, buildOptionsJSON) |
57 | 60 | } |
0 commit comments