Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make runs though make faster by compiling to separate target dir #213

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Added by Makefile configuration
/makefile-target

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
Expand Down
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,42 @@ CLIPPY_ARGS = --all-targets -- -D warnings
# Fail if `cargo fmt` changes anything.
FMT_ARGS = --all -- --check

# Primary targets
# Treat all warnings as errors
export RUSTFLAGS = -Dwarnings

# Set another target dir than default to avoid builds from `make`
# to invalidate cache from barebones use of `cargo` commands.
# The cache is cleared when a new `RUSTFLAGS` value is encountered,
# so to prevent the two builds from interfering, we use two dirs.
export CARGO_TARGET_DIR=./makefile-target

# By first building tests, and consequently building constraints, before
# running `fmt` and `clippy`, the auto-generated constraints are exposed
# to `fmt` and `clippy`.
default: build-constraints build-tests build-bench fmt-only clippy-only clean-constraints

# Run `make all` when the constraints are already in place.
all: test build-bench fmt-only clippy-only

# Alternative to `cargo build --all-targets`
build: build-constraints
cargo build --all-targets
make clean-constraints

# Alternative to `cargo test --all-targets`
test: build-constraints
test:
cargo test --all-targets
make clean-constraints

# Alternative to `cargo bench --all-targets`
bench: build-constraints
cargo bench --all-targets
make clean-constraints

# Alternative to `cargo clippy ...`
clippy: build-constraints
cargo clippy $(CLIPPY_ARGS)
make clean-constraints

# Alternative to `cargo fmt ...`
fmt-check: build-constraints
cargo fmt $(FMT_ARGS)
make clean-constraints

# Alternative to `cargo clean`
clean:
Expand Down
Loading