You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2024/01/08 11:11:54 UTC

(mynewt-newt) branch master updated: builder: Export more env variables for scripts

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

jerzy 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 585e1889 builder: Export more env variables for scripts
585e1889 is described below

commit 585e1889caf54290ad29f6bebdd43e31329cff45
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Nov 23 12:34:29 2023 +0100

    builder: Export more env variables for scripts
    
    This exports following environment variable for scripts to use:
    MYNEWT_BIN_DIR bin/<target>
    MYNEWT_BUILD_GENERATED_DIR bin/<target>/generated
    MYNEWT_TARGET_PATH targets/<target>
    MYNEWT_APP_PATH apps/<app_name>
---
 newt/builder/buildutil.go | 6 ++++++
 newt/builder/extcmd.go    | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/newt/builder/buildutil.go b/newt/builder/buildutil.go
index 6212fad0..323e716c 100644
--- a/newt/builder/buildutil.go
+++ b/newt/builder/buildutil.go
@@ -259,6 +259,8 @@ type UserEnvParams struct {
 	UserSrcDir   string // "" if none
 	UserIncDir   string // "" if none
 	WorkDir      string
+	GeneratedDir string
+	TergetBinDir string
 }
 
 // UserEnvVars calculates the set of environment variables required by external
@@ -285,6 +287,8 @@ func UserEnvVars(params UserEnvParams) map[string]string {
 	}
 
 	m["MYNEWT_BUILD_PROFILE"] = params.BuildProfile
+	m["MYNEWT_BUILD_GENERATED_DIR"] = params.GeneratedDir
+	m["MYNEWT_BIN_DIR"] = params.TergetBinDir
 
 	return m
 }
@@ -324,6 +328,8 @@ func (b *Builder) EnvVars(imageSlot int) (map[string]string, error) {
 
 	env["MYNEWT_INCLUDE_PATH"] = strings.Join(b.compilerInfo.Includes, ":")
 	env["MYNEWT_CFLAGS"] = strings.Join(b.compilerInfo.Cflags, " ")
+	env["MYNEWT_TARGET_PATH"] = b.targetPkg.rpkg.Lpkg.FullName()
+	env["MYNEWT_APP_PATH"] = b.appPkg.rpkg.Lpkg.FullName()
 
 	pkgNames := []string{}
 	for _, p := range b.PkgMap {
diff --git a/newt/builder/extcmd.go b/newt/builder/extcmd.go
index 3424cc02..bcbb54e7 100644
--- a/newt/builder/extcmd.go
+++ b/newt/builder/extcmd.go
@@ -120,6 +120,8 @@ func (t *TargetBuilder) envVarsForCmd(sf stage.StageFunc, userSrcDir string,
 		UserSrcDir:   userSrcDir,
 		UserIncDir:   userIncDir,
 		WorkDir:      workDir,
+		GeneratedDir: GeneratedBaseDir(t.target.FullName()),
+		TergetBinDir: TargetBinDir(t.target.FullName()),
 	}
 	uenv := UserEnvVars(p)
 	for k, v := range uenv {