Skip to content

Commit

Permalink
Merge PR cosmos#3620: Indicate build flags in version
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni authored and jackzampolin committed Feb 13, 2019
1 parent c9a1c8a commit 787f465
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
BUILD_TAGS = netgo
CAT := $(if $(filter $(OS),Windows_NT),type,cat)
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags \
"-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION} \
-X github.com/cosmos/cosmos-sdk/version.Commit=${COMMIT} \
-X github.com/cosmos/cosmos-sdk/version.VendorDirHash=$(shell $(CAT) vendor-deps)"
BUILD_FLAGS = -tags "$(BUILD_TAGS)" -ldflags \
'-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/cosmos/cosmos-sdk/version.VendorDirHash=$(shell $(CAT) vendor-deps) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(BUILD_TAGS)"'
LEDGER_ENABLED ?= true
GOTOOLS = \
github.com/golang/dep/cmd/dep \
Expand Down
3 changes: 3 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ IMPROVEMENTS
* Gaia

* SDK
* [\#3604] Improve SDK funds related error messages and allow for unicode in
JSON ABCI log.
* [\#3620](https://github.com/cosmos/cosmos-sdk/pull/3620) Version command shows build tags

* \#3638 Add Bcrypt benchmarks & justification of security parameter choice

Expand Down
23 changes: 21 additions & 2 deletions docs/gaia/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,29 @@ make tools install
That will install the `gaiad` and `gaiacli` binaries. Verify that everything is OK:

```bash
$ gaiad version
$ gaiacli version
$ gaiad version --long
$ gaiacli version --long
```

`gaiacli` for instance should output something similar to:

```
cosmos-sdk: 0.31.2-10-g1fba7308
git commit: 1fba7308fa226e971964cd6baad9527d4b51d9fc
vendor hash: 1aec7edfad9888a967b3e9063e42f66b28f447e6
build tags: netgo ledger
go version go1.11.5 linux/amd64
```

##### Build Tags

Build tags indicate special features that have been enabled in the binary.

| Build Tag | Description |
| --------- | ----------------------------------------------- |
| netgo | Name resolution will use pure Go code |
| ledger | Ledger devices are supported (hardware wallets) |

### Next

Now you can [join the public testnet](./join-testnet.md) or [create you own testnet](./deploy-testnet.md)
12 changes: 9 additions & 3 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,30 @@ var (
Commit = ""
Version = ""
VendorDirHash = ""
BuildTags = ""
)

type versionInfo struct {
CosmosSDK string `json:"cosmos_sdk"`
GitCommit string `json:"commit"`
VendorDirHash string `json:"vendor_hash"`
BuildTags string `json:"build_tags"`
GoVersion string `json:"go"`
}

func (v versionInfo) String() string {
return fmt.Sprintf(`cosmos-sdk: %s
git commit: %s
vendor hash: %s
%s`, v.CosmosSDK, v.GitCommit, v.VendorDirHash, v.GoVersion)
build tags: %s
%s`, v.CosmosSDK, v.GitCommit, v.VendorDirHash, v.BuildTags, v.GoVersion)
}

func newVersionInfo() versionInfo {
return versionInfo{
Version, Commit, VendorDirHash, fmt.Sprintf("go version %s %s/%s\n",
runtime.Version(), runtime.GOOS, runtime.GOARCH)}
Version,
Commit,
VendorDirHash,
BuildTags,
fmt.Sprintf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)}
}

0 comments on commit 787f465

Please sign in to comment.