Skip to content

Commit

Permalink
chore: update Makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
leovct committed Nov 28, 2023
1 parent 268f5a3 commit 01da566
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 28 deletions.
39 changes: 12 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ help: ## Display this help.
$(BUILD_DIR): ## Create the build folder.
mkdir -p $(BUILD_DIR)

.PHONY: generate
generate: ## Generate protobuf stubs.
protoc --proto_path=proto --go_out=proto/gen/pb --go_opt=paths=source_relative $(wildcard proto/*.proto)

.PHONY: build
build: $(BUILD_DIR) ## Build go binary.
go build -ldflags "$(VERSION_FLAGS)" -o $(BUILD_DIR)/$(BIN_NAME) main.go
Expand Down Expand Up @@ -78,36 +74,25 @@ test: ## Run tests.

##@ Generation

.PHONY: gen
gen: gen-doc gen-proto gen-go-bindings gen-loadtest-modes gen-json-rpctypes ## Generate everything.

.PHONY: gen-doc
gen-doc: ## Generate documentation for `polycli`.
go run docutil/*.go

.PHONY: gen-loadtest-modes
gen-loadtest-modes: ## Generate loadtest modes strings.
cd cmd/loadtest && stringer -type=loadTestMode
.PHONY: gen-proto
gen-proto: ## Generate protobuf stubs.
protoc --proto_path=proto --go_out=proto/gen/pb --go_opt=paths=source_relative $(wildcard proto/*.proto)

.PHONY: gen-go-bindings
gen-go-bindings: ## Generate go bindings for smart contracts.
cd contracts && make gen-go-bindings

.PHONY: gen-loadtest-modes
gen-loadtest-modes: ## Generate loadtest modes strings.
cd cmd/loadtest && stringer -type=loadTestMode

.PHONY: gen-json-rpctypes
gen-json-rpctypes: ## Generate go bindings for smart contracts.
./scripts/rpctypes.sh rpctypes/jsonschemas/

# Generate go binding.
# - $1: input_dir
# - $2: name
# - $3: pkg
# - $4: output_dir
define gen_go_binding
solc $1/$2.sol --abi --bin --output-dir $1 --overwrite --evm-version paris
abigen --abi $1/$2.abi --bin $1/$2.bin --pkg $3 --type $2 --out $4/$2.go
endef

# Example for the ERC20 contract.
# solc contracts/tokens/ERC20/ERC20.sol --abi --bin --output-dir contracts/tokens/ERC20 --overwrite
# abigen --abi contracts/tokens/ERC20/ERC20.abi --bin contracts/tokens/ERC20/ERC20.bin --pkg tokens --type ERC20 --out contracts/tokens/ERC20.go

# Example for the LoadTester contract.
# solc contracts/loadtester/LoadTester.sol --abi --bin --output-dir contracts/loadtester --overwrite
# abigen --abi contracts/loadtester/LoadTester.abi --bin contracts/loadtester/LoadTester.bin --pkg contracts --type LoadTester --out contracts/LoadTester.go
gen-json-rpctypes: ## Generate JSON rpc types.
./scripts/rpctypes.sh rpctypes/jsonschemas/
2 changes: 1 addition & 1 deletion contracts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ help: ## Display this help.

.PHONY: build
build: ## Build the smart contracts
FOUNDRY_PROFILE=lite forge build
FOUNDRY_PROFILE=lite forge build --force

##@ Gen go bindings

Expand Down

0 comments on commit 01da566

Please sign in to comment.