This is an automated email from the ASF dual-hosted git repository.

m-gorecki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new 1f1aa30a newt/builder: Add SDK private includes support
1f1aa30a is described below

commit 1f1aa30aa08b6c93fb732531c07f1aaab1cdf034
Author: Michal Gorecki <[email protected]>
AuthorDate: Sat May 16 22:32:14 2026 +0200

    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"
---
 newt/builder/buildpackage.go | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/newt/builder/buildpackage.go b/newt/builder/buildpackage.go
index 9513bcef..bd705b0f 100644
--- a/newt/builder/buildpackage.go
+++ b/newt/builder/buildpackage.go
@@ -20,15 +20,15 @@
 package builder
 
 import (
-       "mynewt.apache.org/newt/newt/downloader"
-       "mynewt.apache.org/newt/newt/repo"
        "os"
        "path/filepath"
        "regexp"
        "strings"
 
+       "mynewt.apache.org/newt/newt/downloader"
        "mynewt.apache.org/newt/newt/newtutil"
        "mynewt.apache.org/newt/newt/pkg"
+       "mynewt.apache.org/newt/newt/repo"
        "mynewt.apache.org/newt/newt/resolve"
        "mynewt.apache.org/newt/newt/syscfg"
        "mynewt.apache.org/newt/newt/toolchain"
@@ -325,6 +325,7 @@ func (bpkg *BuildPackage) publicIncludeDirs(b *Builder) 
[]string {
 
 func (bpkg *BuildPackage) privateIncludeDirs(b *Builder) []string {
        srcDir := bpkg.rpkg.Lpkg.BasePath() + "/src/"
+       bp := bpkg.rpkg.Lpkg.BasePath()
 
        incls := []string{}
        if addIncludeDir(&incls, srcDir) {
@@ -340,6 +341,26 @@ func (bpkg *BuildPackage) privateIncludeDirs(b *Builder) 
[]string {
                sdkIncls := bpkg.findSdkIncludes()
                incls = append(incls, sdkIncls...)
 
+               settings := b.cfg.AllSettingsForLpkg(bpkg.rpkg.Lpkg)
+
+               userIncls, err := bpkg.rpkg.Lpkg.PkgY.GetValStringSlice(
+                       "pkg.private_include_dirs", settings)
+               util.OneTimeWarningError(err)
+
+               for _, dir := range userIncls {
+                       r, path, err := newtutil.ParsePackageString(dir)
+
+                       if err != nil {
+                               util.OneTimeWarningError(err)
+                       }
+
+                       if r != "" {
+                               incls = append(incls, "repos/"+r+"/"+path)
+                       } else {
+                               incls = append(incls, bp+"/"+dir)
+                       }
+               }
+
        case pkg.PACKAGE_TYPE_UNITTEST:
                // A unittest package gets access to its parent package's 
private
                // includes.

Reply via email to