From 2ffbe85efba87e039c7785998105c4b8cfa2103e Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 29 Nov 2019 16:44:36 +0100 Subject: [PATCH] Add support for additional_include_paths library property Fixes #501 --- arduino/libraries/libraries.go | 29 +++++++++++----------- arduino/libraries/loader.go | 8 ++++++ legacy/builder/phases/libraries_builder.go | 5 ++++ rpc/commands/lib.proto | 1 + 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/arduino/libraries/libraries.go b/arduino/libraries/libraries.go index b31f546aa74..06657b30201 100644 --- a/arduino/libraries/libraries.go +++ b/arduino/libraries/libraries.go @@ -55,20 +55,21 @@ type Library struct { Types []string `json:"types,omitempty"` - InstallDir *paths.Path - SourceDir *paths.Path - UtilityDir *paths.Path - Location LibraryLocation - ContainerPlatform *cores.PlatformRelease `json:""` - Layout LibraryLayout - RealName string - DotALinkage bool - Precompiled bool - LDflags string - IsLegacy bool - Version *semver.Version - License string - Properties *properties.Map + InstallDir *paths.Path + SourceDir *paths.Path + UtilityDir *paths.Path + Location LibraryLocation + ContainerPlatform *cores.PlatformRelease `json:""` + Layout LibraryLayout + RealName string + DotALinkage bool + Precompiled bool + LDflags string + IsLegacy bool + Version *semver.Version + License string + AdditionalIncludePaths []*paths.Path + Properties *properties.Map } func (library *Library) String() string { diff --git a/arduino/libraries/loader.go b/arduino/libraries/loader.go index 221f28a11e6..f03657626a5 100644 --- a/arduino/libraries/loader.go +++ b/arduino/libraries/loader.go @@ -105,6 +105,14 @@ func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library, library.DotALinkage = libProperties.GetBoolean("dot_a_linkage") library.Precompiled = libProperties.GetBoolean("precompiled") library.LDflags = strings.TrimSpace(libProperties.Get("ldflags")) + additionalIncludePathsList := libProperties.Get("additional_include_paths") + if additionalIncludePathsList != "" { + temp := strings.Split(additionalIncludePathsList, ",") + for _, el := range temp { + dir := paths.New(libraryDir.Join(el).String()) + library.AdditionalIncludePaths = append(library.AdditionalIncludePaths, dir) + } + } library.Properties = libProperties return library, nil diff --git a/legacy/builder/phases/libraries_builder.go b/legacy/builder/phases/libraries_builder.go index b01ffe70dc2..06ab152bcf3 100644 --- a/legacy/builder/phases/libraries_builder.go +++ b/legacy/builder/phases/libraries_builder.go @@ -192,6 +192,11 @@ func compileLibrary(ctx *types.Context, library *libraries.Library, buildPath *p } if library.Layout == libraries.RecursiveLayout { + if library.AdditionalIncludePaths != nil { + for _, el := range library.AdditionalIncludePaths { + includes = append(includes, utils.WrapWithHyphenI(el.String())) + } + } libObjectFiles, err := builder_utils.CompileFilesRecursive(ctx, library.SourceDir, libraryBuildPath, buildProperties, includes) if err != nil { return nil, i18n.WrapError(err) diff --git a/rpc/commands/lib.proto b/rpc/commands/lib.proto index 2de44ab28e2..7c4c878c74e 100644 --- a/rpc/commands/lib.proto +++ b/rpc/commands/lib.proto @@ -160,6 +160,7 @@ message Library { string version = 21; string license = 22; map properties = 23; + string additional_include_paths = 24; } enum LibraryLayout {