Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b8c927b

Browse filesBrowse files
authored
Improved {build.*.platform.path} vars enumeration. (#2652)
* Improved build.*.platform.path vars enumeration * Updated docs * Added tests * Added a compatibility note
1 parent 8b6ad25 commit b8c927b
Copy full SHA for b8c927b

File tree

6 files changed

+74
-7
lines changed
Filter options

6 files changed

+74
-7
lines changed

‎docs/platform-specification.md

Copy file name to clipboardExpand all lines: docs/platform-specification.md
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ suffixes are `.linux`, `.windows` and `.macosx`.
8383

8484
The following automatically generated properties can be used globally in all configuration files:
8585

86-
- `{runtime.platform.path}`: the absolute path of the [board platform](#platform-terminology) folder (i.e. the folder
87-
containing boards.txt)
86+
- `{runtime.platform.path}`: is the absolute path of the [board platform](#platform-terminology) folder (i.e. the folder
87+
containing boards.txt) unless `{runtime.use_core_platform_path_for_runtime_platform_path}` is set to `true` in this
88+
case, the value is the absolute path of the referenced core platform.
8889
- `{runtime.hardware.path}`: the absolute path of the hardware folder (i.e. the folder containing the
8990
[board platform](#platform-terminology) folder)
9091
- `{runtime.ide.path}`: the absolute path of the Arduino IDE or Arduino CLI folder
@@ -113,8 +114,11 @@ The following automatically generated properties can be used globally in all con
113114
- `{extra.time.zone}`: local timezone offset without the DST component
114115
- `{extra.time.dst}`: local daylight savings time offset
115116

116-
Compatibility note: Versions before Arduino IDE 1.6.0 only used one digit per version number component in
117-
`{runtime.ide.version}` (so 1.5.9 was `159`, not `10509`).
117+
Compatibility notes:
118+
119+
- Versions before Arduino IDE 1.6.0 only used one digit per version number component in `{runtime.ide.version}` (so
120+
1.5.9 was `159`, not `10509`).
121+
- `{runtime.use_core_platform_path_for_runtime_platform_path}` support is available from Arduino CLI >=1.0.4.
118122

119123
## platform.txt
120124

@@ -534,6 +538,9 @@ This explains the presence of **{build.mcu}** or **{build.board}** in the platfo
534538
overwritten respectively by **{uno.build.mcu}** and **{uno.build.board}** when the Uno board is selected! Moreover the
535539
following properties are automatically generated:
536540

541+
- `{build.board.platform.path}`: The path to the selected board's platform. (available since Arduino CLI >=1.0.4)
542+
- `{build.core.platform.path}`: The path to the core's platform. It may differ from the board's platform path because
543+
the latter may reference a core from another platform. (available since Arduino CLI >=1.0.4)
537544
- `{build.core.path}`: The path to the selected board's core folder (inside the [core platform](#platform-terminology),
538545
for example hardware/arduino/avr/core/arduino)
539546
- `{build.system.path}`: The path to the [core platform](#platform-terminology)'s system folder if available (for

‎go.mod

Copy file name to clipboardExpand all lines: go.mod
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ require (
3737
go.bug.st/cleanup v1.0.0
3838
go.bug.st/downloader/v2 v2.2.0
3939
go.bug.st/relaxed-semver v0.12.0
40-
go.bug.st/testifyjson v1.1.1
40+
go.bug.st/testifyjson v1.2.0
4141
golang.org/x/term v0.22.0
4242
golang.org/x/text v0.16.0
4343
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157

‎go.sum

Copy file name to clipboardExpand all lines: go.sum
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ go.bug.st/relaxed-semver v0.12.0 h1:se8v3lTdAAFp68+/RS/0Y/nFdnpdzkP5ICY04SPau4E=
219219
go.bug.st/relaxed-semver v0.12.0/go.mod h1:Cpcbiig6Omwlq6bS7i3MQWiqS7W7HDd8CAnZFC40Cl0=
220220
go.bug.st/serial v1.6.1 h1:VSSWmUxlj1T/YlRo2J104Zv3wJFrjHIl/T3NeruWAHY=
221221
go.bug.st/serial v1.6.1/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE=
222-
go.bug.st/testifyjson v1.1.1 h1:nHotIMK151LF3vYsU/b2RaoVaWCgrf2kvQeGNoZkGaA=
223-
go.bug.st/testifyjson v1.1.1/go.mod h1:nZyy2icFbv3OE3zW3mGVOnC/GhWgb93LRu+29n2tJlI=
222+
go.bug.st/testifyjson v1.2.0 h1:0pAfOUMVCOJ6bb9JcC4UmnACjxwxv2Ojb6Z9chaQBjg=
223+
go.bug.st/testifyjson v1.2.0/go.mod h1:nZyy2icFbv3OE3zW3mGVOnC/GhWgb93LRu+29n2tJlI=
224224
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
225225
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
226226
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=

‎internal/arduino/cores/packagemanager/package_manager.go

Copy file name to clipboardExpand all lines: internal/arduino/cores/packagemanager/package_manager.go
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,17 @@ func (pme *Explorer) ResolveFQBN(fqbn *cores.FQBN) (
372372

373373
// Add runtime build properties
374374
buildProperties.Merge(boardPlatformRelease.RuntimeProperties())
375+
buildProperties.SetPath("build.board.platform.path", boardPlatformRelease.InstallDir)
376+
buildProperties.SetPath("build.core.platform.path", corePlatformRelease.InstallDir)
375377
buildProperties.SetPath("build.core.path", corePlatformRelease.InstallDir.Join("cores", core))
376378
buildProperties.SetPath("build.system.path", corePlatformRelease.InstallDir.Join("system"))
377379
buildProperties.Set("build.variant.path", "")
378380
if variant != "" {
379381
buildProperties.SetPath("build.variant.path", variantPlatformRelease.InstallDir.Join("variants", variant))
380382
}
383+
if buildProperties.GetBoolean("runtime.use_core_platform_path_for_runtime_platform_path") {
384+
buildProperties.Set("runtime.platform.path", buildProperties.Get("build.core.platform.path"))
385+
}
381386

382387
for _, tool := range pme.GetAllInstalledToolsReleases() {
383388
buildProperties.Merge(tool.RuntimeProperties())

‎internal/integrationtest/core/core_test.go

Copy file name to clipboardExpand all lines: internal/integrationtest/core/core_test.go
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package core_test
1818
import (
1919
"crypto/md5"
2020
"encoding/hex"
21+
"encoding/json"
2122
"fmt"
2223
"os"
2324
"path/filepath"
@@ -1303,3 +1304,50 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
13031304
require.Contains(t, lines, []string{"incompatible_vendor:avr", "n/a", "Incompatible", "Boards"})
13041305
}
13051306
}
1307+
1308+
func TestReferencedCoreBuildAndRuntimeProperties(t *testing.T) {
1309+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
1310+
defer env.CleanUp()
1311+
1312+
_, _, err := cli.Run("core", "install", "arduino:avr@1.8.6")
1313+
require.NoError(t, err)
1314+
1315+
testSketchbook, err := paths.New("testdata", "sketchbook_with_extended_platform").Abs()
1316+
require.NoError(t, err)
1317+
1318+
// Install custom platform
1319+
err = testSketchbook.Join("hardware").CopyDirTo(cli.SketchbookDir().Join("hardware"))
1320+
require.NoError(t, err)
1321+
1322+
// Determine some useful paths
1323+
boardPlatformPath := cli.SketchbookDir().Join("hardware", "test", "avr").String()
1324+
corePlatformPath := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.6").String()
1325+
corePath := cli.DataDir().Join("packages", "arduino", "hardware", "avr", "1.8.6", "cores", "arduino").String()
1326+
1327+
jsonEncode := func(in string) string {
1328+
enc, err := json.Marshal(in)
1329+
require.NoError(t, err)
1330+
return string(enc)
1331+
}
1332+
1333+
// Check runtime variables are populated correctly
1334+
{
1335+
outJson, _, err := cli.Run("board", "details", "-b", "test:avr:test", "--show-properties", "--json")
1336+
require.NoError(t, err)
1337+
out := requirejson.Parse(t, outJson).Query(".build_properties")
1338+
out.ArrayMustContain(jsonEncode("build.board.platform.path=" + boardPlatformPath))
1339+
out.ArrayMustContain(jsonEncode("build.core.platform.path=" + corePlatformPath))
1340+
out.ArrayMustContain(jsonEncode("build.core.path=" + corePath))
1341+
out.ArrayMustContain(jsonEncode("runtime.platform.path=" + boardPlatformPath))
1342+
}
1343+
{
1344+
outJson, _, err := cli.Run("board", "details", "-b", "test:avr:test2", "--show-properties", "--json")
1345+
require.NoError(t, err)
1346+
out := requirejson.Parse(t, outJson).Query(".build_properties")
1347+
out.ArrayMustContain(jsonEncode("build.board.platform.path=" + boardPlatformPath))
1348+
out.ArrayMustContain(jsonEncode("build.core.platform.path=" + corePlatformPath))
1349+
out.ArrayMustContain(jsonEncode("build.core.path=" + corePath))
1350+
// https://github.com/arduino/arduino-cli/issues/2616
1351+
out.ArrayMustContain(jsonEncode("runtime.platform.path=" + corePlatformPath))
1352+
}
1353+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
test.name=Test Board
3+
test.build.core=arduino:arduino
4+
5+
test2.name=Test 2 Board
6+
test2.build.core=arduino:arduino
7+
test2.runtime.use_core_platform_path_for_runtime_platform_path=true

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.