Skip to content

[breaking] Remove auto detection of Arduino IDE built-in libraries and tools / Allow gRPC install of built-in libraries #1817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed nil pointer exception in build options extraction
  • Loading branch information
cmaglie committed Sep 1, 2022
commit 1bcfd732a1f98b54c59c35edfc4939debf502a82
8 changes: 5 additions & 3 deletions legacy/builder/libraries_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ func (s *LibrariesLoader) Run(ctx *types.Context) error {
ctx.LibrariesManager = lm

builtInLibrariesFolders := ctx.BuiltInLibrariesDirs
if err := builtInLibrariesFolders.ToAbs(); err != nil {
return errors.WithStack(err)
if builtInLibrariesFolders != nil {
if err := builtInLibrariesFolders.ToAbs(); err != nil {
return errors.WithStack(err)
}
lm.AddLibrariesDir(builtInLibrariesFolders, libraries.IDEBuiltIn)
}
lm.AddLibrariesDir(builtInLibrariesFolders, libraries.IDEBuiltIn)

if ctx.ActualPlatform != ctx.TargetPlatform {
lm.AddPlatformReleaseLibrariesDir(ctx.ActualPlatform, libraries.ReferencedPlatformBuiltIn)
Expand Down
1 change: 0 additions & 1 deletion legacy/builder/test/create_build_options_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func TestCreateBuildOptionsMap(t *testing.T) {

require.Equal(t, `{
"additionalFiles": "",
"builtInLibrariesFolders": "",
"builtInToolsFolders": "tools",
"compiler.optimization_flags": "-Os",
"customBuildProperties": "",
Expand Down
4 changes: 3 additions & 1 deletion legacy/builder/types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ func (ctx *Context) ExtractBuildOptions() *properties.Map {
opts := properties.NewMap()
opts.Set("hardwareFolders", strings.Join(ctx.HardwareDirs.AsStrings(), ","))
opts.Set("builtInToolsFolders", strings.Join(ctx.BuiltInToolsDirs.AsStrings(), ","))
opts.Set("builtInLibrariesFolders", ctx.BuiltInLibrariesDirs.String())
if ctx.BuiltInLibrariesDirs != nil {
opts.Set("builtInLibrariesFolders", ctx.BuiltInLibrariesDirs.String())
}
opts.Set("otherLibrariesFolders", strings.Join(ctx.OtherLibrariesDirs.AsStrings(), ","))
opts.SetPath("sketchLocation", ctx.SketchLocation)
var additionalFilesRelative []string
Expand Down
61 changes: 61 additions & 0 deletions legacy/builder/types/context_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// This file is part of arduino-cli.
//
// Copyright 2022 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 [email protected].

package types

import (
"testing"

"github.com/arduino/arduino-cli/arduino/cores"
paths "github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
)

func TestInjectBuildOption(t *testing.T) {
fqbn, err := cores.ParseFQBN("aaa:bbb:ccc")
require.NoError(t, err)

{
ctx := &Context{
HardwareDirs: paths.NewPathList("aaa", "bbb"),
BuiltInToolsDirs: paths.NewPathList("ccc", "ddd"),
BuiltInLibrariesDirs: paths.New("eee"),
OtherLibrariesDirs: paths.NewPathList("fff", "ggg"),
SketchLocation: paths.New("hhh"),
FQBN: fqbn,
ArduinoAPIVersion: "iii",
CustomBuildProperties: []string{"jjj", "kkk"},
OptimizationFlags: "lll",
}
newCtx := &Context{}
newCtx.InjectBuildOptions(ctx.ExtractBuildOptions())
require.Equal(t, ctx, newCtx)
}
{
ctx := &Context{
HardwareDirs: paths.NewPathList("aaa", "bbb"),
BuiltInToolsDirs: paths.NewPathList("ccc", "ddd"),
OtherLibrariesDirs: paths.NewPathList("fff", "ggg"),
SketchLocation: paths.New("hhh"),
FQBN: fqbn,
ArduinoAPIVersion: "iii",
CustomBuildProperties: []string{"jjj", "kkk"},
OptimizationFlags: "lll",
}
newCtx := &Context{}
newCtx.InjectBuildOptions(ctx.ExtractBuildOptions())
require.Equal(t, ctx, newCtx)
}
}