You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/10/19 23:55:32 UTC

incubator-mynewt-newt git commit: newt - Ensure macro names are valid C-identifiers.

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop e74fa85f5 -> 07e677a7e


newt - Ensure macro names are valid C-identifiers.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/07e677a7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/07e677a7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/07e677a7

Branch: refs/heads/develop
Commit: 07e677a7e7cd784d72ef0a692e5edf5dc390b513
Parents: e74fa85
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Oct 19 16:55:10 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Oct 19 16:55:10 2016 -0700

----------------------------------------------------------------------
 newt/builder/build.go                           |  6 +++---
 newt/syscfg/syscfg.go                           |  6 +-----
 newt/vendor/mynewt.apache.org/newt/util/util.go | 10 +++++++++-
 util/util.go                                    |  8 ++++++++
 4 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/07e677a7/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index 029d595..f01fa98 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -395,17 +395,17 @@ func (b *Builder) PrepBuild() error {
 	// BSP and app.
 
 	archName := b.targetBuilder.bspPkg.Arch
-	bspCi.Cflags = append(bspCi.Cflags, "-DARCH_"+archName)
+	bspCi.Cflags = append(bspCi.Cflags, "-DARCH_"+util.CIdentifier(archName))
 	bspCi.Cflags = append(bspCi.Cflags, "-DARCH_NAME=\""+archName+"\"")
 
 	if b.appPkg != nil {
 		appName := filepath.Base(b.appPkg.Name())
-		bspCi.Cflags = append(bspCi.Cflags, "-DAPP_"+appName)
+		bspCi.Cflags = append(bspCi.Cflags, "-DAPP_"+util.CIdentifier(appName))
 		bspCi.Cflags = append(bspCi.Cflags, "-DAPP_NAME=\""+appName+"\"")
 	}
 
 	bspName := filepath.Base(b.bspPkg.Name())
-	bspCi.Cflags = append(bspCi.Cflags, "-DBSP_"+bspName)
+	bspCi.Cflags = append(bspCi.Cflags, "-DBSP_"+util.CIdentifier(bspName))
 	bspCi.Cflags = append(bspCi.Cflags, "-DBSP_NAME=\""+bspName+"\"")
 
 	baseCi.AddCompilerInfo(bspCi)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/07e677a7/newt/syscfg/syscfg.go
----------------------------------------------------------------------
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index 7b42c59..fd4a4f5 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -601,11 +601,7 @@ func (cfg *Cfg) WarningText() string {
 }
 
 func escapeStr(s string) string {
-	s = strings.Replace(s, "/", "_", -1)
-	s = strings.Replace(s, "-", "_", -1)
-	s = strings.Replace(s, " ", "_", -1)
-	s = strings.ToUpper(s)
-	return s
+	return strings.ToUpper(util.CIdentifier(s))
 }
 
 func settingName(setting string) string {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/07e677a7/newt/vendor/mynewt.apache.org/newt/util/util.go
----------------------------------------------------------------------
diff --git a/newt/vendor/mynewt.apache.org/newt/util/util.go b/newt/vendor/mynewt.apache.org/newt/util/util.go
index 4aae5a7..ae495ef 100644
--- a/newt/vendor/mynewt.apache.org/newt/util/util.go
+++ b/newt/vendor/mynewt.apache.org/newt/util/util.go
@@ -64,7 +64,7 @@ const (
 )
 
 func (se *NewtError) Error() string {
-	return se.Text + "\n" + string(se.StackTrace)
+	return se.Text
 }
 
 func NewNewtError(msg string) *NewtError {
@@ -559,3 +559,11 @@ func FileContentsChanged(path string, newContents []byte) (bool, error) {
 	rc := bytes.Compare(oldContents, newContents)
 	return rc != 0, nil
 }
+
+func CIdentifier(s string) string {
+	s = strings.Replace(s, "/", "_", -1)
+	s = strings.Replace(s, "-", "_", -1)
+	s = strings.Replace(s, " ", "_", -1)
+
+	return s
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/07e677a7/util/util.go
----------------------------------------------------------------------
diff --git a/util/util.go b/util/util.go
index 298c1b0..ae495ef 100644
--- a/util/util.go
+++ b/util/util.go
@@ -559,3 +559,11 @@ func FileContentsChanged(path string, newContents []byte) (bool, error) {
 	rc := bytes.Compare(oldContents, newContents)
 	return rc != 0, nil
 }
+
+func CIdentifier(s string) string {
+	s = strings.Replace(s, "/", "_", -1)
+	s = strings.Replace(s, "-", "_", -1)
+	s = strings.Replace(s, " ", "_", -1)
+
+	return s
+}