-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from cheqd/local
Added Makefile build, clean
- Loading branch information
Showing
7 changed files
with
236 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,4 @@ secret.yml | |
# Python | ||
.pytest_cache | ||
**/__pycache__ | ||
.vscode-upload.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
export VERSION := $(shell echo $(shell git describe --always --match "v*") | sed 's/^v//') | ||
export TMVERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') | ||
export COMMIT := $(shell git log -1 --format='%H') | ||
|
||
NAME ?= cheqd-node | ||
APPNAME ?= $(NAME)d | ||
LEDGER_ENABLED ?= true | ||
|
||
BINDIR ?= $(GOPATH)/bin | ||
BUILDDIR ?= $(CURDIR)/build | ||
|
||
export GO111MODULE = on | ||
|
||
|
||
### Process build tags | ||
build_tags = netgo | ||
ifeq ($(LEDGER_ENABLED),true) | ||
ifeq ($(OS),Windows_NT) | ||
$(error Windows OS is not supported currently, exiting) | ||
else | ||
UNAME_S = $(shell uname -s) | ||
ifeq ($(UNAME_S),OpenBSD) | ||
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)) | ||
else | ||
GCC = $(shell command -v gcc 2> /dev/null) | ||
ifeq ($(GCC),) | ||
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false) | ||
else | ||
build_tags += ledger | ||
endif | ||
endif | ||
endif | ||
endif | ||
|
||
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS))) | ||
build_tags += gcc | ||
endif | ||
|
||
whitespace := | ||
whitespace += $(whitespace) | ||
comma := , | ||
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) | ||
|
||
|
||
### Process linker flags | ||
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(NAME)\ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName=$(APPNAME) \ | ||
-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.BuildTags=$(build_tags_comma_sep)" \ | ||
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TMVERSION) | ||
|
||
|
||
# DB backend selection | ||
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS))) | ||
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb | ||
endif | ||
|
||
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS))) | ||
ldflags += -w -s | ||
endif | ||
|
||
ldflags += $(LDFLAGS) | ||
ldflags := $(strip $(ldflags)) | ||
|
||
build_tags += $(BUILD_TAGS) | ||
build_tags := $(strip $(build_tags)) | ||
|
||
|
||
### Resulting build flags | ||
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' | ||
|
||
# Check for nostrip option | ||
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS))) | ||
BUILD_FLAGS += -trimpath | ||
endif | ||
|
||
# Check for debug option | ||
ifeq (debug,$(findstring debug,$(COSMOS_BUILD_OPTIONS))) | ||
BUILD_FLAGS += -gcflags "all=-N -l" | ||
endif | ||
|
||
|
||
############################################################################### | ||
### Build ### | ||
############################################################################### | ||
|
||
|
||
all: install | ||
|
||
build: go.sum $(BUILDDIR) | ||
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/cheqd-noded ./cmd/cheqd-noded | ||
|
||
install: go.sum | ||
go install -mod=readonly $(BUILD_FLAGS) ./cmd/cheqd-noded | ||
|
||
$(BUILDDIR): | ||
mkdir -p $(BUILDDIR) | ||
|
||
clean: | ||
rm -rf \ | ||
$(BUILDDIR)/ \ | ||
artifacts/ \ | ||
tmp-swagger-gen/ | ||
|
||
.PHONY: all clean build install | ||
|
||
go.sum: go.mod | ||
echo "Ensure dependencies have not been modified ..." >&2 | ||
go mod verify | ||
go mod tidy | ||
|
||
|
||
############################################################################### | ||
### Protobuf ### | ||
############################################################################### | ||
|
||
proto-gen: | ||
bash scripts/protocgen.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
set -euox pipefail | ||
|
||
# Get protoc executions | ||
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null | ||
|
||
# Get cosmos sdk from github | ||
go get github.com/cosmos/cosmos-sdk 2>/dev/null | ||
|
||
# Get the path of the cosmos-sdk repo from go/pkg/mod | ||
cosmos_sdk_dir=$(go list -f '{{ .Dir }}' -m github.com/cosmos/cosmos-sdk) | ||
|
||
proto_dirs=$(find . -path ./third_party -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) | ||
|
||
for dir in $proto_dirs; do | ||
# Generate protobuf bind | ||
buf protoc \ | ||
-I "proto" \ | ||
-I "$cosmos_sdk_dir/third_party/proto" \ | ||
-I "$cosmos_sdk_dir/proto" \ | ||
--gocosmos_out=plugins=interfacetype+grpc,\ | ||
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \ | ||
$(find "${dir}" -name '*.proto') | ||
|
||
# Generate grpc gateway | ||
buf protoc \ | ||
-I "proto" \ | ||
-I "$cosmos_sdk_dir/third_party/proto" \ | ||
-I "$cosmos_sdk_dir/proto" \ | ||
--grpc-gateway_out=logtostderr=true:. \ | ||
$(find "${dir}" -maxdepth 1 -name '*.proto') | ||
done | ||
|
||
cp -r ./github.com/cheqd/cheqd-node/* ./ | ||
rm -rf ./github.com |