|
16 | 16 | package builder
|
17 | 17 |
|
18 | 18 | import (
|
| 19 | + "bytes" |
19 | 20 | "strings"
|
20 | 21 |
|
21 |
| - "github.com/arduino/arduino-cli/legacy/builder/constants" |
22 |
| - "github.com/arduino/arduino-cli/legacy/builder/types" |
| 22 | + "github.com/arduino/arduino-cli/arduino/cores" |
| 23 | + "github.com/arduino/arduino-cli/arduino/libraries" |
23 | 24 | )
|
24 | 25 |
|
25 |
| -type WarnAboutArchIncompatibleLibraries struct{} |
26 |
| - |
27 |
| -func (s *WarnAboutArchIncompatibleLibraries) Run(ctx *types.Context) error { |
28 |
| - targetPlatform := ctx.TargetPlatform |
29 |
| - buildProperties := ctx.BuildProperties |
| 26 | +func WarnAboutArchIncompatibleLibraries( |
| 27 | + targetPlatform *cores.PlatformRelease, |
| 28 | + overrides string, |
| 29 | + importedLibraries libraries.List, |
| 30 | +) ([]byte, error) { |
| 31 | + infoBuf := &bytes.Buffer{} |
30 | 32 |
|
31 | 33 | archs := []string{targetPlatform.Platform.Architecture}
|
32 |
| - if overrides, ok := buildProperties.GetOk(constants.BUILD_PROPERTIES_ARCH_OVERRIDE_CHECK); ok { |
| 34 | + if overrides != "" { |
33 | 35 | archs = append(archs, strings.Split(overrides, ",")...)
|
34 | 36 | }
|
35 | 37 |
|
36 |
| - for _, importedLibrary := range ctx.SketchLibrariesDetector.ImportedLibraries() { |
| 38 | + for _, importedLibrary := range importedLibraries { |
37 | 39 | if !importedLibrary.SupportsAnyArchitectureIn(archs...) {
|
38 |
| - ctx.Info( |
| 40 | + infoBuf.WriteString( |
39 | 41 | 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).",
|
40 | 42 | importedLibrary.Name,
|
41 | 43 | strings.Join(importedLibrary.Architectures, ", "),
|
42 | 44 | strings.Join(archs, ", ")))
|
43 | 45 | }
|
44 | 46 | }
|
45 | 47 |
|
46 |
| - return nil |
| 48 | + return infoBuf.Bytes(), nil |
47 | 49 | }
|
0 commit comments