feat_: Makefile commands

improve the make clean-generated

chore_: generate as dependant target

fallback to go generate
This commit is contained in:
Igor Sirotin 2024-09-25 12:58:09 +01:00
parent 9bde10da20
commit d9a922d1ee
No known key found for this signature in database
GPG Key ID: 425E227CAAB81F95
2 changed files with 55 additions and 11 deletions

View File

@ -144,6 +144,7 @@ nix-purge: ##@nix Completely remove Nix setup, including /nix directory
all: $(GO_CMD_NAMES) all: $(GO_CMD_NAMES)
.PHONY: $(GO_CMD_NAMES) $(GO_CMD_PATHS) $(GO_CMD_BUILDS) .PHONY: $(GO_CMD_NAMES) $(GO_CMD_PATHS) $(GO_CMD_BUILDS)
$(GO_CMD_BUILDS): generate
$(GO_CMD_BUILDS): ##@build Build any Go project from cmd folder $(GO_CMD_BUILDS): ##@build Build any Go project from cmd folder
go build -mod=vendor -v \ go build -mod=vendor -v \
-tags '$(BUILD_TAGS)' $(BUILD_FLAGS) \ -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) \
@ -155,6 +156,7 @@ bootnode: ##@build Build discovery v5 bootnode using status-go deps
bootnode: build/bin/bootnode bootnode: build/bin/bootnode
node-canary: ##@build Build P2P node canary using status-go deps node-canary: ##@build Build P2P node canary using status-go deps
node-canary: generate
node-canary: build/bin/node-canary node-canary: build/bin/node-canary
statusgo: ##@build Build status-go as statusd server statusgo: ##@build Build status-go as statusd server
@ -190,6 +192,7 @@ statusgo-cross: statusgo-android statusgo-ios
@echo "Full cross compilation done." @echo "Full cross compilation done."
@ls -ld build/bin/statusgo-* @ls -ld build/bin/statusgo-*
statusgo-android: generate
statusgo-android: ##@cross-compile Build status-go for Android statusgo-android: ##@cross-compile Build status-go for Android
@echo "Building status-go for Android..." @echo "Building status-go for Android..."
export GO111MODULE=off; \ export GO111MODULE=off; \
@ -203,6 +206,7 @@ statusgo-android: ##@cross-compile Build status-go for Android
github.com/status-im/status-go/mobile github.com/status-im/status-go/mobile
@echo "Android cross compilation done in build/bin/statusgo.aar" @echo "Android cross compilation done in build/bin/statusgo.aar"
statusgo-ios: generate
statusgo-ios: ##@cross-compile Build status-go for iOS statusgo-ios: ##@cross-compile Build status-go for iOS
@echo "Building status-go for iOS..." @echo "Building status-go for iOS..."
export GO111MODULE=off; \ export GO111MODULE=off; \
@ -215,6 +219,7 @@ statusgo-ios: ##@cross-compile Build status-go for iOS
github.com/status-im/status-go/mobile github.com/status-im/status-go/mobile
@echo "iOS framework cross compilation done in build/bin/Statusgo.xcframework" @echo "iOS framework cross compilation done in build/bin/Statusgo.xcframework"
statusgo-library: generate
statusgo-library: ##@cross-compile Build status-go as static library for current platform statusgo-library: ##@cross-compile Build status-go as static library for current platform
## cmd/library/README.md explains the magic incantation behind this ## cmd/library/README.md explains the magic incantation behind this
mkdir -p build/bin/statusgo-lib mkdir -p build/bin/statusgo-lib
@ -229,6 +234,7 @@ statusgo-library: ##@cross-compile Build status-go as static library for current
@echo "Static library built:" @echo "Static library built:"
@ls -la build/bin/libstatus.* @ls -la build/bin/libstatus.*
statusgo-shared-library: generate
statusgo-shared-library: ##@cross-compile Build status-go as shared library for current platform statusgo-shared-library: ##@cross-compile Build status-go as shared library for current platform
## cmd/library/README.md explains the magic incantation behind this ## cmd/library/README.md explains the magic incantation behind this
mkdir -p build/bin/statusgo-lib mkdir -p build/bin/statusgo-lib
@ -313,16 +319,15 @@ setup-dev:
echo "Replaced by Nix shell. Use 'make shell' or just any target as-is." echo "Replaced by Nix shell. Use 'make shell' or just any target as-is."
generate: generate:
@packages=$$(go list ./... | grep -v "./contracts"); \ @packages=$$(go list ./... | grep -v "/contracts/"); \
go generate $$packages if which go-generate-fast >/dev/null 2>&1; then \
go-generate-fast $$packages; \
clean-generated: SHELL := /bin/sh else \
clean-generated: go generate $$packages; \
# Remove anything generated, excluding ./vendor and ./contracts directories fi
find . -type d -name "mock" ! -path "./vendor/*" ! -path "./contracts/*" -exec rm -rf {} +
# In theory this is only ./transactions/fake/mock.go
find . -type f -name "mock.go" ! -path "./vendor/*" -exec echo {} +
generate-contracts:
go generate ./contracts
download-uniswap-tokens: download-uniswap-tokens:
go run ./services/wallet/token/downloader/main.go go run ./services/wallet/token/downloader/main.go
@ -344,6 +349,8 @@ lint-fix:
-and -not -name 'bindata*' \ -and -not -name 'bindata*' \
-and -not -name 'migrations.go' \ -and -not -name 'migrations.go' \
-and -not -name 'messenger_handlers.go' \ -and -not -name 'messenger_handlers.go' \
-and -not -name '*/mock/*' \
-and -not -name 'mock.go' \
-and -not -wholename '*/vendor/*' \ -and -not -wholename '*/vendor/*' \
-exec goimports \ -exec goimports \
-local 'github.com/ethereum/go-ethereum,github.com/status-im/status-go,github.com/status-im/markdown' \ -local 'github.com/ethereum/go-ethereum,github.com/status-im/status-go,github.com/status-im/markdown' \
@ -355,6 +362,7 @@ docker-test: ##@tests Run tests in a docker container with golang.
test: test-unit ##@tests Run basic, short tests during development test: test-unit ##@tests Run basic, short tests during development
test-unit: generate
test-unit: export BUILD_TAGS ?= test-unit: export BUILD_TAGS ?=
test-unit: export UNIT_TEST_DRY_RUN ?= false test-unit: export UNIT_TEST_DRY_RUN ?= false
test-unit: export UNIT_TEST_COUNT ?= 1 test-unit: export UNIT_TEST_COUNT ?= 1
@ -388,10 +396,11 @@ canary-test: node-canary
lint: lint:
golangci-lint run ./... golangci-lint run ./...
ci: lint canary-test test-unit test-e2e ##@tests Run all linters and tests at once ci: generate lint canary-test test-unit test-e2e ##@tests Run all linters and tests at once
ci-race: lint canary-test test-unit test-e2e-race ##@tests Run all linters and tests at once + race ci-race: generate lint canary-test test-unit test-e2e-race ##@tests Run all linters and tests at once + race
clean: clean-generated-files
clean: ##@other Cleanup clean: ##@other Cleanup
rm -fr build/bin/* mailserver-config.json rm -fr build/bin/* mailserver-config.json
@ -401,6 +410,10 @@ git-clean:
deep-clean: clean git-clean deep-clean: clean git-clean
rm -Rdf .ethereumtest/StatusChain rm -Rdf .ethereumtest/StatusChain
clean-generated-files: SHELL := /bin/sh
clean-generated-files:
./_assets/scripts/clean_generated_files.sh
tidy: tidy:
go mod tidy go mod tidy
@ -488,6 +501,7 @@ test-verif-proxy-wrapper:
CGO_CFLAGS="$(CGO_CFLAGS)" go test -v github.com/status-im/status-go/rpc -tags gowaku_skip_migrations,nimbus_light_client -run ^TestProxySuite$$ -testify.m TestRun -ldflags $(LDFLAGS) CGO_CFLAGS="$(CGO_CFLAGS)" go test -v github.com/status-im/status-go/rpc -tags gowaku_skip_migrations,nimbus_light_client -run ^TestProxySuite$$ -testify.m TestRun -ldflags $(LDFLAGS)
run-integration-tests: generate
run-integration-tests: export INTEGRATION_TESTS_DOCKER_UID ?= $(call sh, id -u) run-integration-tests: export INTEGRATION_TESTS_DOCKER_UID ?= $(call sh, id -u)
run-integration-tests: export INTEGRATION_TESTS_REPORT_CODECOV ?= false run-integration-tests: export INTEGRATION_TESTS_REPORT_CODECOV ?= false
run-integration-tests: run-integration-tests:

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
source "${GIT_ROOT}/_assets/scripts/colors.sh"
echo -e "${GRN}Removing mockgen files from ./mock directories${RST}" # excluding ./vendor and ./contracts directories
find . \
\( \
-type d -name "mock" \
-and -not -path "./vendor/*" \
-and -not -path "./contracts/*" \
\) \
-exec rm -rf {} +
echo -e "${GRN}Removing mock.go files${RST}" # In theory this is only ./transactions/fake/mock.go
find . \
-name "mock.go" \
-and -not -path "./vendor/*" \
-exec rm -f {} +
echo -e "${GRN}Removing protoc and go-bindata files${RST}"
find . \
\( \
-name '*.pb.go' \
-or -name 'bindata.go' \
-or -name 'migrations.go' \
-or -name 'messenger_handlers.go' \
\) \
-and -not -path './vendor/*' \
-exec rm -f {} +