Skip to content

Commit

Permalink
Merge pull request #233 from anandrgitnirman/prodversion
Browse files Browse the repository at this point in the history
set the daemon build version details using ldflags
  • Loading branch information
anandrgitnirman authored Mar 21, 2019
2 parents 4d0c885 + 2f854ef commit 31f86b3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
command: ./scripts/install
- run:
name: Run build script
command: ./scripts/build linux amd64
command: ./scripts/build linux amd64 `git describe --tag`
- run:
name: Run test script
command: ./scripts/test
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ $ ./scripts/install
```

* Build snet-daemon (on Linux amd64 platform), see below section if you want to cross compile instead.
Please note using ldflags, the latest tagged version , sha1 revision and the build time are set as part of the build.
You need to pass the version as shown in the example below
```bash
$ ./scripts/build linux amd64
$ ./scripts/build linux amd64 v.0.1.8
```

* Generate default config file snet-daemon (on Linux amd64 platform)
Expand All @@ -76,6 +78,12 @@ If you want to build snetd for platforms other than the one you are on, run `./s

You can edit the script to choose a specific platform, but by default it will build for Linux, OSX, and Windows (amd64 for all, except Linux which will also build for arm6)

Please note using ldflags the latest tagged version (passed as the first parameter to the script) , sha1 revision and the build time are set as part of the build.

```bash
$ ./scripts/build-xgo v.0.1.8
```

#### Run Deamon
```bash
$ ../build/snetd-linux-amd64
Expand Down
6 changes: 6 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ set -ex

PARENT_PATH=$(dirname $(cd $(dirname $0); pwd -P))


if [ $# -lt 3 ]
then
echo "arguments expected are of the form <OS> <PLATFORM> and <VERSION> for the build script , as an example: '/scripts/build linux amd64 v.0.1.8'"
exit 1
fi
pushd $PARENT_PATH
mkdir -p build
now=$(date +'%Y-%m-%d_%T')
Expand Down
9 changes: 8 additions & 1 deletion scripts/build-xgo
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ set -ex
PARENT_PATH=$(dirname $(cd $(dirname $0); pwd -P))
pushd $PARENT_PATH

if [ $# -eq 0 ]
then
echo "Please pass the latest tagged version of the Daemon as an argument.The version passed will be used by the ldflags to set accordingly."
exit 1
fi
# Make sure we have xgo
go get -u github.com/karalabe/xgo

Expand All @@ -25,5 +30,7 @@ GO_VERSION=1.10.x

# See here for details
# https://github.com/karalabe/xgo#limit-build-targets
now=$(date +'%Y-%m-%d_%T')
#latest version tag is passed as a param to this script.
TARGETS=linux/amd64,linux/arm-6,darwin-10.6/amd64,windows/amd64
xgo -dest build -go $GO_VERSION -targets=$TARGETS ./snetd
xgo -dest build -go $GO_VERSION -ldflags "-X github.com/singnet/snet-daemon/config.sha1Revision=`git rev-parse HEAD` -X github.com/singnet/snet-daemon/config.versionTag=$1 -X github.com/singnet/snet-daemon/config.buildTime=$now" -targets=$TARGETS ./snetd

0 comments on commit 31f86b3

Please sign in to comment.