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 2019/10/16 00:38:12 UTC

[mynewt-newt] branch master updated: build.sh: Allow user to override version string

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

ccollins 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 2882e35  build.sh: Allow user to override version string
2882e35 is described below

commit 2882e35edc3036b521dc1e35b5b07dcdc6f626b8
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Oct 14 15:53:02 2019 -0700

    build.sh: Allow user to override version string
    
    Allow the user can override the version reported by `newt version`.
    This is done by exporting `NEWT_VERSION_STR` to the desired string and
    then running `build.sh`.
---
 build.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/build.sh b/build.sh
index d2e2504..f6edd7d 100755
--- a/build.sh
+++ b/build.sh
@@ -82,11 +82,20 @@ DATE="$(date +%F_%R)"
 (
     cd "$newtdir"
 
+    # Include the build date in `newt version`.
     EXTRA_OPTS="-X mynewt.apache.org/newt/newt/newtutil.NewtDate=$DATE"
+
+    # Include the git hash and dirty state in `newt version`.
     if [ $GIT_HASH != "none" ]; then
         EXTRA_OPTS="${EXTRA_OPTS} -X mynewt.apache.org/newt/newt/newtutil.NewtGitHash=$GIT_HASH"
     fi
 
+    # Allow the user to override the version reported by `newt version`.
+    if [ "$NEWT_VERSION_STR" != "" ]
+    then
+        EXTRA_OPTS="${EXTRA_OPTS} -X mynewt.apache.org/newt/newt/newtutil.NewtVersionStr=$NEWT_VERSION_STR"
+    fi
+
     printf "Building newt.  This may take a minute...\n"
     unset GOPATH
     go build -ldflags "$EXTRA_OPTS"