Skip to content

Commit 8e1e16b

Browse files
authored
Set runtime.hardware.path property during upload (#1978)
* Added integration test * Set runtime.hardware.path property during upload
1 parent 74da66a commit 8e1e16b

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

Diff for: arduino/cores/cores.go

+1
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ func (release *PlatformRelease) RuntimeProperties() *properties.Map {
337337
res := properties.NewMap()
338338
if release.InstallDir != nil {
339339
res.Set("runtime.platform.path", release.InstallDir.String())
340+
res.Set("runtime.hardware.path", release.InstallDir.Join("..").String())
340341
}
341342

342343
return res
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2022 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to [email protected].
15+
16+
package compile_test
17+
18+
import (
19+
"testing"
20+
21+
"github.com/arduino/arduino-cli/internal/integrationtest"
22+
"github.com/arduino/go-paths-helper"
23+
"github.com/stretchr/testify/require"
24+
)
25+
26+
func TestCompileAndUploadRuntimeProperties(t *testing.T) {
27+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
28+
defer env.CleanUp()
29+
30+
// https://github.com/arduino/arduino-cli/issues/1971
31+
sketchbookHardwareDir := cli.SketchbookDir().Join("hardware")
32+
require.NoError(t, sketchbookHardwareDir.MkdirAll())
33+
34+
// Copy test platform
35+
testPlatform := paths.New("..", "testdata", "foo")
36+
require.NoError(t, testPlatform.CopyDirTo(sketchbookHardwareDir.Join("foo")))
37+
38+
// Install dependencies of the demo platform
39+
_, _, err := cli.Run("core", "update-index")
40+
require.NoError(t, err)
41+
_, _, err = cli.Run("core", "install", "arduino:avr")
42+
require.NoError(t, err)
43+
44+
// Check compile runtime propeties expansion
45+
bareMinimum := cli.CopySketch("bare_minimum")
46+
stdout, _, err := cli.Run("compile", "--fqbn", "foo:avr:bar", "-v", bareMinimum.String())
47+
require.NoError(t, err)
48+
require.Contains(t, string(stdout), "PREBUILD-runtime.hardware.path="+sketchbookHardwareDir.String())
49+
50+
// Check upload runtime propeties expansion
51+
stdout, _, err = cli.Run("upload", "--fqbn", "foo:avr:bar", bareMinimum.String())
52+
require.NoError(t, err)
53+
require.Contains(t, string(stdout), "UPLOAD-runtime.hardware.path="+sketchbookHardwareDir.String())
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
void setup() {}
2+
void loop() {}

Diff for: internal/integrationtest/testdata/foo/avr/boards.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bar.name=Bar
2+
bar.upload.tool=baz
3+
bar.upload.protocol=
4+
bar.build.board=AVR_BAR
5+
bar.build.f_cpu=16000000L
6+
bar.build.mcu=atmega328p
7+
bar.build.core=arduino:arduino
8+
bar.build.variant=arduino:standard
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=Foo Platform
2+
version=0.0.0
3+
4+
recipe.hooks.prebuild.0.pattern=echo PREBUILD-runtime.hardware.path={runtime.hardware.path}
5+
recipe.hooks.prebuild.0.pattern.windows=cmd /C echo PREBUILD-runtime.hardware.path={runtime.hardware.path}
6+
7+
tools.baz.upload.params.quiet=
8+
tools.baz.upload.params.verbose=
9+
tools.baz.upload.pattern=echo UPLOAD-runtime.hardware.path={runtime.hardware.path}
10+
tools.baz.upload.pattern.windows=cmd /C echo UPLOAD-runtime.hardware.path={runtime.hardware.path}

0 commit comments

Comments
 (0)