You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/02/17 09:11:06 UTC

[mynewt-newt] branch master updated: Skip include dirs that do not exist

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

andk 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 0f7940c  Skip include dirs that do not exist
0f7940c is described below

commit 0f7940c5a8e1566d0833004ba0a0a5cdf05983bf
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Feb 17 07:28:57 2022 +0100

    Skip include dirs that do not exist
    
    It does not really matter for build process, but makes debugging build
    issues easier as it does not clutter command line with tons of unused
    include directories.
---
 newt/builder/buildpackage.go | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/newt/builder/buildpackage.go b/newt/builder/buildpackage.go
index 7fb267c..a679664 100644
--- a/newt/builder/buildpackage.go
+++ b/newt/builder/buildpackage.go
@@ -237,14 +237,24 @@ func (bpkg *BuildPackage) findSdkIncludes() []string {
 	return sdkPathList
 }
 
+func addIncludeDir(incls *[]string, inc string) bool {
+	if _, err := os.Stat(inc); err == nil {
+		*incls = append(*incls, inc)
+
+		return true
+	}
+
+	return false
+}
+
 func (bpkg *BuildPackage) publicIncludeDirs(b *Builder) []string {
 	bspPkg := b.targetBuilder.bspPkg
 	pkgBase := filepath.Base(bpkg.rpkg.Lpkg.Name())
 	bp := bpkg.rpkg.Lpkg.BasePath()
 
-	incls := []string{
-		bp + "/include",
-		bp + "/include/" + pkgBase + "/arch/" + bspPkg.Arch,
+	incls := []string{}
+	if addIncludeDir(&incls, bp+"/include") {
+		addIncludeDir(&incls, bp+"/include/"+pkgBase+"/arch/"+bspPkg.Arch)
 	}
 
 	if bpkg.rpkg.Lpkg.Type() == pkg.PACKAGE_TYPE_SDK {
@@ -260,7 +270,7 @@ func (bpkg *BuildPackage) publicIncludeDirs(b *Builder) []string {
 		util.OneTimeWarningError(err)
 
 		for _, dir := range inclDirs {
-			incls = append(incls, bp + "/" + dir)
+			incls = append(incls, bp+"/"+dir)
 		}
 	}
 
@@ -271,8 +281,9 @@ func (bpkg *BuildPackage) privateIncludeDirs(b *Builder) []string {
 	srcDir := bpkg.rpkg.Lpkg.BasePath() + "/src/"
 
 	incls := []string{}
-	incls = append(incls, srcDir)
-	incls = append(incls, srcDir+"/arch/"+b.targetBuilder.bspPkg.Arch)
+	if addIncludeDir(&incls, srcDir) {
+		addIncludeDir(&incls, srcDir+"/arch/"+b.targetBuilder.bspPkg.Arch)
+	}
 
 	switch bpkg.rpkg.Lpkg.Type() {
 	case pkg.PACKAGE_TYPE_SDK: