frostfs-contract/Makefile

106 lines
3.3 KiB
Makefile
Raw Normal View History

#!/usr/bin/make -f
SHELL=bash
# GOBIN is used only to install neo-go and allows to override
# the location of written binary.
export GOBIN ?= $(shell pwd)/bin
NEOGO ?= $(GOBIN)/cli
VERSION ?= $(shell git describe --tags --dirty --match "v*" --always --abbrev=8 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
2020-03-30 13:59:54 +00:00
# .deb package versioning
OS_RELEASE = $(shell lsb_release -cs)
PKG_VERSION ?= $(shell echo $(VERSION) | sed "s/^v//" | \
sed -E "s/(.*)-(g[a-fA-F0-9]{6,8})(.*)/\1\3~\2/" | \
sed "s/-/~/")-${OS_RELEASE}
.PHONY: all build clean test neo-go
.PHONY: alphabet mainnet morph nns sidechain
.PHONY: debpackage debclean
build: neo-go all
all: sidechain mainnet
sidechain: alphabet morph nns
alphabet_sc = alphabet
morph_sc = balance container frostfsid netmap proxy policy
mainnet_sc = frostfs processing
nns_sc = nns
all_sc = $(alphabet_sc) $(morph_sc) $(mainnet_sc) $(nns_sc)
define sc_template
$(2)$(1)/$(1)_contract.nef: $(2)$(1)/$(1)_contract.go $(2)$(1)/config.yml
$(NEOGO) contract compile -i $(2)$(1) -c $(if $(2),$(2),$(1)/)config.yml -m $(2)$(1)/config.json -o $(2)$(1)/$(1)_contract.nef
$(if $(2),$(2)$(1)/$(1)_contract.go: alphabet/alphabet.go alphabet/alphabet.tpl
go run alphabet/alphabet.go
)
endef
$(foreach sc,$(alphabet_sc),$(eval $(call sc_template,$(sc))))
$(foreach sc,$(morph_sc),$(eval $(call sc_template,$(sc))))
$(foreach sc,$(mainnet_sc),$(eval $(call sc_template,$(sc))))
$(foreach sc,$(nns_sc),$(eval $(call sc_template,$(sc))))
alphabet: $(foreach sc,$(alphabet_sc),$(sc)/$(sc)_contract.nef)
morph: $(foreach sc,$(morph_sc),$(sc)/$(sc)_contract.nef)
mainnet: $(foreach sc,$(mainnet_sc),$(sc)/$(sc)_contract.nef)
nns: $(foreach sc,$(nns_sc),$(sc)/$(sc)_contract.nef)
2020-03-30 13:59:54 +00:00
neo-go:
@go list -f '{{.Path}}/...@{{.Version}}' -m github.com/nspcc-dev/neo-go \
| xargs go install -v
generate-wrapper.%:
@mkdir -p ./rpcclient/$*
@# Note, that bindings file is currently missing: is can be emitted by compiler,
@# but this leads to a large amount of code duplication. It can be written by hand,
@# in case we need to override the type of some variables.
@# --config $*/$*.bindings.yml
@# Unfortunately, primitive integer types are not yet supported.
@# When changing auto-generated path, don't forget to change .gitattributes too.
$(NEOGO) contract generate-rpcwrapper --manifest=$*/config.json --out ./rpcclient/$*/client.go
generate-wrappers: build $(foreach sc,$(all_sc),generate-wrapper.$(sc))
test:
@go test ./tests/...
# Run all code formatters
fmts: fumpt imports
# Reformat imports
imports:
@echo "⇒ Processing goimports check"
@goimports -w $(all_sc) tests/
fumpt:
@echo "⇒ Processing gofumpt check"
@gofumpt -l -w $(all_sc) tests/
clean:
find . -name '*.nef' -exec rm -rf {} \;
find . -name 'config.json' -exec rm -rf {} \;
rm -rf ./bin/
2020-03-30 13:59:54 +00:00
mr_proper: clean
for sc in $(alphabet_sc); do\
rm -rf alphabet/$$sc; \
done
archive: build
@tar --transform "s|^./|frostfs-contract-$(VERSION)/|" \
-czf frostfs-contract-$(VERSION).tar.gz \
$(shell find . -name '*.nef' -o -name 'config.json')
# Package for Debian
debpackage:
dch --package frostfs-contract \
--controlmaint \
--newversion $(PKG_VERSION) \
--distribution $(OS_RELEASE) \
"Please see CHANGELOG.md for code changes for $(VERSION)"
dpkg-buildpackage --no-sign -b
debclean:
dh clean