-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
128 lines (101 loc) · 3.41 KB
/
Makefile
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
# In some situations we might want to override the default profile (release) (e.g. in CI)
PROFILE ?= release
PROFILE_OPT := --profile $(PROFILE)
# Frustratingly, for the dev profile, /target/debug is used. For all other profiles,
# /target/$(PROFILE) is used. This is a workaround to ensure that the correct target
# directory is used for the dev profile.
ifeq ($(PROFILE), dev)
PROFILE_TARGET_DIR := debug
else
PROFILE_TARGET_DIR := $(PROFILE)
endif
JSTZD_KERNEL_PATH := crates/jstzd/resources/jstz_rollup/jstz_kernel.wasm
CLI_KERNEL_PATH := crates/jstz_cli/jstz_kernel.wasm
.PHONY: all
all: build test check
.PHONY: build
build: build-cli-kernel build-jstzd-kernel
@cargo build $(PROFILE_OPT)
.PHONY: build-bridge
build-bridge:
@ligo compile contract --no-warn contracts/jstz_bridge.mligo \
--module "Jstz_bridge" > contracts/jstz_bridge.tz
@ligo compile contract contracts/jstz_native_bridge.mligo > contracts/jstz_native_bridge.tz
@ligo compile contract --no-warn contracts/exchanger.mligo > contracts/exchanger.tz
@ligo compile contract --no-warn contracts/jstz_fa_bridge.mligo > contracts/jstz_fa_bridge.tz
@ligo compile contract --no-warn contracts/examples/fa_ticketer/fa_ticketer.mligo > contracts/examples/fa_ticketer/fa_ticketer.tz
.PHONY: build-kernel
build-kernel:
@cargo build --package jstz_kernel --target wasm32-unknown-unknown $(PROFILE_OPT)
.PHONY: build-jstzd-kernel
build-jstzd-kernel: build-kernel
@cp target/wasm32-unknown-unknown/$(PROFILE_TARGET_DIR)/jstz_kernel.wasm $(JSTZD_KERNEL_PATH)
# TODO: Remove once jstzd replaces the sandbox
# https://linear.app/tezos/issue/JSTZ-205/remove-build-for-jstz-cli
.PHONY: build-cli-kernel
build-cli-kernel: build-kernel
@cp target/wasm32-unknown-unknown/$(PROFILE_TARGET_DIR)/jstz_kernel.wasm $(CLI_KERNEL_PATH)
.PHONY: build-cli
build-cli: build-cli-kernel
@cargo build --package jstz_cli $(PROFILE_OPT)
.PHONY: build-deps
build-deps:
@rustup target add wasm32-unknown-unknown
.PHONY: build-dev-deps
build-dev-deps: build-deps
@rustup component add rustfmt clippy
.PHONY: build-sdk-wasm-pkg
build-sdk-wasm-pkg:
@cd crates/jstz_sdk && wasm-pack build --target bundler --release
.PHONY: test
test: test-unit test-int
.PHONY: test-unit
test-unit:
# --lib only runs unit tests in library crates
# --bins only runs unit tests in binary crates
@cargo nextest run --lib --bins
.PHONY: test-int
test-int:
# --test only runs a specified integration test (a test in /tests).
# the glob pattern is used to match all integration tests
# --exclude excludes the jstz_api wpt test
@cargo nextest run --test "*" --workspace --exclude "jstz_api"
.PHONY: cov
cov:
@cargo llvm-cov --workspace --exclude-from-test "jstz_api" --html --open
.PHONY: check
check: lint fmt
.PHONY: clean
clean:
@cargo clean
@rm -f result
@rm -rf logs
.PHONY: fmt-nix-check
fmt-nix-check:
@alejandra check ./
.PHONY: fmt-nix
fmt-nix:
@alejandra ./
.PHONY: fmt-rust-check
fmt-rust-check:
@cargo fmt --check
.PHONY: fmt-rust
fmt-rust:
@cargo fmt
.PHONY: fmt-js-check
fmt-js-check:
npm run check:format
.PHONY: fmt-js
fmt-js:
npm run format
.PHONY: fmt
fmt: fmt-nix fmt-rust fmt-js
.PHONY: fmt-check
fmt-check: fmt-nix-check fmt-rust-check fmt-js-check
.PHONY: lint
lint:
@touch $(CLI_KERNEL_PATH)
# Jstzd has to processes a non-empty kernel in its build script
@echo "ignore" > $(JSTZD_KERNEL_PATH)
@cargo clippy --all-targets -- --deny warnings
@rm -f $(CLI_KERNEL_PATH) $(JSTZD_KERNEL_PATH)