diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index c1c8d86ed6d..a23a0f75b5b 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -51,6 +51,11 @@ $ arduino-cli outdated --format json } ``` +### Command `compile` does not support `--vid-pid` flag anymore + +It was a legacy and undocumented feature that is now useless. The correspondin field in gRPC `CompileRequest.vid_pid` +has been removed as well. + ### golang API: method `github.com/arduino/arduino-cli/arduino/libraries/Library.LocationPriorityFor` removed That method was outdated and must not be used. diff --git a/internal/cli/compile/compile.go b/internal/cli/compile/compile.go index 318fc021dc3..9695bc19e98 100644 --- a/internal/cli/compile/compile.go +++ b/internal/cli/compile/compile.go @@ -78,7 +78,6 @@ var ( warnings string // Used to tell gcc which warning level to use. verbose bool // Turns on verbose mode. quiet bool // Suppresses almost every output. - vidPid string // VID/PID specific build properties. uploadAfterCompile bool // Upload the binary after the compilation. portArgs arguments.Port // Upload port, e.g.: COM10 or /dev/ttyACM0. verify bool // Upload, verify uploaded binary after the upload. @@ -145,7 +144,6 @@ func NewCommand() *cobra.Command { compileCommand.Flags().BoolVarP(&uploadAfterCompile, "upload", "u", false, tr("Upload the binary after the compilation.")) portArgs.AddToCommand(compileCommand) compileCommand.Flags().BoolVarP(&verify, "verify", "t", false, tr("Verify uploaded binary after the upload.")) - compileCommand.Flags().StringVar(&vidPid, "vid-pid", "", tr("When specified, VID/PID specific build properties are used, if board supports them.")) compileCommand.Flags().StringSliceVar(&library, "library", []string{}, tr("Path to a single library’s root folder. Can be used multiple times or entries can be comma separated.")) compileCommand.Flags().StringSliceVar(&libraries, "libraries", []string{}, @@ -240,7 +238,6 @@ func runCompileCommand(cmd *cobra.Command, args []string) { Warnings: warnings, Verbose: verbose, Quiet: quiet, - VidPid: vidPid, ExportDir: exportDir, Libraries: libraries, OptimizeForDebug: optimizeForDebug, diff --git a/legacy/builder/constants/constants.go b/legacy/builder/constants/constants.go index 5d7d3bb45a5..47d7a95c652 100644 --- a/legacy/builder/constants/constants.go +++ b/legacy/builder/constants/constants.go @@ -32,12 +32,10 @@ const BUILD_PROPERTIES_FQBN = "build.fqbn" const BUILD_PROPERTIES_INCLUDES = "includes" const BUILD_PROPERTIES_OBJECT_FILE = "object_file" const BUILD_PROPERTIES_PATTERN = "pattern" -const BUILD_PROPERTIES_PID = "pid" const BUILD_PROPERTIES_PREPROCESSED_FILE_PATH = "preprocessed_file_path" const BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH = "runtime.platform.path" const BUILD_PROPERTIES_SOURCE_FILE = "source_file" const BUILD_PROPERTIES_TOOLS_KEY = "tools" -const BUILD_PROPERTIES_VID = "vid" const CTAGS = "ctags" const EMPTY_STRING = "" const FILE_CTAGS_TARGET_FOR_GCC_MINUS_E = "ctags_target_for_gcc_minus_e.cpp" diff --git a/legacy/builder/container_setup.go b/legacy/builder/container_setup.go index c48e3a1d0bf..1b76ad8eb1d 100644 --- a/legacy/builder/container_setup.go +++ b/legacy/builder/container_setup.go @@ -52,7 +52,6 @@ func (s *ContainerSetupHardwareToolsLibsSketchAndProps) Run(ctx *types.Context) commands = []types.Command{ &SetupBuildProperties{}, - &LoadVIDPIDSpecificProperties{}, &SetCustomBuildProperties{}, &AddMissingBuildPropertiesFromParentPlatformTxtFiles{}, } diff --git a/legacy/builder/load_vid_pid_specific_properties.go b/legacy/builder/load_vid_pid_specific_properties.go deleted file mode 100644 index 7cf0f5c517b..00000000000 --- a/legacy/builder/load_vid_pid_specific_properties.go +++ /dev/null @@ -1,66 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package builder - -import ( - "strconv" - "strings" - - "github.com/arduino/arduino-cli/legacy/builder/constants" - "github.com/arduino/arduino-cli/legacy/builder/types" - "github.com/arduino/go-properties-orderedmap" - "github.com/pkg/errors" -) - -type LoadVIDPIDSpecificProperties struct{} - -func (s *LoadVIDPIDSpecificProperties) Run(ctx *types.Context) error { - if ctx.USBVidPid == "" { - return nil - } - - vidPid := ctx.USBVidPid - vidPid = strings.ToLower(vidPid) - vidPidParts := strings.Split(vidPid, "_") - vid := vidPidParts[0] - pid := vidPidParts[1] - - buildProperties := ctx.BuildProperties - VIDPIDIndex, err := findVIDPIDIndex(buildProperties, vid, pid) - if err != nil { - return errors.WithStack(err) - } - if VIDPIDIndex < 0 { - return nil - } - - vidPidSpecificProperties := buildProperties.SubTree(constants.BUILD_PROPERTIES_VID).SubTree(strconv.Itoa(VIDPIDIndex)) - buildProperties.Merge(vidPidSpecificProperties) - - return nil -} - -func findVIDPIDIndex(buildProperties *properties.Map, vid, pid string) (int, error) { - for key, value := range buildProperties.SubTree(constants.BUILD_PROPERTIES_VID).AsMap() { - if !strings.Contains(key, ".") { - if vid == strings.ToLower(value) && pid == strings.ToLower(buildProperties.Get(constants.BUILD_PROPERTIES_PID+"."+key)) { - return strconv.Atoi(key) - } - } - } - - return -1, nil -} diff --git a/legacy/builder/test/load_vid_pid_specific_properties_test.go b/legacy/builder/test/load_vid_pid_specific_properties_test.go deleted file mode 100644 index 0152310605a..00000000000 --- a/legacy/builder/test/load_vid_pid_specific_properties_test.go +++ /dev/null @@ -1,87 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -package test - -import ( - "path/filepath" - "testing" - - "github.com/arduino/arduino-cli/legacy/builder" - "github.com/arduino/arduino-cli/legacy/builder/types" - paths "github.com/arduino/go-paths-helper" - "github.com/stretchr/testify/require" -) - -func TestLoadVIDPIDSpecificPropertiesWhenNoVIDPIDAreProvided(t *testing.T) { - DownloadCoresAndToolsAndLibraries(t) - - ctx := &types.Context{ - HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"), - BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "./tools_builtin"), - Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")), - FQBN: parseFQBN(t, "arduino:avr:micro"), - } - - buildPath := SetupBuildPath(t, ctx) - defer buildPath.RemoveAll() - - commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - } - - for _, command := range commands { - err := command.Run(ctx) - NoError(t, err) - } - - buildProperties := ctx.BuildProperties - - require.Equal(t, "0x0037", buildProperties.Get("pid.0")) - require.Equal(t, "\"Genuino Micro\"", buildProperties.Get("vid.4.build.usb_product")) - require.Equal(t, "0x8037", buildProperties.Get("build.pid")) -} - -func TestLoadVIDPIDSpecificProperties(t *testing.T) { - DownloadCoresAndToolsAndLibraries(t) - - ctx := &types.Context{ - HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"), - BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "./tools_builtin"), - Sketch: OpenSketch(t, paths.New("sketch1", "sketch1.ino")), - FQBN: parseFQBN(t, "arduino:avr:micro"), - } - - buildPath := SetupBuildPath(t, ctx) - defer buildPath.RemoveAll() - - ctx.USBVidPid = "0x2341_0x0237" - - commands := []types.Command{ - &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, - } - - for _, command := range commands { - err := command.Run(ctx) - NoError(t, err) - } - - buildProperties := ctx.BuildProperties - - require.Equal(t, "0x0037", buildProperties.Get("pid.0")) - require.Equal(t, "\"Genuino Micro\"", buildProperties.Get("vid.4.build.usb_product")) - require.Equal(t, "0x2341", buildProperties.Get("build.vid")) - require.Equal(t, "0x8237", buildProperties.Get("build.pid")) -} diff --git a/legacy/builder/types/context.go b/legacy/builder/types/context.go index 04cb16a4324..0b78872ab33 100644 --- a/legacy/builder/types/context.go +++ b/legacy/builder/types/context.go @@ -88,7 +88,6 @@ type Context struct { TargetPackage *cores.Package TargetPlatform *cores.PlatformRelease ActualPlatform *cores.PlatformRelease - USBVidPid string PlatformKeyRewrites PlatforKeysRewrite HardwareRewriteResults map[*cores.PlatformRelease][]PlatforKeyRewrite