organic/Makefile

130 lines
5.7 KiB
Makefile
Raw Normal View History

SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
TESTJOBS := 4
OS:=$(shell uname -s)
2023-04-21 02:53:17 +00:00
RELEASEFLAGS :=
2024-01-27 02:17:40 +00:00
WASMTARGET := bundler # or web
ifeq ($(OS),Linux)
TESTJOBS:=$(shell nproc)
2023-04-21 02:53:17 +00:00
RELEASEFLAGS=--target x86_64-unknown-linux-musl
endif
ifeq ($(OS),FreeBSD)
TESTJOBS:=$(shell sysctl -n hw.ncpu)
endif
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
2024-04-07 03:07:37 +00:00
.PHONY: help
help: ## List the available make targets.
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
.PHONY: build
2024-04-07 03:07:37 +00:00
build: ## Make a debug build of the project.
2023-03-25 18:10:22 +00:00
> cargo build
2023-04-19 04:09:25 +00:00
.PHONY: release
2024-04-07 03:07:37 +00:00
release: ## Make an optimized build of the project.
2023-04-21 02:53:17 +00:00
> cargo build --release $(RELEASEFLAGS)
2023-04-19 04:09:25 +00:00
2023-12-24 05:39:57 +00:00
.PHONY: wasm
2024-04-07 03:07:37 +00:00
wasm: ## Build the parser as wasm.
2023-12-24 05:39:57 +00:00
> cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm
2024-01-27 02:17:40 +00:00
> wasm-bindgen --target $(WASMTARGET) --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm
2023-12-24 05:39:57 +00:00
.PHONY: clean
2024-04-07 03:07:37 +00:00
clean: ## Delete the built binaries.
> cargo clean
2024-04-07 03:07:37 +00:00
> $(MAKE) -C docker/organic_development TARGET=builder clean
> $(MAKE) -C docker/organic_development TARGET=format clean
> $(MAKE) -C docker/organic_development TARGET=clippy clean
> $(MAKE) -C docker/organic_development TARGET=wasm clean
> $(MAKE) -C docker/organic_test TARGET=tester build
2023-09-22 03:13:30 +00:00
.PHONY: format
2024-04-07 03:07:37 +00:00
format: ## Format the code.
> cargo fmt
.PHONY: docker_format
docker_format: ## Format the code using docker.
> $(MAKE) -C docker/organic_development TARGET=format build
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" organic-development-format cargo fmt
2023-09-22 03:13:30 +00:00
2024-04-07 03:07:37 +00:00
.PHONY: docker_clippy
docker_clippy: ## Lint the code using docker.
> $(MAKE) -C docker/organic_development TARGET=clippy build
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" organic-development-clippy cargo clippy --no-deps --all-targets --all-features -- -D warnings
2023-10-16 20:16:37 +00:00
.PHONY: clippy
2024-04-07 03:07:37 +00:00
clippy: ## Lint the code.
2023-10-16 20:16:37 +00:00
> cargo clippy --no-deps --all-targets --all-features -- -D warnings
2023-03-25 18:10:22 +00:00
.PHONY: test
2024-04-07 03:07:37 +00:00
test: ## Run the test suite.
> cargo test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
2024-01-04 00:55:22 +00:00
.PHONY: doc
2024-04-07 03:07:37 +00:00
doc: ## Generate documentation.
2024-01-04 00:55:22 +00:00
> cargo doc --no-deps --open --lib --release --all-features
2024-04-07 03:07:37 +00:00
.PHONY: docker_test
docker_test: ## Run the test suite using docker.
> $(MAKE) -C docker/organic_test TARGET=tester build
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
2024-04-07 03:07:37 +00:00
.PHONY: docker_wasm_test
docker_wasm_test: ## Run the test suite with wasm tests.
> $(MAKE) -C docker/organic_test TARGET=tester build
2023-12-30 00:07:07 +00:00
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test --no-default-features --features compare,wasm_test --no-fail-fast --lib --test test_loader autogen_wasm_ -- --test-threads $(TESTJOBS)
2024-04-07 03:07:37 +00:00
.PHONY: build_test
build_test:
> cargo build --no-default-features
> cargo build --no-default-features --features compare
> cargo build --no-default-features --features tracing
> cargo build --no-default-features --features compare,tracing
> cargo build --no-default-features --features compare,foreign_document_test
> cargo build --no-default-features --features compare,tracing,foreign_document_test
2024-01-04 04:04:47 +00:00
> cargo build --target wasm32-unknown-unknown --profile wasm --bin wasm --no-default-features --features wasm
> cargo build --bin wasm_test --no-default-features --features wasm_test
.PHONY: foreign_document_test
foreign_document_test:
2024-04-07 03:07:37 +00:00
> $(MAKE) -C docker/organic_test TARGET=foreign-document build
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test-foreign-document
.PHONY: dockerclean
dockerclean:
# Delete volumes created for running the tests in docker. This does not touch anything related to the jaeger docker container.
> docker volume rm cargo-cache rust-cache
.PHONY: integrationtest
integrationtest:
> cargo test --no-default-features --features compare --no-fail-fast --test test_loader -- --test-threads $(TESTJOBS)
2023-03-25 18:10:22 +00:00
2023-04-19 19:29:46 +00:00
.PHONY: unittest
unittest:
> cargo test --no-default-features --lib -- --test-threads $(TESTJOBS)
2023-04-19 19:29:46 +00:00
.PHONY: jaeger
jaeger:
# 4317 for OTLP gRPC, 4318 for OTLP HTTP. We currently use gRPC but I forward both ports regardless.
#
# These flags didn't help even though they seem like they would: --collector.queue-size=20000 --collector.num-workers=100
> docker run -d --rm --name organicdocker --read-only -p 4317:4317 -p 4318:4318 -p 16686:16686 -e COLLECTOR_OTLP_ENABLED=true jaegertracing/all-in-one:1.47 --collector.grpc-server.max-message-size=20000000 --collector.otlp.grpc.max-message-size=20000000
.PHONY: jaegerweb
jaegerweb:
> xdg-open 'http://localhost:16686'
.PHONY: jaegerstop
jaegerstop:
> docker stop organicdocker