diff --git a/arduino/builder/libraries.go b/arduino/builder/libraries.go index 445dcbd46af..fcd896fb9d9 100644 --- a/arduino/builder/libraries.go +++ b/arduino/builder/libraries.go @@ -22,6 +22,7 @@ import ( "github.com/arduino/arduino-cli/arduino/builder/cpp" "github.com/arduino/arduino-cli/arduino/builder/progress" "github.com/arduino/arduino-cli/arduino/builder/utils" + "github.com/arduino/arduino-cli/arduino/cores" "github.com/arduino/arduino-cli/arduino/libraries" f "github.com/arduino/arduino-cli/internal/algorithms" rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" @@ -320,3 +321,25 @@ func (b *Builder) RemoveUnusedCompiledLibraries(importedLibraries libraries.List return nil } + +// WarnAboutArchIncompatibleLibraries fixdoc +func (b *Builder) WarnAboutArchIncompatibleLibraries( + targetPlatform *cores.PlatformRelease, + importedLibraries libraries.List, +) { + archs := []string{targetPlatform.Platform.Architecture} + overrides, _ := b.buildProperties.GetOk("architecture.override_check") + if overrides != "" { + archs = append(archs, strings.Split(overrides, ",")...) + } + + for _, importedLibrary := range importedLibraries { + if !importedLibrary.SupportsAnyArchitectureIn(archs...) { + b.logger.Info( + tr("WARNING: library %[1]s claims to run on %[2]s architecture(s) and may be incompatible with your current board which runs on %[3]s architecture(s).", + importedLibrary.Name, + strings.Join(importedLibrary.Architectures, ", "), + strings.Join(archs, ", "))) + } + } +} diff --git a/legacy/builder/builder.go b/legacy/builder/builder.go index 5abe9bf3294..751317e4524 100644 --- a/legacy/builder/builder.go +++ b/legacy/builder/builder.go @@ -399,12 +399,9 @@ func containerBuildOptions(ctx *types.Context) types.BareCommand { func warnAboutArchIncompatibleLibraries(ctx *types.Context) types.BareCommand { return types.BareCommand(func(ctx *types.Context) error { - overrides, _ := ctx.Builder.GetBuildProperties().GetOk("architecture.override_check") - WarnAboutArchIncompatibleLibraries( + ctx.Builder.WarnAboutArchIncompatibleLibraries( ctx.TargetPlatform, - overrides, ctx.SketchLibrariesDetector.ImportedLibraries(), - func(s string) { ctx.BuilderLogger.Info(s) }, ) return nil }) diff --git a/legacy/builder/warn_about_arch_incompatible_libraries.go b/legacy/builder/warn_about_arch_incompatible_libraries.go deleted file mode 100644 index ea7392560bc..00000000000 --- a/legacy/builder/warn_about_arch_incompatible_libraries.go +++ /dev/null @@ -1,45 +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 ( - "strings" - - "github.com/arduino/arduino-cli/arduino/cores" - "github.com/arduino/arduino-cli/arduino/libraries" -) - -func WarnAboutArchIncompatibleLibraries( - targetPlatform *cores.PlatformRelease, - overrides string, - importedLibraries libraries.List, - printInfoFn func(string), -) { - archs := []string{targetPlatform.Platform.Architecture} - if overrides != "" { - archs = append(archs, strings.Split(overrides, ",")...) - } - - for _, importedLibrary := range importedLibraries { - if !importedLibrary.SupportsAnyArchitectureIn(archs...) { - printInfoFn( - tr("WARNING: library %[1]s claims to run on %[2]s architecture(s) and may be incompatible with your current board which runs on %[3]s architecture(s).", - importedLibrary.Name, - strings.Join(importedLibrary.Architectures, ", "), - strings.Join(archs, ", "))) - } - } -}