2017-10-03 11:54:19 +00:00
|
|
|
.PHONY: statusgo all test xgo clean help
|
2016-07-20 06:42:19 +00:00
|
|
|
.PHONY: statusgo-android statusgo-ios
|
|
|
|
|
2017-11-03 22:07:13 +00:00
|
|
|
help: ##@other Show this help
|
|
|
|
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
|
|
|
|
|
2017-11-04 04:20:17 +00:00
|
|
|
ifndef GOPATH
|
2018-01-03 18:50:19 +00:00
|
|
|
$(error GOPATH not set. Please set GOPATH and make sure status-go is located at $$GOPATH/src/github.com/status-im/status-go. \
|
|
|
|
For more information about the GOPATH environment variable, see https://golang.org/doc/code.html#GOPATH)
|
2017-11-04 04:20:17 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
CGO_CFLAGS=-I/$(JAVA_HOME)/include -I/$(JAVA_HOME)/include/darwin
|
2018-03-01 16:18:12 +00:00
|
|
|
GOBIN=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))build/bin
|
2018-04-10 10:36:11 +00:00
|
|
|
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
2018-03-01 16:18:12 +00:00
|
|
|
|
2018-04-10 10:36:11 +00:00
|
|
|
BUILD_FLAGS := $(shell echo "-ldflags '-X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` -X main.gitCommit=$(GIT_COMMIT) -X github.com/status-im/status-go/geth/params.VersionMeta=$(GIT_COMMIT)'")
|
2018-03-15 11:36:28 +00:00
|
|
|
|
2016-06-17 11:55:54 +00:00
|
|
|
GO ?= latest
|
2018-01-04 09:47:10 +00:00
|
|
|
XGOVERSION ?= 1.9.2
|
|
|
|
XGOIMAGE = statusteam/xgo:$(XGOVERSION)
|
|
|
|
XGOIMAGEIOSSIM = statusteam/xgo-ios-simulator:$(XGOVERSION)
|
2016-06-17 11:55:54 +00:00
|
|
|
|
2018-03-15 11:36:28 +00:00
|
|
|
networkid ?= StatusChain
|
2018-03-27 12:38:41 +00:00
|
|
|
gotest_extraflags =
|
2018-03-15 11:36:28 +00:00
|
|
|
|
2018-02-26 18:36:04 +00:00
|
|
|
DOCKER_IMAGE_NAME ?= statusteam/status-go
|
2018-01-03 18:50:19 +00:00
|
|
|
|
2018-02-19 15:32:58 +00:00
|
|
|
DOCKER_TEST_WORKDIR = /go/src/github.com/status-im/status-go/
|
2018-03-27 12:36:40 +00:00
|
|
|
DOCKER_TEST_IMAGE = golang:1.9
|
2018-02-19 15:32:58 +00:00
|
|
|
|
2018-04-09 06:26:06 +00:00
|
|
|
UNIT_TEST_PACKAGES := $(shell go list ./... | grep -v /vendor | grep -v /t/e2e | grep -v /t/destructive | grep -v /lib)
|
2018-01-03 18:50:19 +00:00
|
|
|
|
2017-10-03 11:54:19 +00:00
|
|
|
# This is a code for automatic help generator.
|
|
|
|
# It supports ANSI colors and categories.
|
|
|
|
# To add new item into help output, simply add comments
|
|
|
|
# starting with '##'. To add category, use @category.
|
2018-01-09 17:46:54 +00:00
|
|
|
GREEN := $(shell echo "\e[32m")
|
|
|
|
WHITE := $(shell echo "\e[37m")
|
|
|
|
YELLOW := $(shell echo "\e[33m")
|
|
|
|
RESET := $(shell echo "\e[0m")
|
2017-10-03 11:54:19 +00:00
|
|
|
HELP_FUN = \
|
|
|
|
%help; \
|
2018-03-27 15:07:06 +00:00
|
|
|
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z0-9\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
|
2017-10-03 11:54:19 +00:00
|
|
|
print "Usage: make [target]\n\n"; \
|
|
|
|
for (sort keys %help) { \
|
|
|
|
print "${WHITE}$$_:${RESET}\n"; \
|
|
|
|
for (@{$$help{$$_}}) { \
|
|
|
|
$$sep = " " x (32 - length $$_->[0]); \
|
|
|
|
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
|
|
|
|
}; \
|
|
|
|
print "\n"; \
|
|
|
|
}
|
|
|
|
|
|
|
|
statusgo: ##@build Build status-go as statusd server
|
2018-03-15 11:36:28 +00:00
|
|
|
go build -i -o $(GOBIN)/statusd -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./cmd/statusd
|
2018-02-02 15:54:14 +00:00
|
|
|
@echo "Compilation done."
|
|
|
|
@echo "Run \"build/bin/statusd -h\" to view available commands."
|
2017-11-03 22:07:13 +00:00
|
|
|
|
2016-07-20 06:42:19 +00:00
|
|
|
statusgo-cross: statusgo-android statusgo-ios
|
2016-10-13 11:46:54 +00:00
|
|
|
@echo "Full cross compilation done."
|
2016-07-20 06:42:19 +00:00
|
|
|
@ls -ld $(GOBIN)/statusgo-*
|
|
|
|
|
2017-10-03 11:54:19 +00:00
|
|
|
statusgo-android: xgo ##@cross-compile Build status-go for Android
|
2018-02-27 10:39:30 +00:00
|
|
|
./_assets/patches/patcher -b . -p geth-xgo
|
2018-03-15 11:36:28 +00:00
|
|
|
$(GOPATH)/bin/xgo --image $(XGOIMAGE) --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./lib
|
2018-02-27 10:39:30 +00:00
|
|
|
./_assets/patches/patcher -b . -p geth-xgo -r
|
2016-10-13 11:46:54 +00:00
|
|
|
@echo "Android cross compilation done."
|
2016-06-17 11:55:54 +00:00
|
|
|
|
2017-10-03 11:54:19 +00:00
|
|
|
statusgo-ios: xgo ##@cross-compile Build status-go for iOS
|
2018-02-27 10:39:30 +00:00
|
|
|
./_assets/patches/patcher -b . -p geth-xgo
|
2018-03-15 11:36:28 +00:00
|
|
|
$(GOPATH)/bin/xgo --image $(XGOIMAGE) --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./lib
|
2018-02-27 10:39:30 +00:00
|
|
|
./_assets/patches/patcher -b . -p geth-xgo -r
|
2016-10-13 11:46:54 +00:00
|
|
|
@echo "iOS framework cross compilation done."
|
2016-07-20 06:42:19 +00:00
|
|
|
|
2017-10-03 11:54:19 +00:00
|
|
|
statusgo-ios-simulator: xgo ##@cross-compile Build status-go for iOS Simulator
|
2018-01-04 09:47:10 +00:00
|
|
|
@docker pull $(XGOIMAGEIOSSIM)
|
2018-02-27 10:39:30 +00:00
|
|
|
./_assets/patches/patcher -b . -p geth-xgo
|
2018-03-15 11:36:28 +00:00
|
|
|
$(GOPATH)/bin/xgo --image $(XGOIMAGEIOSSIM) --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./lib
|
2018-02-27 10:39:30 +00:00
|
|
|
./_assets/patches/patcher -b . -p geth-xgo -r
|
2016-10-13 11:46:54 +00:00
|
|
|
@echo "iOS framework cross compilation done."
|
2016-07-20 06:42:19 +00:00
|
|
|
|
2017-11-29 21:30:16 +00:00
|
|
|
statusgo-library: ##@cross-compile Build status-go as static library for current platform
|
|
|
|
@echo "Building static library..."
|
|
|
|
go build -buildmode=c-archive -o $(GOBIN)/libstatus.a ./lib
|
|
|
|
@echo "Static library built:"
|
|
|
|
@ls -la $(GOBIN)/libstatus.*
|
|
|
|
|
2018-03-27 12:36:40 +00:00
|
|
|
docker-image: BUILD_TAGS ?= metrics prometheus
|
2018-01-03 18:50:19 +00:00
|
|
|
docker-image: ##@docker Build docker image (use DOCKER_IMAGE_NAME to set the image name)
|
|
|
|
@echo "Building docker image..."
|
2018-02-12 20:56:53 +00:00
|
|
|
docker build --file _assets/build/Dockerfile --build-arg "build_tags=$(BUILD_TAGS)" . -t $(DOCKER_IMAGE_NAME):latest
|
|
|
|
|
|
|
|
docker-image-tag: ##@docker Tag DOCKER_IMAGE_NAME:latest with a tag following pattern $GIT_SHA[:8]-$BUILD_TAGS
|
|
|
|
@echo "Tagging docker image..."
|
|
|
|
docker tag $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_NAME):$(shell BUILD_TAGS="$(BUILD_TAGS)" ./_assets/ci/get-docker-image-tag.sh)
|
2018-01-03 18:50:19 +00:00
|
|
|
|
2018-01-04 09:47:10 +00:00
|
|
|
xgo-docker-images: ##@docker Build xgo docker images
|
|
|
|
@echo "Building xgo docker images..."
|
2018-02-09 13:38:18 +00:00
|
|
|
docker build _assets/build/xgo/base -t $(XGOIMAGE)
|
|
|
|
docker build _assets/build/xgo/ios-simulator -t $(XGOIMAGEIOSSIM)
|
2018-01-04 09:47:10 +00:00
|
|
|
|
2016-06-17 11:55:54 +00:00
|
|
|
xgo:
|
2018-01-04 09:47:10 +00:00
|
|
|
docker pull $(XGOIMAGE)
|
2017-11-04 04:20:17 +00:00
|
|
|
go get github.com/karalabe/xgo
|
2016-07-20 06:42:19 +00:00
|
|
|
|
2018-03-27 15:07:06 +00:00
|
|
|
setup: lint-install mock-install ##@other Prepare project for first build
|
|
|
|
|
2017-10-03 11:54:19 +00:00
|
|
|
generate: ##@other Regenerate assets and other auto-generated stuff
|
2017-11-04 04:20:17 +00:00
|
|
|
go generate ./static
|
2017-04-06 19:36:55 +00:00
|
|
|
|
2017-10-11 14:20:51 +00:00
|
|
|
mock-install: ##@other Install mocking tools
|
2017-09-04 12:56:58 +00:00
|
|
|
go get -u github.com/golang/mock/mockgen
|
|
|
|
|
2017-10-11 14:20:51 +00:00
|
|
|
mock: ##@other Regenerate mocks
|
2018-04-13 13:10:37 +00:00
|
|
|
mockgen -package=fcm -destination=geth/notifications/push/fcm/client_mock.go -source=geth/notifications/push/fcm/client.go
|
|
|
|
mockgen -package=fake -destination=geth/transactions/fake/mock.go -source=geth/transactions/fake/txservice.go
|
|
|
|
mockgen -package=account -destination=geth/account/accounts_mock.go -source=geth/account/accounts.go
|
|
|
|
mockgen -package=jail -destination=geth/jail/cell_mock.go -source=geth/jail/cell.go
|
2017-09-04 12:56:58 +00:00
|
|
|
|
2018-02-19 15:32:58 +00:00
|
|
|
docker-test: ##@tests Run tests in a docker container with golang.
|
|
|
|
docker run --privileged --rm -it -v "$(shell pwd):$(DOCKER_TEST_WORKDIR)" -w "$(DOCKER_TEST_WORKDIR)" $(DOCKER_TEST_IMAGE) go test ${ARGS}
|
|
|
|
|
2017-10-20 10:10:28 +00:00
|
|
|
test: test-unit-coverage ##@tests Run basic, short tests during development
|
|
|
|
|
|
|
|
test-unit: ##@tests Run unit and integration tests
|
2018-04-20 11:26:54 +00:00
|
|
|
go test -v $(UNIT_TEST_PACKAGES) $(gotest_extraflags)
|
2017-10-11 14:20:51 +00:00
|
|
|
|
2017-10-20 10:10:28 +00:00
|
|
|
test-unit-coverage: ##@tests Run unit and integration tests with coverage
|
2018-03-27 12:38:41 +00:00
|
|
|
go test -coverpkg= $(UNIT_TEST_PACKAGES) $(gotest_extraflags)
|
|
|
|
|
|
|
|
test-unit-race: gotest_extraflags=-race
|
|
|
|
test-unit-race: test-unit ##@tests Run unit and integration tests with -race flag
|
2017-10-11 14:20:51 +00:00
|
|
|
|
|
|
|
test-e2e: ##@tests Run e2e tests
|
|
|
|
# order: reliability then alphabetical
|
2017-10-23 11:05:52 +00:00
|
|
|
# TODO(tiabc): make a single command out of them adding `-p 1` flag.
|
2018-03-27 12:38:41 +00:00
|
|
|
go test -timeout 5m ./t/e2e/accounts/... -network=$(networkid) $(gotest_extraflags)
|
|
|
|
go test -timeout 5m ./t/e2e/api/... -network=$(networkid) $(gotest_extraflags)
|
|
|
|
go test -timeout 5m ./t/e2e/node/... -network=$(networkid) $(gotest_extraflags)
|
|
|
|
go test -timeout 50m ./t/e2e/jail/... -network=$(networkid) $(gotest_extraflags)
|
|
|
|
go test -timeout 20m ./t/e2e/rpc/... -network=$(networkid) $(gotest_extraflags)
|
|
|
|
go test -timeout 20m ./t/e2e/whisper/... -network=$(networkid) $(gotest_extraflags)
|
|
|
|
go test -timeout 10m ./t/e2e/transactions/... -network=$(networkid) $(gotest_extraflags)
|
2018-04-10 10:02:54 +00:00
|
|
|
go test -timeout 10m ./t/e2e/services/... -network=$(networkid) $(gotest_extraflags)
|
2017-11-22 13:06:14 +00:00
|
|
|
# e2e_test tag is required to include some files from ./lib without _test suffix
|
2018-03-27 12:38:41 +00:00
|
|
|
go test -timeout 40m -tags e2e_test ./lib -network=$(networkid) $(gotest_extraflags)
|
|
|
|
|
2018-03-27 15:07:06 +00:00
|
|
|
test-e2e-race: gotest_extraflags=-race
|
|
|
|
test-e2e-race: test-e2e ##@tests Run e2e tests with -race flag
|
2017-10-11 14:20:51 +00:00
|
|
|
|
2018-01-24 08:25:28 +00:00
|
|
|
lint-install:
|
|
|
|
go get -u github.com/alecthomas/gometalinter
|
|
|
|
gometalinter --install
|
|
|
|
|
|
|
|
lint:
|
|
|
|
@echo "lint"
|
|
|
|
@gometalinter ./...
|
|
|
|
|
2018-05-02 09:08:53 +00:00
|
|
|
ci: lint mock dep-ensure test-unit test-e2e ##@tests Run all linters and tests at once
|
2016-12-07 21:07:08 +00:00
|
|
|
|
2017-10-03 11:54:19 +00:00
|
|
|
clean: ##@other Cleanup
|
2016-07-20 06:42:19 +00:00
|
|
|
rm -fr build/bin/*
|
2017-11-07 17:46:11 +00:00
|
|
|
rm -f coverage.out coverage-all.out coverage.html
|
|
|
|
|
|
|
|
deep-clean: clean
|
2017-11-21 14:40:52 +00:00
|
|
|
rm -Rdf .ethereumtest/StatusChain
|
2018-02-01 17:14:51 +00:00
|
|
|
|
2018-02-14 17:44:27 +00:00
|
|
|
vendor-check: ##@dependencies Require all new patches and disallow other changes
|
|
|
|
./_assets/patches/patcher -c
|
|
|
|
./_assets/ci/isolate-vendor-check.sh
|
|
|
|
|
|
|
|
dep-ensure: ##@dependencies Dep ensure and apply all patches
|
2018-02-01 17:14:51 +00:00
|
|
|
@dep ensure
|
2018-02-14 17:44:27 +00:00
|
|
|
./_assets/patches/patcher
|
2018-02-01 17:14:51 +00:00
|
|
|
|
2018-02-14 17:44:27 +00:00
|
|
|
dep-install: ##@dependencies Install vendoring tool
|
2018-02-01 17:14:51 +00:00
|
|
|
go get -u github.com/golang/dep/cmd/dep
|
2018-02-09 13:38:18 +00:00
|
|
|
|
2018-02-20 18:04:25 +00:00
|
|
|
update-geth: ##@dependencies Update geth (use GETH_BRANCH to optionally set the geth branch name)
|
|
|
|
./_assets/ci/update-geth.sh $(GETH_BRANCH)
|
|
|
|
|
2018-02-14 17:44:27 +00:00
|
|
|
patch: ##@patching Revert and apply all patches
|
2018-02-09 13:38:18 +00:00
|
|
|
./_assets/patches/patcher
|
2018-02-14 17:44:27 +00:00
|
|
|
|
|
|
|
patch-revert: ##@patching Revert all patches only
|
|
|
|
./_assets/patches/patcher -r
|