build.sh script for building newt from source.

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/bb53feda
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/bb53feda
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/bb53feda

Branch: refs/heads/develop
Commit: bb53feda03db22dc16b81f5934faf784175fb44e
Parents: b002dd0
Author: Christopher Collins <[email protected]>
Authored: Wed Mar 16 17:59:31 2016 -0700
Committer: Christopher Collins <[email protected]>
Committed: Wed Mar 16 18:08:22 2016 -0700

----------------------------------------------------------------------
 build.sh | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/bb53feda/build.sh
----------------------------------------------------------------------
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..e31efb7
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+set -e
+
+### Ensure >= go1.5 is installed.
+go_ver_str="$(go version | cut -d ' ' -f 3)"
+go_ver="${go_ver_str#go}"
+go_maj="${go_ver%.*}"
+go_min="${go_ver#*.}"
+
+if [ ! "$go_maj" -gt 1 ] && [ ! "$go_min" -ge 5 ]
+then
+    printf "* Error: go 1.5 or later is required (detected version: %s)\n" \
+        "$go_maj"."$go_min"
+    exit 1
+fi
+
+### Create a temporary go tree in /tmp and build newt.
+installdir="$(realpath "$(dirname "$0")")"
+godir="$(mktemp -d /tmp/mynewt.XXXXXXXXXX)"
+mynewtdir="$godir"/src/mynewt.apache.org
+repodir="$mynewtdir"/newt
+newtdir="$repodir"/newt
+dstfile="$installdir"/newt/newt
+
+mkdir -p "$mynewtdir"
+ln -s "$installdir" "$repodir"
+
+(
+    cd "$newtdir"
+    GOPATH="$godir" GO15VENDOREXPERIMENT=1 go install
+    mv "$godir"/bin/newt "$dstfile"
+    printf "Successfully built executable: %s\n" "$dstfile"
+)
+
+### Delete the temporary directory.
+rm -r "$godir"

Reply via email to