2022-04-08 09:44:50 -05:00
|
|
|
###############################
|
|
|
|
# Common defaults/definitions #
|
|
|
|
###############################
|
|
|
|
|
|
|
|
comma := ,
|
|
|
|
|
|
|
|
# Checks two given strings for equality.
|
|
|
|
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
|
|
|
|
$(findstring $(2),$(1))),1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###########
|
|
|
|
# Aliases #
|
|
|
|
###########
|
|
|
|
|
|
|
|
book: book.build
|
|
|
|
|
|
|
|
|
2023-10-27 10:51:41 -05:00
|
|
|
codespell: book.codespell
|
|
|
|
|
|
|
|
|
2022-04-08 09:44:50 -05:00
|
|
|
fmt: cargo.fmt
|
|
|
|
|
|
|
|
|
|
|
|
lint: cargo.lint
|
|
|
|
|
|
|
|
|
|
|
|
test: test.cargo
|
|
|
|
|
|
|
|
|
|
|
|
release: cargo.release
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##################
|
|
|
|
# Cargo commands #
|
|
|
|
##################
|
|
|
|
|
|
|
|
# Format Rust sources with rustfmt.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# make cargo.fmt [check=(no|yes)]
|
|
|
|
|
|
|
|
cargo.fmt:
|
|
|
|
cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,)
|
|
|
|
|
|
|
|
|
|
|
|
# Lint Rust sources with Clippy.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# make cargo.lint
|
|
|
|
|
|
|
|
cargo.lint:
|
|
|
|
cargo clippy --workspace --all-features -- -D warnings
|
2023-11-17 14:38:17 -06:00
|
|
|
cargo clippy -p juniper_integration_tests --tests --all-features -- -D warnings
|
2022-04-08 09:44:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Release Rust crate.
|
|
|
|
#
|
|
|
|
# Read more about bump levels here:
|
|
|
|
# https://github.com/crate-ci/cargo-release/blob/master/docs/reference.md#bump-level
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# make cargo.release crate=<crate-name> [ver=(release|<bump-level>)]
|
|
|
|
# ([exec=no]|exec=yes [push=(yes|no)])
|
|
|
|
# [install=(yes|no)]
|
|
|
|
|
|
|
|
cargo.release:
|
|
|
|
ifneq ($(install),no)
|
|
|
|
cargo install cargo-release
|
|
|
|
endif
|
|
|
|
cargo release -p $(crate) --all-features \
|
|
|
|
$(if $(call eq,$(exec),yes),\
|
|
|
|
--no-publish $(if $(call eq,$(push),no),--no-push,) --execute,\
|
2022-04-14 11:07:48 -05:00
|
|
|
-v $(if $(call eq,$(CI),),,--no-publish)) \
|
2022-04-08 09:44:50 -05:00
|
|
|
$(or $(ver),release)
|
|
|
|
|
|
|
|
|
|
|
|
cargo.test: test.cargo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
####################
|
|
|
|
# Testing commands #
|
|
|
|
####################
|
|
|
|
|
|
|
|
# Run Rust tests of Book.
|
|
|
|
#
|
|
|
|
# Usage:
|
2022-07-20 05:37:58 -05:00
|
|
|
# make test.book [clean=(no|yes)]
|
2022-04-08 09:44:50 -05:00
|
|
|
|
|
|
|
test.book:
|
2022-07-20 05:37:58 -05:00
|
|
|
ifeq ($(clean),yes)
|
|
|
|
cargo clean
|
|
|
|
endif
|
2022-11-02 10:32:50 -05:00
|
|
|
$(eval target := $(strip $(shell cargo -vV | sed -n 's/host: //p')))
|
2023-10-17 09:12:20 -05:00
|
|
|
cargo build --all-features
|
2022-11-02 10:32:50 -05:00
|
|
|
mdbook test book -L target/debug/deps $(strip \
|
|
|
|
$(if $(call eq,$(findstring windows,$(target)),),,\
|
|
|
|
$(shell cargo metadata -q \
|
|
|
|
| jq -r '.packages[] | select(.name == "windows_$(word 1,$(subst -, ,$(target)))_$(word 4,$(subst -, ,$(target)))") | .manifest_path' \
|
|
|
|
| sed -e "s/^/-L '/" -e 's/Cargo.toml/lib/' -e "s/$$/'/" )))
|
2022-04-08 09:44:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Run Rust tests of project crates.
|
|
|
|
#
|
|
|
|
# Usage:
|
2022-10-21 11:07:17 -05:00
|
|
|
# make test.cargo [crate=<crate-name>] [careful=(no|yes)]
|
2022-04-08 09:44:50 -05:00
|
|
|
|
|
|
|
test.cargo:
|
2022-10-21 11:07:17 -05:00
|
|
|
ifeq ($(careful),yes)
|
|
|
|
ifeq ($(shell cargo install --list | grep cargo-careful),)
|
|
|
|
cargo install cargo-careful
|
|
|
|
endif
|
|
|
|
ifeq ($(shell rustup component list --toolchain=nightly \
|
|
|
|
| grep 'rust-src (installed)'),)
|
|
|
|
rustup component add --toolchain=nightly rust-src
|
|
|
|
endif
|
|
|
|
endif
|
2023-11-01 13:00:05 -05:00
|
|
|
cargo $(if $(call eq,$(careful),yes),+nightly careful,) \
|
2022-10-21 11:07:17 -05:00
|
|
|
test $(if $(call eq,$(crate),),--workspace,-p $(crate)) --all-features
|
2022-04-08 09:44:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#################
|
|
|
|
# Book commands #
|
|
|
|
#################
|
|
|
|
|
|
|
|
# Build Book.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# make book.build [out=<dir>]
|
|
|
|
|
|
|
|
book.build:
|
|
|
|
mdbook build book/ $(if $(call eq,$(out),),,-d $(out))
|
|
|
|
|
|
|
|
|
2023-10-27 10:51:41 -05:00
|
|
|
# Spellcheck Book.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# make book.codespell [fix=(no|yes)]
|
|
|
|
|
|
|
|
book.codespell:
|
|
|
|
codespell book/ $(if $(call eq,$(fix),yes),--write-changes,)
|
|
|
|
|
|
|
|
|
2022-04-08 09:44:50 -05:00
|
|
|
# Serve Book on some port.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# make book.serve [port=(3000|<port>)]
|
|
|
|
|
|
|
|
book.serve:
|
|
|
|
mdbook serve book/ -p=$(or $(port),3000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-13 10:34:44 -05:00
|
|
|
######################
|
|
|
|
# Forwarded commands #
|
|
|
|
######################
|
|
|
|
|
|
|
|
# Download and prepare actual version of GraphiQL static files, used for
|
|
|
|
# integrating it.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# make graphiql
|
|
|
|
|
|
|
|
graphiql:
|
|
|
|
@cd juniper/ && \
|
|
|
|
make graphiql
|
|
|
|
|
|
|
|
|
2023-09-13 12:10:49 -05:00
|
|
|
# Download and prepare actual version of GraphQL Playground static files, used
|
|
|
|
# for integrating it.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# make graphql-playground
|
|
|
|
|
|
|
|
graphql-playground:
|
|
|
|
@cd juniper/ && \
|
|
|
|
make graphql-playground
|
|
|
|
|
|
|
|
|
2023-09-13 10:34:44 -05:00
|
|
|
|
|
|
|
|
2022-04-08 09:44:50 -05:00
|
|
|
##################
|
|
|
|
# .PHONY section #
|
|
|
|
##################
|
|
|
|
|
2023-10-27 10:51:41 -05:00
|
|
|
.PHONY: book codespell fmt lint release test \
|
|
|
|
book.build book.codespell book.serve \
|
2022-04-08 09:44:50 -05:00
|
|
|
cargo.fmt cargo.lint cargo.release cargo.test \
|
2023-09-13 12:10:49 -05:00
|
|
|
graphiql graphql-playground \
|
2022-04-08 09:44:50 -05:00
|
|
|
test.book test.cargo
|