-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathMakefile
More file actions
152 lines (116 loc) · 4.44 KB
/
Makefile
File metadata and controls
152 lines (116 loc) · 4.44 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
# Targets that are commands.
COMMANDS := deploy-stack gen compile-abi rust-binding slither lint fmt deps build \
test install-dev install-npm-package install-eth-abi storage clean coverage \
prepare forge
# Targets that are prerequisite commands.
PREREQ_COMMANDS := pnpm
# Targets that are not commands.
NON_COMMANDS := node_modules test/helpers/SelectorLibrary.sol
# Declare commands and prerequisite commands as phony targets.
.PHONY: $(COMMANDS) $(PREREQ_COMMANDS)
# Make all commands and non-command targets dependent on the prerequisites.
$(COMMANDS): $(PREREQ_COMMANDS)
$(NON_COMMANDS): $(PREREQ_COMMANDS)
# Override PROFILE env var to choose between `local | ci`
PROFILE ?= local
# Set to `--push` to push the multiarch image during the build.
# Leave on `--load` for local build, but it only works for a single platform.
BUILDX_STORE ?= --load
# Set according to what kind of `--platform` and `--cache` to use.
# Leave empty for local builds, then the platform matches the local one.
BUILDX_FLAGS ?=
# Set to the `<repo>/<image>:<tag>` label the image.
BUILDX_TAG ?= contracts:latest
COMMIT_SHA := $(shell git rev-parse --short HEAD)
# To use `buildx` locally to produce multiplatform images, one needs to run `docker buildx create --use`.
# After that it looks like even the regular docker build needs the `--load` parameter, which hopefully
# it can handle for anyone with `DOCKER_BUILDKIT=1`.
docker-build:
if [ "$(PROFILE)" = "ci" ]; then \
docker buildx build \
$(BUILDX_STORE) \
$(BUILDX_FLAGS) \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
-f docker/Dockerfile \
-t $(BUILDX_TAG) $(PWD)/.; \
else \
DOCKER_BUILDKIT=1 \
docker build \
$(BUILDX_STORE) \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
-f docker/Dockerfile \
-t contracts:latest $(PWD)/.; \
fi
pnpm:
@command -v pnpm > /dev/null || { \
echo "pnpm is not installed. Installing pnpm..."; \
npm install -g pnpm; \
}
# ==============================================================================
# Deployment
NETWORK ?= auto
# Output for generated Solidity artifacts.
# It is required by docker builds, but shouldn't be checked into git.
OUTPUT ?= out
deploy-stack:
pnpm exec hardhat deploy-stack --network $(NETWORK)
# ==============================================================================
# Code generation
# Regenerate bindings and ABI artifacts when sources change with the `make .gen` target.
.gen: $(IPC_ACTORS_CODE)
$(MAKE) gen
touch $@
gen: compile-abi rust-binding
compile-abi: node_modules | forge
mkdir -p $(OUTPUT)
./ops/compile-abi.sh $(OUTPUT)
rust-binding:
OUTPUT=$(OUTPUT) cargo build --locked --release --manifest-path ./binding/Cargo.toml -p ipc_actors_abis
# ==============================================================================
# Running security checks within the local computer
slither:
slither . --config-file ./slither.config.json
# ==============================================================================
# Development support
lint: fmt
pnpm exec solhint 'contracts/**/*.sol' 'sdk/**/**/*.sol'
fmt:
pnpm install --silent --no-save
pnpm exec prettier --check -w 'contracts/**/**/*.sol' 'sdk/**/**/*.sol' 'test/**/**/*.sol' 'test/**/**/*.t.sol' '**/*.{js,jsx,ts,tsx,json,css}'
deps: node_modules
node_modules: package.json pnpm-lock.yaml
pnpm install
touch node_modules
build: node_modules | forge
forge build
FOUNDRY_SRC=sdk forge build
test: node_modules test/helpers/SelectorLibrary.sol | forge
forge test -vvv --ffi
storage:
rm -rf ./cache
rm -rf ./cache_hardhat
pnpm exec hardhat storage-layout --update
clean:
rm -rf ./artifacts
rm -rf ./cache
rm -rf ./cache_hardhat
rm -rf ./typechain
coverage: node_modules | forge
forge coverage --ffi --report lcov -C ./src
@if [ "$(shell uname)" = "Darwin" ]; then \
genhtml -o coverage_report lcov.info --branch-coverage --ignore-errors category; \
else \
genhtml -o coverage_report lcov.info --branch-coverage; \
fi
./tools/check_coverage.sh
prepare: test/helpers/SelectorLibrary.sol fmt lint test slither
test/helpers/SelectorLibrary.sol: | forge
pnpm exec hardhat gen-selector-library
pnpm exec prettier -w test/helpers/SelectorLibrary.sol
# Forge is used by the ipc-solidity-actors compilation steps.
forge:
@if [ -z "$(shell which forge)" ]; then \
echo "Please install Foundry. See https://book.getfoundry.sh/getting-started/installation"; \
exit 1; \
fi
# ==============================================================================