Skip to content

Commit

Permalink
make WarnAboutArchIncompatibleLibraries a method recevier of arduino/…
Browse files Browse the repository at this point in the history
…builder
  • Loading branch information
alessio-perugini committed Sep 12, 2023
1 parent 352362d commit c0eed43
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 49 deletions.
23 changes: 23 additions & 0 deletions arduino/builder/libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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, ", ")))
}
}
}
5 changes: 1 addition & 4 deletions legacy/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
45 changes: 0 additions & 45 deletions legacy/builder/warn_about_arch_incompatible_libraries.go

This file was deleted.

0 comments on commit c0eed43

Please sign in to comment.