|
| 1 | +BIN_DIR = bin |
| 2 | +export GOPATH ?= $(shell go env GOPATH) |
| 3 | +export GO111MODULE ?= on |
| 4 | +export ANCHOR_VERSION ?=v0.29.0 |
| 5 | +export ANCHOR_IMAGE ?= backpackapp/build:$(ANCHOR_VERSION) |
| 6 | +export ANCHOR_BUILD_ARGS ?= |
| 7 | +# Allow overriding the output directory for docker builds |
| 8 | +TARGET_DIR ?= $(PWD)/contracts/target |
| 9 | + |
| 10 | +.PHONY: projectserum_version |
| 11 | +anchor_version: |
| 12 | + @echo "${ANCHOR_VERSION}" |
| 13 | + |
| 14 | +.PHONY: clippy |
| 15 | +clippy: |
| 16 | + cd ./contracts && cargo clippy -- -D warnings |
| 17 | + |
| 18 | +.PHONY: gomods |
| 19 | +gomods: ## Install gomods |
| 20 | + go install github.com/jmank88/gomods@v0.1.3 |
| 21 | + |
| 22 | +.PHONY: gomodtidy |
| 23 | +gomodtidy: gomods |
| 24 | + gomods tidy |
| 25 | + |
| 26 | +.PHONY: format-contracts |
| 27 | +format-contracts: |
| 28 | + cd ./contracts && cargo fmt && go fmt ./... |
| 29 | + |
| 30 | +.PHONY: rust-tests |
| 31 | +rust-tests: |
| 32 | + cd ./contracts && cargo test |
| 33 | + |
| 34 | +.PHONY: lint-go |
| 35 | +lint-go: |
| 36 | + golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 15m --out-format checkstyle:golangci-lint-report.xml run |
| 37 | + |
| 38 | +.PHONY: lint-go-fix |
| 39 | +lint-go-fix: |
| 40 | + golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 15m run --verbose --fix |
| 41 | + |
| 42 | +.PHONY: anchor-go-gen |
| 43 | +anchor-go-gen: |
| 44 | + rm -rf ./gobindings && cd ./contracts && anchor build && cd .. && ./scripts/anchor-go-gen.sh |
| 45 | + |
| 46 | +.PHONY: rematch-ids |
| 47 | +rematch-ids: |
| 48 | + ./scripts/rematch-ids.sh |
| 49 | + |
| 50 | +.PHONY: reclaim-sol |
| 51 | +reclaim-sol: |
| 52 | + ./scripts/reclaim-sol.sh |
| 53 | + |
| 54 | +.PHONY: format |
| 55 | +format: |
| 56 | + go fmt ./... && cd ./contracts && cargo fmt |
| 57 | + |
| 58 | +.PHONY: go-tests |
| 59 | +go-tests: |
| 60 | + go test -v ./... -json -covermode=atomic -coverpkg=./... -coverprofile=integration_coverage.txt 2>&1 | tee /tmp/gotest.log | gotestloghelper -ci=true -singlepackage=true -hidepassingtests=false -hidepassinglogs=false |
| 61 | + |
| 62 | +.PHONY: build-contracts |
| 63 | +build-contracts: |
| 64 | + cd ./contracts && anchor build |
| 65 | + |
| 66 | +# Note on CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse |
| 67 | +# Sparse index significantly speeds up dependency fetching, supposedly default in 1.70 but anchor build was still using a slow git download |
| 68 | +.PHONY: docker-build-contracts |
| 69 | +docker-build-contracts: |
| 70 | + docker run --rm \ |
| 71 | + -v $(shell pwd)/contracts:/workdir \ |
| 72 | + -v ${TARGET_DIR}:/workdir/target \ |
| 73 | + -e CARGO_TARGET_DIR=/workdir/target \ |
| 74 | + -e CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \ |
| 75 | + ${ANCHOR_IMAGE} anchor build ${ANCHOR_BUILD_ARGS} |
| 76 | + |
| 77 | +.PHONY: docker-update-contracts |
| 78 | +docker-update-contracts: |
| 79 | + docker run --rm \ |
| 80 | + -v $(shell pwd)/contracts:/workdir \ |
| 81 | + -v ${TARGET_DIR}:/workdir/target \ |
| 82 | + -e CARGO_TARGET_DIR=/workdir/target \ |
| 83 | + -e CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \ |
| 84 | + ${ANCHOR_IMAGE} anchor keys sync |
| 85 | + |
| 86 | +.PHONY: solana-checks |
| 87 | +solana-checks: clippy anchor-go-gen format gomodtidy lint-go rust-tests go-tests build-contracts |
0 commit comments