Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Indicate build flags in version #3620

Merged
merged 6 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 \
jleni marked this conversation as resolved.
Show resolved Hide resolved
"-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

* Tendermint
* [\#3618] Upgrade to Tendermint 0.30.03
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)}
}