Skip to content

Commit 7e9a246

Browse files
committed
Refactoring of some legacy properties generation subroutines
1 parent 053c260 commit 7e9a246

15 files changed

+41
-99
lines changed

arduino/cores/packagemanager/package_manager.go

+15
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ package packagemanager
1818
import (
1919
"fmt"
2020
"net/url"
21+
"os"
2122
"path"
23+
"path/filepath"
2224
"strconv"
2325
"strings"
2426
"sync"
@@ -371,6 +373,19 @@ func (pme *Explorer) ResolveFQBN(fqbn *cores.FQBN) (
371373
buildProperties.Set("extra.time.zone", strconv.Itoa(timeutils.TimezoneOffsetNoDST(now)))
372374
buildProperties.Set("extra.time.dst", strconv.Itoa(timeutils.DaylightSavingsOffset(now)))
373375

376+
if !buildProperties.ContainsKey("runtime.ide.path") {
377+
if ex, err := os.Executable(); err == nil {
378+
buildProperties.Set("runtime.ide.path", filepath.Dir(ex))
379+
} else {
380+
buildProperties.Set("runtime.ide.path", "")
381+
}
382+
}
383+
buildProperties.Set("runtime.os", properties.GetOSSuffix())
384+
buildProperties.Set("build.library_discovery_phase", "0")
385+
// Deprecated properties
386+
buildProperties.Set("ide_version", "10607")
387+
buildProperties.Set("runtime.ide.version", "10607")
388+
374389
// No errors... phew!
375390
return targetPackage, platformRelease, board, buildProperties, buildPlatformRelease, nil
376391
}

commands/compile/compile.go

-3
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
174174

175175
builderCtx.BuiltInLibrariesDirs = configuration.IDEBuiltinLibrariesDir(configuration.Settings)
176176

177-
// Will be deprecated.
178-
builderCtx.ArduinoAPIVersion = "10607"
179-
180177
builderCtx.Stdout = outStream
181178
builderCtx.Stderr = errStream
182179
builderCtx.Clean = req.GetClean()

legacy/builder/setup_build_properties.go

-16
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
package builder
1717

1818
import (
19-
"os"
20-
"path/filepath"
21-
2219
"github.com/arduino/arduino-cli/legacy/builder/types"
2320
properties "github.com/arduino/go-properties-orderedmap"
2421
"github.com/pkg/errors"
@@ -42,19 +39,6 @@ func (s *SetupBuildProperties) Run(ctx *types.Context) error {
4239
buildProperties.Set("build.project_name", ctx.Sketch.MainFile.Base())
4340
}
4441

45-
// get base folder and use it to populate BUILD_PROPERTIES_RUNTIME_IDE_PATH (arduino and arduino-builder live in the same dir)
46-
ex, err := os.Executable()
47-
exPath := ""
48-
if err == nil {
49-
exPath = filepath.Dir(ex)
50-
}
51-
52-
buildProperties.Set("runtime.ide.version", ctx.ArduinoAPIVersion)
53-
buildProperties.Set("runtime.ide.path", exPath)
54-
buildProperties.Set("ide_version", ctx.ArduinoAPIVersion)
55-
buildProperties.Set("runtime.os", properties.GetOSSuffix())
56-
buildProperties.Set("build.library_discovery_phase", "0")
57-
5842
if ctx.OptimizeForDebug {
5943
if buildProperties.ContainsKey("compiler.optimization_flags.debug") {
6044
buildProperties.Set("compiler.optimization_flags", buildProperties.Get("compiler.optimization_flags.debug"))

legacy/builder/test/builder_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func prepareBuilderTestContext(t *testing.T, sketchPath *paths.Path, fqbn string
4141
BuiltInToolsDirs: paths.NewPathList("downloaded_tools"),
4242
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
4343
OtherLibrariesDirs: paths.NewPathList("libraries"),
44-
ArduinoAPIVersion: "10600",
4544
Verbose: false,
4645
}
4746
}

legacy/builder/test/create_build_options_map_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func TestCreateBuildOptionsMap(t *testing.T) {
3232
OtherLibrariesDirs: paths.NewPathList("libraries"),
3333
Sketch: &sketch.Sketch{FullPath: paths.New("sketchLocation")},
3434
FQBN: parseFQBN(t, "my:nice:fqbn"),
35-
ArduinoAPIVersion: "ideVersion",
3635
Verbose: true,
3736
BuildPath: paths.New("buildPath"),
3837
OptimizationFlags: "-Os",
@@ -50,7 +49,6 @@ func TestCreateBuildOptionsMap(t *testing.T) {
5049
"fqbn": "my:nice:fqbn",
5150
"hardwareFolders": "hardware,hardware2",
5251
"otherLibrariesFolders": "libraries",
53-
"runtime.ide.version": "ideVersion",
5452
"sketchLocation": "sketchLocation"
5553
}`, ctx.BuildOptionsJson)
5654
}

legacy/builder/test/ctags_runner_test.go

-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func TestCTagsRunner(t *testing.T) {
3838
OtherLibrariesDirs: paths.NewPathList("libraries"),
3939
Sketch: OpenSketch(t, sketchLocation),
4040
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
41-
ArduinoAPIVersion: "10600",
4241
Verbose: true,
4342
}
4443

@@ -88,7 +87,6 @@ func TestCTagsRunnerSketchWithClass(t *testing.T) {
8887
OtherLibrariesDirs: paths.NewPathList("libraries"),
8988
Sketch: OpenSketch(t, sketchLocation),
9089
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
91-
ArduinoAPIVersion: "10600",
9290
Verbose: true,
9391
}
9492

@@ -136,7 +134,6 @@ func TestCTagsRunnerSketchWithTypename(t *testing.T) {
136134
OtherLibrariesDirs: paths.NewPathList("libraries"),
137135
Sketch: OpenSketch(t, sketchLocation),
138136
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
139-
ArduinoAPIVersion: "10600",
140137
Verbose: true,
141138
}
142139

@@ -183,7 +180,6 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) {
183180
OtherLibrariesDirs: paths.NewPathList("libraries"),
184181
Sketch: OpenSketch(t, sketchLocation),
185182
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
186-
ArduinoAPIVersion: "10600",
187183
Verbose: true,
188184
}
189185

@@ -229,7 +225,6 @@ func TestCTagsRunnerSketchWithTemplates(t *testing.T) {
229225
OtherLibrariesDirs: paths.NewPathList("libraries"),
230226
Sketch: OpenSketch(t, sketchLocation),
231227
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
232-
ArduinoAPIVersion: "10600",
233228
Verbose: true,
234229
}
235230

legacy/builder/test/includes_to_include_folders_test.go

-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func TestIncludesToIncludeFolders(t *testing.T) {
3636
OtherLibrariesDirs: paths.NewPathList("libraries"),
3737
Sketch: OpenSketch(t, paths.New("downloaded_libraries", "Bridge", "examples", "Bridge", "Bridge.ino")),
3838
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
39-
ArduinoAPIVersion: "10600",
4039
Verbose: true,
4140
}
4241

@@ -72,7 +71,6 @@ func TestIncludesToIncludeFoldersSketchWithIfDef(t *testing.T) {
7271
OtherLibrariesDirs: paths.NewPathList("libraries"),
7372
Sketch: OpenSketch(t, paths.New("SketchWithIfDef", "SketchWithIfDef.ino")),
7473
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
75-
ArduinoAPIVersion: "10600",
7674
Verbose: true,
7775
}
7876

@@ -107,7 +105,6 @@ func TestIncludesToIncludeFoldersIRremoteLibrary(t *testing.T) {
107105
OtherLibrariesDirs: paths.NewPathList("libraries"),
108106
Sketch: OpenSketch(t, paths.New("sketch9", "sketch9.ino")),
109107
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
110-
ArduinoAPIVersion: "10600",
111108
Verbose: true,
112109
}
113110

@@ -145,7 +142,6 @@ func TestIncludesToIncludeFoldersANewLibrary(t *testing.T) {
145142
OtherLibrariesDirs: paths.NewPathList("libraries"),
146143
Sketch: OpenSketch(t, paths.New("sketch10", "sketch10.ino")),
147144
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
148-
ArduinoAPIVersion: "10600",
149145
Verbose: true,
150146
}
151147

@@ -179,7 +175,6 @@ func TestIncludesToIncludeFoldersDuplicateLibs(t *testing.T) {
179175
BuiltInLibrariesDirs: paths.New("downloaded_libraries"),
180176
Sketch: OpenSketch(t, paths.New("user_hardware", "my_avr_platform", "avr", "libraries", "SPI", "examples", "BarometricPressureSensor", "BarometricPressureSensor.ino")),
181177
FQBN: parseFQBN(t, "my_avr_platform:avr:custom_yun"),
182-
ArduinoAPIVersion: "10600",
183178
Verbose: true,
184179
}
185180

@@ -217,7 +212,6 @@ func TestIncludesToIncludeFoldersDuplicateLibsWithConflictingLibsOutsideOfPlatfo
217212
OtherLibrariesDirs: paths.NewPathList("libraries"),
218213
Sketch: OpenSketch(t, paths.New("user_hardware", "my_avr_platform", "avr", "libraries", "SPI", "examples", "BarometricPressureSensor", "BarometricPressureSensor.ino")),
219214
FQBN: parseFQBN(t, "my_avr_platform:avr:custom_yun"),
220-
ArduinoAPIVersion: "10600",
221215
Verbose: true,
222216
}
223217

@@ -255,7 +249,6 @@ func TestIncludesToIncludeFoldersDuplicateLibs2(t *testing.T) {
255249
OtherLibrariesDirs: paths.NewPathList("libraries"),
256250
Sketch: OpenSketch(t, paths.New("sketch_usbhost", "sketch_usbhost.ino")),
257251
FQBN: parseFQBN(t, "arduino:samd:arduino_zero_native"),
258-
ArduinoAPIVersion: "10600",
259252
Verbose: true,
260253
}
261254

@@ -293,7 +286,6 @@ func TestIncludesToIncludeFoldersSubfolders(t *testing.T) {
293286
OtherLibrariesDirs: paths.NewPathList("libraries"),
294287
Sketch: OpenSketch(t, paths.New("sketch_with_subfolders", "sketch_with_subfolders.ino")),
295288
FQBN: parseFQBN(t, "arduino:avr:leonardo"),
296-
ArduinoAPIVersion: "10600",
297289
Verbose: true,
298290
}
299291

legacy/builder/test/load_vid_pid_specific_properties_test.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ func TestLoadVIDPIDSpecificPropertiesWhenNoVIDPIDAreProvided(t *testing.T) {
2929
DownloadCoresAndToolsAndLibraries(t)
3030

3131
ctx := &types.Context{
32-
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
33-
BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "./tools_builtin"),
34-
Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")),
35-
FQBN: parseFQBN(t, "arduino:avr:micro"),
36-
ArduinoAPIVersion: "10600",
32+
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
33+
BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "./tools_builtin"),
34+
Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")),
35+
FQBN: parseFQBN(t, "arduino:avr:micro"),
3736
}
3837

3938
buildPath := SetupBuildPath(t, ctx)
@@ -59,11 +58,10 @@ func TestLoadVIDPIDSpecificProperties(t *testing.T) {
5958
DownloadCoresAndToolsAndLibraries(t)
6059

6160
ctx := &types.Context{
62-
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
63-
BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "./tools_builtin"),
64-
Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")),
65-
FQBN: parseFQBN(t, "arduino:avr:micro"),
66-
ArduinoAPIVersion: "10600",
61+
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
62+
BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "./tools_builtin"),
63+
Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")),
64+
FQBN: parseFQBN(t, "arduino:avr:micro"),
6765
}
6866

6967
buildPath := SetupBuildPath(t, ctx)

legacy/builder/test/merge_sketch_with_bootloader_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func TestMergeSketchWithBootloader(t *testing.T) {
3838
OtherLibrariesDirs: paths.NewPathList("libraries"),
3939
Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")),
4040
FQBN: parseFQBN(t, "arduino:avr:uno"),
41-
ArduinoAPIVersion: "10600",
4241
}
4342

4443
buildPath := SetupBuildPath(t, ctx)
@@ -108,7 +107,6 @@ func TestMergeSketchWithBootloaderSketchInBuildPath(t *testing.T) {
108107
OtherLibrariesDirs: paths.NewPathList("libraries"),
109108
Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")),
110109
FQBN: parseFQBN(t, "arduino:avr:uno"),
111-
ArduinoAPIVersion: "10600",
112110
}
113111

114112
buildPath := SetupBuildPath(t, ctx)
@@ -179,7 +177,6 @@ func TestMergeSketchWithBootloaderWhenNoBootloaderAvailable(t *testing.T) {
179177
OtherLibrariesDirs: paths.NewPathList("libraries"),
180178
Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")),
181179
FQBN: parseFQBN(t, "arduino:avr:uno"),
182-
ArduinoAPIVersion: "10600",
183180
}
184181

185182
buildPath := SetupBuildPath(t, ctx)
@@ -217,7 +214,6 @@ func TestMergeSketchWithBootloaderPathIsParameterized(t *testing.T) {
217214
OtherLibrariesDirs: paths.NewPathList("libraries"),
218215
Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")),
219216
FQBN: parseFQBN(t, "my_avr_platform:avr:mymega:cpu=atmega2560"),
220-
ArduinoAPIVersion: "10600",
221217
}
222218

223219
buildPath := SetupBuildPath(t, ctx)

0 commit comments

Comments
 (0)