2019-02-01 17:02:52 +00:00
.PHONY : statusgo statusd -prune all test clean help
2016-07-20 06:42:19 +00:00
.PHONY : statusgo -android statusgo -ios
2018-11-05 14:02:16 +00:00
RELEASE_TAG := $( shell cat VERSION)
RELEASE_BRANCH := "develop"
RELEASE_DIRECTORY := /tmp/release-$( RELEASE_TAG)
PRE_RELEASE := "1"
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
i f n d e f G O P A T H
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
e n d i f
2018-06-14 11:28:09 +00:00
EXPECTED_PATH = $( shell go env GOPATH) /src/github.com/status-im/status-go
i f n e q ( $( CURDIR ) , $( EXPECTED_PATH ) )
d e f i n e N O T _ I N _ G O P A T H _ E R R O R
C u r r e n t d i r i s $( CURDIR ) , w h i c h s e e m s t o b e d i f f e r e n t f r o m y o u r G O P A T H .
P l e a s e , b u i l d s t a t u s - g o f r o m G O P A T H f o r p r o p e r b u i l d .
2018-06-25 13:27:17 +00:00
GOPATH = $( shell go env GOPATH)
Current dir = $( CURDIR)
2018-06-14 11:28:09 +00:00
Expected dir = $( EXPECTED_PATH) )
See https : //golang .org /doc /code .html #GOPATH for more info
e n d e f
$( error $ ( NOT_IN_GOPATH_ERROR ) )
e n d i f
2018-08-24 10:25:07 +00:00
CGO_CFLAGS = -I/$( JAVA_HOME) /include -I/$( JAVA_HOME) /include/darwin
GOBIN = $( dir $( realpath $( firstword $( MAKEFILE_LIST) ) ) ) build/bin
2018-11-20 10:13:42 +00:00
GIT_COMMIT = $( shell git rev-parse --short HEAD)
2018-08-24 10:25:07 +00:00
AUTHOR = $( shell echo $$ USER)
2018-03-01 16:18:12 +00:00
2018-12-14 11:16:45 +00:00
ENABLE_METRICS ?= true
2018-11-14 07:03:58 +00:00
BUILD_FLAGS ?= $( shell echo " -ldflags '\
-X main.buildStamp= ` date -u '+%Y-%m-%d.%H:%M:%S' ` \
2018-11-20 10:13:42 +00:00
-X github.com/status-im/status-go/params.Version= $( RELEASE_TAG) \
-X github.com/status-im/status-go/params.GitCommit= $( GIT_COMMIT) \
2018-11-14 07:03:58 +00:00
-X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr= $( ENABLE_METRICS) ' " )
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-05-18 13:43:07 +00:00
BOOTNODE_IMAGE_NAME ?= statusteam/bootnode
2018-08-24 03:17:32 +00:00
PROXY_IMAGE_NAME ?= statusteam/discovery-proxy
2018-06-07 10:30:18 +00:00
STATUSD_PRUNE_IMAGE_NAME ?= statusteam/statusd-prune
2018-01-03 18:50:19 +00:00
2018-11-20 10:13:42 +00:00
DOCKER_IMAGE_CUSTOM_TAG ?= $( RELEASE_TAG)
2018-07-02 16:27:59 +00:00
2018-02-19 15:32:58 +00:00
DOCKER_TEST_WORKDIR = /go/src/github.com/status-im/status-go/
2018-05-07 20:58:09 +00:00
DOCKER_TEST_IMAGE = golang:1.10
2018-02-19 15:32:58 +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
2018-06-07 10:30:18 +00:00
statusd-prune : ##@statusd-prune Build statusd-prune
go build -o $( GOBIN) /statusd-prune -v ./cmd/statusd-prune
@echo "Compilation done."
@echo "Run \"build/bin/statusd-prune -h\" to view available commands."
statusd-prune-docker-image : ##@statusd-prune Build statusd-prune docker image
2018-08-24 10:25:07 +00:00
@echo "Building docker image for ststusd-prune..."
docker build --file _assets/build/Dockerfile-prune . \
--label " commit= $( GIT_COMMIT) " \
--label " author= $( AUTHOR) " \
-t $( BOOTNODE_IMAGE_NAME) :$( DOCKER_IMAGE_CUSTOM_TAG) \
-t $( STATUSD_PRUNE_IMAGE_NAME) :latest
2018-06-07 10:30:18 +00:00
2018-05-18 13:43:07 +00:00
bootnode : ##@build Build discovery v5 bootnode using status-go deps
go build -i -o $( GOBIN) /bootnode -v -tags '$(BUILD_TAGS)' $( BUILD_FLAGS) ./cmd/bootnode/
@echo "Compilation done."
2018-08-24 03:17:32 +00:00
proxy : ##@build Build proxy for rendezvous servers using status-go deps
go build -i -o $( GOBIN) /proxy -v -tags '$(BUILD_TAGS)' $( BUILD_FLAGS) ./cmd/proxy/
@echo "Compilation done."
2018-09-20 11:25:32 +00:00
node-canary : ##@build Build P2P node canary using status-go deps
go build -i -o $( GOBIN) /node-canary -v -tags '$(BUILD_TAGS)' $( BUILD_FLAGS) ./cmd/node-canary/
2018-07-12 14:50:49 +00:00
@echo "Compilation done."
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-*
2019-02-01 17:02:52 +00:00
statusgo-android : ##@cross-compile Build status-go for Android
@echo "Building status-go for Android..."
@gomobile bind -target= android -ldflags= "-s -w" -o build/bin/statusgo.aar github.com/status-im/status-go/mobile
@echo "Android cross compilation done in build/bin/statusgo.aar"
statusgo-ios : ##@cross-compile Build status-go for iOS
@echo "Building status-go for iOS..."
@gomobile bind -target= ios -ldflags= "-s -w" -o build/bin/Statusgo.framework github.com/status-im/status-go/mobile
@echo "iOS framework cross compilation done in build/bin/Statusgo.framework"
2018-06-14 11:28:09 +00:00
statusgo-linux : xgo ##@cross-compile Build status-go for Linux
./_assets/patches/patcher -b . -p geth-xgo
2018-08-24 10:25:07 +00:00
$( GOPATH) /bin/xgo --image $( XGOIMAGE) --go= $( XGO_GO) -out statusgo --dest= $( GOBIN) --targets= linux/amd64 -v -tags '$(BUILD_TAGS)' $( BUILD_FLAGS) ./cmd/statusd
2018-06-14 11:28:09 +00:00
./_assets/patches/patcher -b . -p geth-xgo -r
2018-12-07 13:35:05 +00:00
@echo "Linux cross compilation done."
2018-06-14 11:28:09 +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..."
2018-12-14 11:16:45 +00:00
go build -buildmode= c-archive -o $( GOBIN) /libstatus.a $( BUILD_FLAGS) ./lib
2017-11-29 21:30:16 +00:00
@echo "Static library built:"
@ls -la $( GOBIN) /libstatus.*
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-07-02 16:27:59 +00:00
docker build --file _assets/build/Dockerfile . \
--build-arg " build_tags= $( BUILD_TAGS) " \
--build-arg " build_flags= $( BUILD_FLAGS) " \
2018-08-24 10:25:07 +00:00
--label " commit= $( GIT_COMMIT) " \
--label " author= $( AUTHOR) " \
2018-07-02 16:27:59 +00:00
-t $( DOCKER_IMAGE_NAME) :$( DOCKER_IMAGE_CUSTOM_TAG) \
-t $( DOCKER_IMAGE_NAME) :latest
2018-02-12 20:56:53 +00:00
2018-05-18 13:43:07 +00:00
bootnode-image :
@echo "Building docker image for bootnode..."
2018-07-02 16:27:59 +00:00
docker build --file _assets/build/Dockerfile-bootnode . \
2018-08-24 03:17:32 +00:00
--build-arg " build_tags= $( BUILD_TAGS) " \
--build-arg " build_flags= $( BUILD_FLAGS) " \
2018-08-24 10:25:07 +00:00
--label " commit= $( GIT_COMMIT) " \
--label " author= $( AUTHOR) " \
2018-07-02 16:27:59 +00:00
-t $( BOOTNODE_IMAGE_NAME) :$( DOCKER_IMAGE_CUSTOM_TAG) \
-t $( BOOTNODE_IMAGE_NAME) :latest
2018-08-24 03:17:32 +00:00
proxy-image :
@echo "Building docker image for proxy..."
docker build --file _assets/build/Dockerfile-proxy . \
--build-arg " build_tags= $( BUILD_TAGS) " \
--build-arg " build_flags= $( BUILD_FLAGS) " \
-t $( PROXY_IMAGE_NAME) :$( DOCKER_IMAGE_CUSTOM_TAG) \
-t $( PROXY_IMAGE_NAME) :latest
2018-07-02 16:27:59 +00:00
push-docker-images : docker -image bootnode -image
docker push $( BOOTNODE_IMAGE_NAME) :$( DOCKER_IMAGE_CUSTOM_TAG)
docker push $( DOCKER_IMAGE_NAME) :$( DOCKER_IMAGE_CUSTOM_TAG)
2018-08-02 17:16:39 +00:00
# See https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html to understand this magic.
push-docker-images-latest : GIT_BRANCH = $( shell git rev -parse --abbrev -ref HEAD )
push-docker-images-latest : GIT_LOCAL = $( shell git rev -parse @)
push-docker-images-latest : GIT_REMOTE = $( shell git fetch -q && git rev -parse remotes /origin /develop || echo 'NO_DEVELOP ')
2018-07-02 16:27:59 +00:00
push-docker-images-latest : docker -image bootnode -image
2018-08-02 17:16:39 +00:00
@echo "Pushing latest docker images..."
@echo "Checking git branch..."
2018-07-02 16:27:59 +00:00
i f n e q ( "$(GIT_BRANCH)" , "develop" )
2018-08-02 17:16:39 +00:00
$( error You should only use develop branch to push the latest tag!)
2018-07-02 16:27:59 +00:00
exit 1
e n d i f
i f n e q ( "$(GIT_LOCAL)" , "$(GIT_REMOTE)" )
2018-08-02 17:16:39 +00:00
$( error The local git commit does not match the remote origin!)
2018-07-02 16:27:59 +00:00
exit 1
e n d i f
2018-07-12 09:45:31 +00:00
docker push $( BOOTNODE_IMAGE_NAME) :latest
2018-07-02 16:27:59 +00:00
docker push $( DOCKER_IMAGE_NAME) :latest
2018-01-03 18:50:19 +00:00
2018-09-24 18:07:34 +00:00
install-os-dependencies :
_assets/scripts/install_deps.sh
2019-02-07 12:12:35 +00:00
setup-dev : setup -build install -os -dependencies gen -install ##@other Prepare project for development
2019-02-01 17:02:52 +00:00
setup-build : dep -install lint -install mock -install release -install gomobile -install ##@other Prepare project for build
setup : setup -build setup -dev ##@other Prepare project for development and building
2018-09-13 16:31:29 +00:00
generate : ##@other Regenerate assets and other auto-generated stuff
2018-09-24 18:07:34 +00:00
go generate ./static ./static/migrations
$( shell cd ./services/shhext/chat && exec protoc --go_out= . ./*.proto)
2018-11-05 14:02:16 +00:00
prepare-release : clean -release
mkdir -p $( RELEASE_DIRECTORY)
2019-02-01 17:02:52 +00:00
mv build/bin/statusgo.aar $( RELEASE_DIRECTORY) /status-go-android.aar
zip -r build/bin/Statusgo.framework.zip build/bin/Statusgo.framework
mv build/bin/Statusgo.framework.zip $( RELEASE_DIRECTORY) /status-go-ios.zip
2018-11-05 14:02:16 +00:00
zip -r $( RELEASE_DIRECTORY) /status-go-desktop.zip . -x *.git*
2018-12-06 12:22:18 +00:00
${ MAKE } clean
2018-11-05 14:02:16 +00:00
clean-release :
rm -rf $( RELEASE_DIRECTORY)
release :
2018-11-20 10:13:42 +00:00
@read -p " Are you sure you want to create a new GitHub $( shell if [ $( PRE_RELEASE) = "0" ] ; then echo release; else echo pre-release ; fi ) against $( RELEASE_BRANCH) branch? (y/n): " REPLY; \
2018-11-05 14:02:16 +00:00
if [ $$ REPLY = "y" ] ; then \
2018-11-20 10:13:42 +00:00
latest_tag = $$ ( git describe --tags ` git rev-list --tags --max-count= 1` ) ; \
comparison = " $$ latest_tag..HEAD " ; \
if [ -z " $$ latest_tag " ] ; then comparison = "" ; fi ; \
changelog = $$ ( git log $$ comparison --oneline --no-merges --format= "* %h %s" ) ; \
github-release $( shell if [ $( PRE_RELEASE) != "0" ] ; then echo "-prerelease" ; fi ) "status-im/status-go" " $( RELEASE_TAG) " " $( RELEASE_BRANCH) " " $( changelog) " " $( RELEASE_DIRECTORY) /* " ; \
2018-11-05 14:02:16 +00:00
else \
echo "Aborting." && exit 1; \
fi
2019-02-01 17:02:52 +00:00
gomobile-install :
go get -u golang.org/x/mobile/cmd/gomobile
i f d e f N D K _ G O M O B I L E
gomobile init -ndk $( NDK_GOMOBILE)
e l s e
gomobile init
e n d i f
release-install :
2018-11-05 14:02:16 +00:00
go get -u github.com/c4milo/github-release
2018-09-24 18:07:34 +00:00
gen-install :
2018-12-14 11:21:34 +00:00
go get -u github.com/jteeuwen/go-bindata
go get -u github.com/jteeuwen/go-bindata/go-bindata
2018-09-24 18:07:34 +00:00
go get -u github.com/golang/protobuf/protoc-gen-go
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
2018-12-10 12:53:27 +00:00
dep ensure -update github.com/golang/mock
2017-09-04 12:56:58 +00:00
2017-10-11 14:20:51 +00:00
mock : ##@other Regenerate mocks
2018-06-08 11:29:50 +00:00
mockgen -package= fcm -destination= notifications/push/fcm/client_mock.go -source= notifications/push/fcm/client.go
mockgen -package= fake -destination= transactions/fake/mock.go -source= transactions/fake/txservice.go
mockgen -package= account -destination= account/accounts_mock.go -source= account/accounts.go
2018-06-25 13:27:17 +00:00
mockgen -package= status -destination= services/status/account_mock.go -source= services/status/service.go
2018-07-16 07:40:40 +00:00
mockgen -package= peer -destination= services/peer/discoverer_mock.go -source= services/peer/service.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 }
2018-08-02 17:16:39 +00:00
test : test -unit ##@tests Run basic, short tests during development
2017-10-20 10:10:28 +00:00
2018-08-02 17:16:39 +00:00
test-unit : UNIT_TEST_PACKAGES = $( shell go list ./... | \
grep -v /vendor | \
grep -v /t/e2e | \
grep -v /t/benchmarks | \
grep -v /lib)
2017-10-20 10:10:28 +00:00
test-unit : ##@tests Run unit and integration tests
2018-11-14 07:03:58 +00:00
go test -v -failfast $( UNIT_TEST_PACKAGES) $( gotest_extraflags)
2017-10-11 14:20:51 +00:00
2018-03-27 12:38:41 +00:00
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 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 -e 2e ##@tests Run e2e tests with -race flag
2017-10-11 14:20:51 +00:00
2018-11-19 17:12:59 +00:00
canary-test : node -canary
2019-02-01 17:02:52 +00:00
# TODO: uncomment that!
#_assets/scripts/canary_test_mailservers.sh ./config/cli/fleet-eth.beta.json
2018-11-19 17:12:59 +00:00
2018-01-24 08:25:28 +00:00
lint-install :
2018-06-12 16:34:24 +00:00
@# The following installs a specific version of golangci-lint, which is appropriate for a CI server to avoid different results from build to build
2018-10-17 10:17:58 +00:00
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $( GOPATH) /bin v1.10.2
2018-01-24 08:25:28 +00:00
lint :
@echo "lint"
2018-06-12 16:34:24 +00:00
@golangci-lint run ./...
2018-01-24 08:25:28 +00:00
2018-11-19 17:12:59 +00:00
ci : lint mock dep -ensure canary -test test -unit test -e 2e ##@tests Run all linters and tests at once
2016-12-07 21:07:08 +00:00
2019-02-07 12:12:35 +00:00
ci-race : lint mock dep -ensure canary -test test -unit test -e 2e -race ##@tests Run all linters and tests at once + race
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
deep-clean : clean
2017-11-21 14:40:52 +00:00
rm -Rdf .ethereumtest/StatusChain
2018-02-01 17:14:51 +00:00
2018-09-27 19:16:15 +00:00
dep-ensure : ##@dependencies Ensure all dependencies are in place with dep
2018-02-01 17:14:51 +00:00
@dep ensure
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-09-14 08:46:34 +00:00
update-fleet-config : ##@other Update fleets configuration from fleets.status.im
./_assets/ci/update-fleet-config.sh
@echo "Updating static assets..."
@go generate ./static
@echo "Done"
2019-02-06 16:47:01 +00:00
run-mailserver : ##@Easy way to run a mailserver locally with Docker
cd _assets/compose/mailserver/ && $( MAKE)