Commit 52642458 authored by Cristian Maglie's avatar Cristian Maglie Committed by Cristian Maglie

Allow multiple instances of the same 'required_tool' in cores

Fix #166
parent 7e255e96
......@@ -403,16 +403,17 @@ func (pm *PackageManager) FindToolsRequiredForBoard(board *cores.Board) ([]*core
}
// replace the default tools above with the specific required by the current platform
requiredTools := []*cores.ToolRelease{}
for _, toolDep := range platform.Dependencies {
pm.Log.WithField("tool", toolDep).Infof("Required tool")
tool := pm.FindToolDependency(toolDep)
if tool == nil {
return nil, fmt.Errorf("tool release not found: %s", toolDep)
}
foundTools[tool.Tool.Name] = tool
requiredTools = append(requiredTools, tool)
delete(foundTools, tool.Tool.Name)
}
requiredTools := []*cores.ToolRelease{}
for _, toolRel := range foundTools {
requiredTools = append(requiredTools, toolRel)
}
......
......@@ -21,14 +21,13 @@ import (
"net/url"
"testing"
"go.bug.st/relaxed-semver"
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/configs"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-properties-orderedmap"
"github.com/stretchr/testify/require"
semver "go.bug.st/relaxed-semver"
)
var customHardware = paths.New("testdata", "custom_hardware")
......@@ -102,6 +101,7 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
}
loadIndex("https://dl.espressif.com/dl/package_esp32_index.json")
loadIndex("http://arduino.esp8266.com/stable/package_esp8266com_index.json")
loadIndex("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json")
require.NoError(t, pm.LoadHardware(conf))
esp32, err := pm.FindBoardWithFQBN("esp32:esp32:esp32")
require.NoError(t, err)
......@@ -138,4 +138,28 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
testConflictingToolsInDifferentPackages()
testConflictingToolsInDifferentPackages()
testConflictingToolsInDifferentPackages()
feather, err := pm.FindBoardWithFQBN("adafruit:samd:adafruit_feather_m0_express")
require.NoError(t, err)
require.NotNil(t, feather)
featherTools, err := pm.FindToolsRequiredForBoard(feather)
require.NoError(t, err)
require.NotNil(t, featherTools)
// Test when a package index requires two different version of the same tool
// See: https://github.com/arduino/arduino-cli/issues/166#issuecomment-528295989
bossac17 := pm.FindToolDependency(&cores.ToolDependency{
ToolPackager: "arduino",
ToolName: "bossac",
ToolVersion: semver.ParseRelaxed("1.7.0"),
})
require.NotNil(t, bossac17)
bossac18 := pm.FindToolDependency(&cores.ToolDependency{
ToolPackager: "arduino",
ToolName: "bossac",
ToolVersion: semver.ParseRelaxed("1.8.0-48-gb176eee"),
})
require.NotNil(t, bossac18)
require.Contains(t, featherTools, bossac17)
require.Contains(t, featherTools, bossac18)
}
This source diff could not be displayed because it is too large. You can view the blob instead.
SerialGSM KEYWORD1
SerialSARA KEYWORD1
INPUT_PULLDOWN LITERAL1 Constants RESERVED_WORD_2
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
adafruit_jlink.name=J-Link over OpenOCD
adafruit_jlink.communication=USB
adafruit_jlink.protocol=jlink
adafruit_jlink.program.protocol=jlink
adafruit_jlink.program.tool=openocd
adafruit_jlink.program.setup_command=interface jlink; transport select swd; reset_config none separate; set WORKAREASIZE 0;
adafruit_atmel_ice.name=Atmel-ICE over OpenOCD
adafruit_atmel_ice.communication=USB
adafruit_atmel_ice.protocol=cmsis-dap
adafruit_atmel_ice.program.protocol=cmsis-dap
adafruit_atmel_ice.program.tool=openocd
adafruit_atmel_ice.program.setup_command=cmsis_dap_vid_pid 0x03eb 0x2141; transport select swd;
\ No newline at end of file
......@@ -116,6 +116,7 @@ func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStr
if requiredTools, err := pm.FindToolsRequiredForBoard(board); err == nil {
for _, requiredTool := range requiredTools {
logrus.WithField("tool", requiredTool).Info("Tool required for upload")
uploadProperties.Merge(requiredTool.RuntimeProperties())
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment