Skip to content

Commit 5991bf6

Browse files
committed
newt/builder: Add SDK private includes support
This allows specifying include directories that will only be used interally in the SDK package. Usage example (in pkg.yml): pkg.private_include_dirs: - "example/directory1" - "example/directory2"
1 parent a8b1971 commit 5991bf6

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

newt/builder/buildpackage.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
package builder
2121

2222
import (
23-
"mynewt.apache.org/newt/newt/downloader"
24-
"mynewt.apache.org/newt/newt/repo"
2523
"os"
2624
"path/filepath"
2725
"regexp"
2826
"strings"
2927

28+
"mynewt.apache.org/newt/newt/downloader"
3029
"mynewt.apache.org/newt/newt/newtutil"
3130
"mynewt.apache.org/newt/newt/pkg"
31+
"mynewt.apache.org/newt/newt/repo"
3232
"mynewt.apache.org/newt/newt/resolve"
3333
"mynewt.apache.org/newt/newt/syscfg"
3434
"mynewt.apache.org/newt/newt/toolchain"
@@ -325,6 +325,7 @@ func (bpkg *BuildPackage) publicIncludeDirs(b *Builder) []string {
325325

326326
func (bpkg *BuildPackage) privateIncludeDirs(b *Builder) []string {
327327
srcDir := bpkg.rpkg.Lpkg.BasePath() + "/src/"
328+
bp := bpkg.rpkg.Lpkg.BasePath()
328329

329330
incls := []string{}
330331
if addIncludeDir(&incls, srcDir) {
@@ -340,6 +341,26 @@ func (bpkg *BuildPackage) privateIncludeDirs(b *Builder) []string {
340341
sdkIncls := bpkg.findSdkIncludes()
341342
incls = append(incls, sdkIncls...)
342343

344+
settings := b.cfg.AllSettingsForLpkg(bpkg.rpkg.Lpkg)
345+
346+
userIncls, err := bpkg.rpkg.Lpkg.PkgY.GetValStringSlice(
347+
"pkg.private_include_dirs", settings)
348+
util.OneTimeWarningError(err)
349+
350+
for _, dir := range userIncls {
351+
r, path, err := newtutil.ParsePackageString(dir)
352+
353+
if err != nil {
354+
util.OneTimeWarningError(err)
355+
}
356+
357+
if r != "" {
358+
incls = append(incls, "repos/"+r+"/"+path)
359+
} else {
360+
incls = append(incls, bp+"/"+dir)
361+
}
362+
}
363+
343364
case pkg.PACKAGE_TYPE_UNITTEST:
344365
// A unittest package gets access to its parent package's private
345366
// includes.

0 commit comments

Comments
 (0)