You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/12/11 00:40:52 UTC

[GitHub] ccollins476ad closed pull request #250: Inject target name into syscfg

ccollins476ad closed pull request #250:  Inject target name into syscfg
URL: https://github.com/apache/mynewt-newt/pull/250
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/newt/builder/build.go b/newt/builder/build.go
index 9db22135..06b16415 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -486,7 +486,8 @@ func (b *Builder) PrepBuild() error {
 
 	// Define a cpp symbol indicating the BSP architecture, name of the
 	// BSP and app.
-
+	// The arch, app, and bsp defines are kept here for backwards compatiblity.
+	// Users should prefer the equivalent syscfg defines.
 	archName := b.targetBuilder.bspPkg.Arch
 	bspCi.Cflags = append(bspCi.Cflags, "-DARCH_"+util.CIdentifier(archName))
 	bspCi.Cflags = append(bspCi.Cflags, "-DARCH_NAME="+archName+"")
diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index f5fa8e64..3f10dbb9 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -99,9 +99,6 @@ func NewTargetTester(target *target.Target,
 		injectedSettings: map[string]string{},
 	}
 
-	// Indicate that this version of newt supports the generated logcfg header.
-	t.InjectSetting("NEWT_FEATURE_LOGCFG", "1")
-
 	return t, nil
 }
 
@@ -122,11 +119,42 @@ func (t *TargetBuilder) NewCompiler(dstDir string, buildProfile string) (
 	return c, err
 }
 
+func (t *TargetBuilder) injectNewtSettings() {
+	// Indicate that this version of newt supports the generated logcfg header.
+	t.InjectSetting("NEWT_FEATURE_LOGCFG", "1")
+
+	// Indicate to the apache-mynewt-core code that this version of newt
+	// supports the sysdown mechanism (generated package shutdown functions).
+	t.InjectSetting("NEWT_FEATURE_SYSDOWN", "1")
+}
+
+func (t *TargetBuilder) injectBuildSettings() {
+	t.InjectSetting("ARCH_NAME", "\""+t.bspPkg.Arch+"\"")
+	t.InjectSetting("ARCH_"+util.CIdentifier(t.bspPkg.Arch), "1")
+
+	if t.appPkg != nil {
+		appName := filepath.Base(t.appPkg.Name())
+		t.InjectSetting("APP_NAME", "\""+appName+"\"")
+		t.InjectSetting("APP_"+util.CIdentifier(appName), "1")
+	}
+
+	bspName := filepath.Base(t.bspPkg.Name())
+	t.InjectSetting("BSP_NAME", "\""+bspName+"\"")
+	t.InjectSetting("BSP_"+util.CIdentifier(bspName), "1")
+
+	tgtName := filepath.Base(t.target.Name())
+	t.InjectSetting("TARGET_NAME", "\""+tgtName+"\"")
+	t.InjectSetting("TARGET_"+util.CIdentifier(tgtName), "1")
+}
+
 func (t *TargetBuilder) ensureResolved() error {
 	if t.res != nil {
 		return nil
 	}
 
+	t.injectNewtSettings()
+	t.injectBuildSettings()
+
 	var loaderSeeds []*pkg.LocalPackage
 	if t.loaderPkg != nil {
 		loaderSeeds = []*pkg.LocalPackage{
@@ -149,7 +177,7 @@ func (t *TargetBuilder) ensureResolved() error {
 
 		// Inject the SPLIT_IMAGE setting into the entire target.  All packages
 		// now know that they are part of a split image build.
-		t.injectedSettings["SPLIT_IMAGE"] = "1"
+		t.InjectSetting("SPLIT_IMAGE", "1")
 	}
 
 	appSeeds := []*pkg.LocalPackage{
@@ -168,16 +196,12 @@ func (t *TargetBuilder) ensureResolved() error {
 		//     * TEST:      lets packages know that this is a test app
 		//     * SELFTEST:  indicates that the "newt test" command is used;
 		//                  causes a package to define a main() function.
-		t.injectedSettings["TEST"] = "1"
-		t.injectedSettings["SELFTEST"] = "1"
+		t.InjectSetting("TEST", "1")
+		t.InjectSetting("SELFTEST", "1")
 
 		appSeeds = append(appSeeds, t.testPkg)
 	}
 
-	// Indicate to the apache-mynewt-core code that this version of newt
-	// supports the sysdown mechanism (generated package shutdown functions).
-	t.injectedSettings["NEWT_FEATURE_SYSDOWN"] = "1"
-
 	var err error
 	t.res, err = resolve.ResolveFull(
 		loaderSeeds, appSeeds, t.injectedSettings, t.bspPkg.FlashMap)
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index 40f68b30..8a81a68d 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -998,12 +998,8 @@ func (cfg *Cfg) DeprecatedWarning() []string {
 	return lines
 }
 
-func escapeStr(s string) string {
-	return strings.ToUpper(util.CIdentifier(s))
-}
-
 func settingName(setting string) string {
-	return SYSCFG_PREFIX_SETTING + escapeStr(setting)
+	return SYSCFG_PREFIX_SETTING + util.CIdentifier(setting)
 }
 
 func normalizePkgType(typ interfaces.PackageType) interfaces.PackageType {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services