forked from onbloc/gno-ibc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
167 lines (144 loc) · 7.79 KB
/
Makefile
File metadata and controls
167 lines (144 loc) · 7.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# gno-ibc Makefile.
#
# `make install-gno` runs tools/setup-stdlibs.py, which clones the pinned gno
# repo into a per-user cache, symlinks every package under stdlibs/ into
# <cache>/gnovm/stdlibs/<module>/, regenerates the native-binding dispatch
# table (`go generate`), and installs the resulting `gno` binary.
#
# Bump GNO_COMMIT in .gno-version to roll the upstream toolchain.
include .gno-version
GNO_CACHE := $(HOME)/.cache/gno-ibc/gno
GO_BIN_DIR := $(shell go env GOPATH)/bin
GNO_BIN := $(GO_BIN_DIR)/gno
GNO_SHORT := $(shell echo $(GNO_COMMIT) | cut -c1-7)
ABI_FIXTURES_DIR := tools/abi-fixtures
ABI_VECTORS := gno.land/p/core/encoding/abi/testdata/vectors.json
ABI_VECTORS_GNO := gno.land/p/core/ibc/zkgm/vectors_fixture_test.gno
# Submodule pins (.gitmodules + tree gitlinks) are the source of truth; the
# gno.land/<rel>/ mirrors built by `make vendor` are .gitignored.
VENDOR_GNOLANG_REPO := third_party/gnolang-gno
VENDOR_GNOLANG_SUB := examples/gno.land
VENDOR_GNOLANG_RELS := \
p/demo/tokens/grc20 \
p/moul/md \
p/onbloc/diff \
p/onbloc/json \
p/nt/avl/v0 \
p/nt/bptree/v0 \
p/nt/cford32/v0 \
p/nt/fqname/v0 \
p/nt/mux/v0 \
p/nt/seqid/v0 \
p/nt/testutils/v0 \
p/nt/uassert/v0 \
p/nt/ufmt/v0 \
r/demo/defi/grc20reg
VENDOR_GNOSWAP_REPO := third_party/gnoswap
VENDOR_GNOSWAP_SUB := contract
VENDOR_GNOSWAP_RELS := p/gnoswap/uint256
VENDOR_GNOREALMS_REPO := third_party/gno-realms
VENDOR_GNOREALMS_SUB := gno.land
VENDOR_GNOREALMS_RELS := \
p/aib/encoding \
p/aib/ics23 \
p/aib/jsonpage \
p/aib/merkle \
p/aib/ibc/app \
p/aib/ibc/host \
p/aib/ibc/lightclient \
p/aib/ibc/lightclient/tendermint \
p/aib/ibc/lightclient/tendermint/testing \
p/aib/ibc/types \
r/aib/ibc/core
RSYNC_BASE := -a --delete
STD_EXCLUDES := --delete-excluded --exclude='*_test.gno' --exclude='*_filetest.gno'
FLAGS_p_gnoswap_uint256 :=
FLAGS_p_onbloc_json :=
FLAGS_p_nt_avl_v0 := $(STD_EXCLUDES) --exclude='filetests/' --exclude='list/' --exclude='pager/' --exclude='rolist/'
FLAGS_p_nt_bptree_v0 := --delete-excluded --exclude='list/' --exclude='pager/' --exclude='rolist/' --exclude='rotree/'
FLAGS_p_aib_ibc_lightclient := $(STD_EXCLUDES) --exclude='testing/'
FLAGS_p_aib_ibc_lightclient_tendermint := $(STD_EXCLUDES) --exclude='testing/'
FLAGS_r_aib_ibc_core := $(STD_EXCLUDES) --exclude='README.md' --exclude='recover-client.md'
vendor-flags = $(if $(filter undefined,$(origin FLAGS_$(subst /,_,$(1)))),$(STD_EXCLUDES),$(FLAGS_$(subst /,_,$(1))))
# rsync only auto-creates the leaf dest dir, so mkdir -p covers intermediates.
vendor-cmd = mkdir -p $(dir gno.land/$(2)) && rsync $(RSYNC_BASE) $(call vendor-flags,$(2)) $(1)/$(2)/ gno.land/$(2)/
.PHONY: help install-gno link-stdlibs verify-gno vendor test test-stdlibs test-smoke clean-gno-cache refresh-abi-vectors
# Vendored stdlib import paths, derived from stdlibs/<path>/gnomod.toml presence.
STDLIB_PKGS := $(patsubst stdlibs/%/gnomod.toml,%,$(wildcard stdlibs/*/*/gnomod.toml))
# Subset that ships a Go-side native binding (vs pure-gno). Detected via .go presence.
STDLIB_NATIVE := $(foreach p,$(STDLIB_PKGS),$(if $(wildcard stdlibs/$(p)/*.go),$(p)))
# First-party gno packages. Third-party mirrors under gno.land/p/{aib,gnoswap,nt,onbloc}
# and gno.land/r/aib are dependency inputs only, so local and CI tests skip them.
USER_GNO_PKGS := $(patsubst %/gnomod.toml,./%/,$(shell find gno.land/p/core gno.land/r/core -name gnomod.toml | sort))
help:
@echo "Targets:"
@echo " install-gno — vendor stdlibs/, regenerate, build+install gno"
@echo " link-stdlibs — refresh stdlib symlinks only (no rebuild)"
@echo " verify-gno — assert the gno binary is on PATH"
@echo " vendor — mirror sparse third_party package sub-paths into gno.land/"
@echo " test — verify-gno + vendor, then run first-party gno tests"
@echo " test-stdlibs — run the vendored stdlib's own .gno and .go tests"
@echo " test-smoke — run only the env-prep smoke tests"
@echo " clean-gno-cache — remove the cloned gno repo (forces re-clone next install)"
@echo " refresh-abi-vectors — regenerate ABI ground-truth vectors via the Rust harness"
@echo
@echo "Pinned: $(GNO_REPO)@$(GNO_SHORT) (.gno-version)"
install-gno:
@python3 tools/setup-stdlibs.py
# Refresh stdlib symlinks under the cached gno checkout without rebuilding
# the binary. Used in CI when the binary cache hits but .gno files in
# stdlibs/ may have been added/removed (edits to existing files are picked
# up automatically since symlinks resolve to the working-tree path).
link-stdlibs:
@python3 tools/setup-stdlibs.py --link-only
# Initialise/update the third_party submodules, ensure sparse-checkout is set,
# and rsync the relevant subdirectories into the gno.land workspace paths.
# Idempotent — safe to run on every test invocation.
vendor:
@git submodule update --init --recursive --quiet
@git -C $(VENDOR_GNOLANG_REPO) sparse-checkout init --cone >/dev/null
@git -C $(VENDOR_GNOLANG_REPO) sparse-checkout set $(addprefix $(VENDOR_GNOLANG_SUB)/,$(VENDOR_GNOLANG_RELS)) >/dev/null
@git -C $(VENDOR_GNOSWAP_REPO) sparse-checkout init --cone >/dev/null
@git -C $(VENDOR_GNOSWAP_REPO) sparse-checkout set $(addprefix $(VENDOR_GNOSWAP_SUB)/,$(VENDOR_GNOSWAP_RELS)) >/dev/null
@git -C $(VENDOR_GNOREALMS_REPO) sparse-checkout init --cone >/dev/null
@git -C $(VENDOR_GNOREALMS_REPO) sparse-checkout set $(addprefix $(VENDOR_GNOREALMS_SUB)/,$(VENDOR_GNOREALMS_RELS)) >/dev/null
@$(foreach r,$(VENDOR_GNOLANG_RELS),$(call vendor-cmd,$(VENDOR_GNOLANG_REPO)/$(VENDOR_GNOLANG_SUB),$(r)) && )true
@$(foreach r,$(VENDOR_GNOSWAP_RELS),$(call vendor-cmd,$(VENDOR_GNOSWAP_REPO)/$(VENDOR_GNOSWAP_SUB),$(r)) && )true
@$(foreach r,$(VENDOR_GNOREALMS_RELS),$(call vendor-cmd,$(VENDOR_GNOREALMS_REPO)/$(VENDOR_GNOREALMS_SUB),$(r)) && )true
@echo "ok: vendored third_party package mirrors into gno.land/"
verify-gno:
@command -v gno >/dev/null 2>&1 || { \
echo "ERROR: 'gno' not found on PATH. Make sure $(GO_BIN_DIR) is on PATH and run 'make install-gno'."; exit 1; }
@gno version 2>&1 | grep -q $(GNO_SHORT) || { \
gno version; \
echo "ERROR: 'gno' on PATH does not match pinned commit $(GNO_SHORT)."; \
echo " Run 'make install-gno' to rebuild against the current pin + stdlibs/."; \
exit 1; }
@echo "ok: gno binary matches pinned commit $(GNO_SHORT)"
test: verify-gno vendor
@gno test -v $(USER_GNO_PKGS)
# Stdlib sources live under stdlibs/ but their gnomod.toml declares stdlib
# paths, so `gno test ./stdlibs/...` would reject them as user mempackages.
# Test them by import path (gno) and via the cache (go).
test-stdlibs: verify-gno
@for pkg in $(STDLIB_PKGS); do \
echo ">> gno test $$pkg"; \
gno test -v $$pkg || exit 1; \
done
@echo ">> go test (native bindings)"
@cd $(GNO_CACHE)/gnovm && go test $(addprefix ./stdlibs/,$(STDLIB_NATIVE))
test-smoke: verify-gno
@gno test ./gno.land/p/core/_smoke/ -v
clean-gno-cache:
@rm -rf $(GNO_CACHE)
@echo "removed $(GNO_CACHE)"
# Regenerates ABI test vectors against Union's `sol!` macro definitions.
# Single canonical fixture lives next to the gno tests that consume it.
# CI re-runs this and asserts the committed bytes match.
refresh-abi-vectors:
@command -v cargo >/dev/null 2>&1 || { \
echo "ERROR: 'cargo' not found on PATH. Install Rust toolchain (rustup) to refresh ABI vectors."; exit 1; }
@echo ">> regenerating $(ABI_VECTORS)"
@cargo run --release --quiet -p abi-fixtures > $(ABI_VECTORS)
@python3 -c 'from pathlib import Path; src = Path("$(ABI_VECTORS)").read_text(); assert "\x60" not in src, "vectors.json contains a backtick; cannot embed in Gno raw string"; Path("$(ABI_VECTORS_GNO)").write_text("package zkgm\n\nconst fixtureVectorsJSON = `" + src + "`\n")'
@echo "ok: vectors written to $(ABI_VECTORS) and $(ABI_VECTORS_GNO) ($$(grep -c '"name":' $(ABI_VECTORS)) scenarios)"