Skip to content

Commit

Permalink
Makefile improvements (0xPolygonHermez#2419)
Browse files Browse the repository at this point in the history
  • Loading branch information
criadoperez authored Aug 18, 2023
1 parent b8f23d2 commit 3086056
Showing 1 changed file with 69 additions and 27 deletions.
96 changes: 69 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARCH := $(shell arch)

ifeq ($(ARCH),x86_64)
ARCH = amd64
else
else
ifeq ($(ARCH),aarch64)
ARCH = arm64
endif
Expand All @@ -26,8 +26,53 @@ VENV_PYTHON = $(VENV)/bin/python
SYSTEM_PYTHON = $(or $(shell which python3), $(shell which python))
PYTHON = $(or $(wildcard $(VENV_PYTHON)), "install_first_venv")
GENERATE_SCHEMA_DOC = $(VENV)/bin/generate-schema-doc
GENERATE_DOC_PATH= "docs/config-file/"
GENERATE_DOC_TEMPLATES_PATH= "docs/config-file/templates/"
GENERATE_DOC_PATH = "docs/config-file/"
GENERATE_DOC_TEMPLATES_PATH = "docs/config-file/templates/"

# Check dependencies
# Check for Go
.PHONY: check-go
check-go:
@which go > /dev/null || (echo "Error: Go is not installed" && exit 1)

# Check for Docker
.PHONY: check-docker
check-docker:
@which docker > /dev/null || (echo "Error: docker is not installed" && exit 1)

# Check for Docker-compose
.PHONY: check-docker-compose
check-docker-compose:
@which docker-compose > /dev/null || (echo "Error: docker-compose is not installed" && exit 1)

# Check for Protoc
.PHONY: check-protoc
check-protoc:
@which protoc > /dev/null || (echo "Error: Protoc is not installed" && exit 1)

# Check for Python
.PHONY: check-python
check-python:
@which python3 > /dev/null || which python > /dev/null || (echo "Error: Python is not installed" && exit 1)

# Check for Curl
.PHONY: check-curl
check-curl:
@which curl > /dev/null || (echo "Error: curl is not installed" && exit 1)

# Targets that require the checks
build: check-go
lint: check-go
build-docker: check-docker
build-docker-nc: check-docker
run-rpc: check-docker check-docker-compose
stop: check-docker check-docker-compose
install-linter: check-go check-curl
install-config-doc-gen: check-python
config-doc-node: check-go check-python
config-doc-custom_network: check-go check-python
update-external-dependencies: check-go
generate-code-from-proto: check-protoc

.PHONY: build
build: ## Builds the binary locally into ./dist
Expand All @@ -42,7 +87,7 @@ build-docker-nc: ## Builds a docker image with the node binary - but without bui
docker build --no-cache=true -t zkevm-node -f ./Dockerfile .

.PHONY: run-rpc
run-rpc: ## Runs all the services need to run a local zkEMV RPC node
run-rpc: ## Runs all the services needed to run a local zkEVM RPC node
docker-compose up -d zkevm-state-db zkevm-pool-db
sleep 2
docker-compose up -d zkevm-prover
Expand All @@ -63,7 +108,6 @@ install-linter: ## Installs the linter
lint: ## Runs the linter
export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/golangci-lint run


$(VENV_PYTHON):
rm -rf $(VENV)
$(SYSTEM_PYTHON) -m venv $(VENV)
Expand All @@ -76,38 +120,36 @@ $(GENERATE_SCHEMA_DOC): $(VENV_PYTHON)
$(PYTHON) -m pip install --upgrade pip
$(PYTHON) -m pip install json-schema-for-humans

PHONY: config-doc-gen
.PHONY: config-doc-gen
config-doc-gen: config-doc-node config-doc-custom_network ## Generate config file's json-schema for node and custom_network and documentation
#

.PHONY: config-doc-node
config-doc-node: $(GENERATE_SCHEMA_DOC) ## Generate config file's json-schema for node and documentation
go run ./cmd generate-json-schema --config-file=node --output=$(GENERATE_DOC_PATH)node-config-schema.json
$(GENERATE_SCHEMA_DOC) --config show_breadcrumbs=true \
--config footer_show_time=false \
--config expand_buttons=true \
--config custom_template_path=$(GENERATE_DOC_TEMPLATES_PATH)/js/base.html \
$(GENERATE_DOC_PATH)node-config-schema.json \
$(GENERATE_DOC_PATH)node-config-doc.html
--config footer_show_time=false \
--config expand_buttons=true \
--config custom_template_path=$(GENERATE_DOC_TEMPLATES_PATH)/js/base.html \
$(GENERATE_DOC_PATH)node-config-schema.json \
$(GENERATE_DOC_PATH)node-config-doc.html
$(GENERATE_SCHEMA_DOC) --config custom_template_path=$(GENERATE_DOC_TEMPLATES_PATH)/md/base.md \
--config footer_show_time=false \
$(GENERATE_DOC_PATH)node-config-schema.json \
$(GENERATE_DOC_PATH)node-config-doc.md
--config footer_show_time=false \
$(GENERATE_DOC_PATH)node-config-schema.json \
$(GENERATE_DOC_PATH)node-config-doc.md

.PHONY: config-doc-custom_network
config-doc-custom_network: $(GENERATE_SCHEMA_DOC) ## Generate config file's json-schema for custom_network and documentation
go run ./cmd generate-json-schema --config-file=custom_network --output=$(GENERATE_DOC_PATH)custom_network-config-schema.json
$(GENERATE_SCHEMA_DOC) --config show_breadcrumbs=true --config footer_show_time=false \
--config expand_buttons=true \
--config custom_template_path=$(GENERATE_DOC_TEMPLATES_PATH)/js/base.html \
$(GENERATE_DOC_PATH)custom_network-config-schema.json \
$(GENERATE_DOC_PATH)custom_network-config-doc.html
--config expand_buttons=true \
--config custom_template_path=$(GENERATE_DOC_TEMPLATES_PATH)/js/base.html \
$(GENERATE_DOC_PATH)custom_network-config-schema.json \
$(GENERATE_DOC_PATH)custom_network-config-doc.html
$(GENERATE_SCHEMA_DOC) --config custom_template_path=$(GENERATE_DOC_TEMPLATES_PATH)/md/base.md \
--config footer_show_time=false \
--config example_format=JSON \
$(GENERATE_DOC_PATH)custom_network-config-schema.json \
$(GENERATE_DOC_PATH)custom_network-config-doc.md

--config footer_show_time=false \
--config example_format=JSON \
$(GENERATE_DOC_PATH)custom_network-config-schema.json \
$(GENERATE_DOC_PATH)custom_network-config-doc.md

.PHONY: update-external-dependencies
update-external-dependencies: ## Updates external dependencies like images, test vectors or proto files
Expand All @@ -130,6 +172,6 @@ generate-code-from-proto: ## Generates code from proto files

.PHONY: help
help: ## Prints this help
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

0 comments on commit 3086056

Please sign in to comment.