Skip to content

Commit 6123c6e

Browse files
committed
Removed duplication of extensions table
1 parent 6e47c95 commit 6123c6e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

legacy/builder/create_cmake_rule.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@ import (
2929
"github.com/arduino/arduino-cli/legacy/builder/utils"
3030
)
3131

32-
var VALID_EXPORT_EXTENSIONS = map[string]bool{".h": true, ".c": true, ".hpp": true, ".hh": true, ".cpp": true, ".S": true, ".a": true, ".properties": true}
33-
3432
var ValidExportExtensions = []string{".h", ".c", ".hpp", ".hh", ".cpp", ".S", ".a", ".properties"}
3533
var DotHExtension = []string{".h", ".hh", ".hpp"}
3634
var DotAExtension = []string{".a"}
3735

36+
func stringArrayToLookupFunction(in []string) func(string) bool {
37+
out := map[string]bool{}
38+
for _, i := range in {
39+
out[i] = true
40+
}
41+
return func(s string) bool {
42+
return out[s]
43+
}
44+
}
45+
3846
type ExportProjectCMake struct {
3947
// Was there an error while compiling the sketch?
4048
SketchError bool
@@ -65,7 +73,7 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
6573
cmakeFile := cmakeFolder.Join("CMakeLists.txt")
6674

6775
dynamicLibsFromPkgConfig := map[string]bool{}
68-
extensions := func(ext string) bool { return VALID_EXPORT_EXTENSIONS[ext] }
76+
extensions := stringArrayToLookupFunction(ValidExportExtensions)
6977
for _, library := range ctx.ImportedLibraries {
7078
// Copy used libraries in the correct folder
7179
libDir := libBaseFolder.Join(library.Name)

0 commit comments

Comments
 (0)