mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-10 07:04:17 +00:00
chore: replace make
with cargo-make
`cargo-make` make it easier to provide developers of all platforms an unified build workflow.
This commit is contained in:
parent
77c6e106e4
commit
9cdff275cb
2 changed files with 111 additions and 116 deletions
116
Makefile
116
Makefile
|
@ -1,116 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
|
||||
# ================================ Cargo ======================================
|
||||
|
||||
|
||||
RUST_CHANNEL ?= stable
|
||||
CARGO_FLAGS =
|
||||
RUSTUP_INSTALLED = $(shell command -v rustup 2> /dev/null)
|
||||
TEST_FILTER ?=
|
||||
|
||||
ifndef RUSTUP_INSTALLED
|
||||
CARGO = cargo
|
||||
else
|
||||
ifdef CI
|
||||
CARGO = cargo
|
||||
else
|
||||
CARGO = rustup run $(RUST_CHANNEL) cargo
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# ================================ Help =======================================
|
||||
|
||||
.PHONY: help
|
||||
help: ## Print all the available commands
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
|
||||
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
|
||||
# =============================== Build =======================================
|
||||
|
||||
.PHONY: check
|
||||
check: ## Validate the project code
|
||||
$(CARGO) check
|
||||
|
||||
.PHONY: build
|
||||
build: ## Build the project in debug mode
|
||||
$(CARGO) build $(CARGO_FLAGS)
|
||||
|
||||
.PHONY: release
|
||||
release: CARGO_FLAGS += --release
|
||||
release: build ## Build the project in release mode
|
||||
|
||||
|
||||
# ================================ Lint =======================================
|
||||
|
||||
.PHONY: lint
|
||||
lint: fmt clippy ## Lint project files
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: ## Check the format of the source code
|
||||
cargo fmt --all -- --check
|
||||
|
||||
.PHONY: clippy
|
||||
clippy: ## Check the style of the source code and catch common errors
|
||||
$(CARGO) clippy --all-targets --all-features -- -D warnings
|
||||
|
||||
|
||||
# ================================ Test =======================================
|
||||
|
||||
.PHONY: test
|
||||
test: ## Run the tests
|
||||
$(CARGO) test --all-features $(TEST_FILTER)
|
||||
|
||||
# =============================== Examples ====================================
|
||||
|
||||
.PHONY: build-examples
|
||||
build-examples: ## Build all examples
|
||||
@$(CARGO) build --release --examples --all-features
|
||||
|
||||
.PHONY: run-examples
|
||||
run-examples: build-examples ## Run all examples
|
||||
@for file in examples/*.rs; do \
|
||||
name=$$(basename $${file/.rs/}); \
|
||||
$(CARGO) run --all-features --release --example $$name; \
|
||||
done;
|
||||
|
||||
# ================================ Doc ========================================
|
||||
|
||||
|
||||
.PHONY: doc
|
||||
doc: RUST_CHANNEL = nightly
|
||||
doc: ## Build the documentation (available at ./target/doc)
|
||||
$(CARGO) doc
|
||||
|
||||
|
||||
# ================================= Watch =====================================
|
||||
|
||||
# Requires watchman and watchman-make (https://facebook.github.io/watchman/docs/install.html)
|
||||
|
||||
.PHONY: watch
|
||||
watch: ## Watch file changes and build the project if any
|
||||
watchman-make -p 'src/**/*.rs' -t check build
|
||||
|
||||
.PHONY: watch-test
|
||||
watch-test: ## Watch files changes and run the tests if any
|
||||
watchman-make -p 'src/**/*.rs' 'tests/**/*.rs' 'examples/**/*.rs' -t test
|
||||
|
||||
.PHONY: watch-doc
|
||||
watch-doc: RUST_CHANNEL = nightly
|
||||
watch-doc: ## Watch file changes and rebuild the documentation if any
|
||||
$(CARGO) watch -x doc -x 'test --doc'
|
||||
|
||||
# ================================= Pipelines =================================
|
||||
|
||||
.PHONY: stable
|
||||
stable: RUST_CHANNEL = stable
|
||||
stable: build lint test ## Run build and tests for stable
|
||||
|
||||
.PHONY: beta
|
||||
beta: RUST_CHANNEL = beta
|
||||
beta: build lint test ## Run build and tests for beta
|
||||
|
||||
.PHONY: nightly
|
||||
nightly: RUST_CHANNEL = nightly
|
||||
nightly: build lint test ## Run build, lint and tests for nightly
|
111
Makefile.toml
Normal file
111
Makefile.toml
Normal file
|
@ -0,0 +1,111 @@
|
|||
[config]
|
||||
skip_core_tasks = true
|
||||
|
||||
[env.TUI_FEATURES]
|
||||
source = "${CARGO_MAKE_RUST_TARGET_OS}"
|
||||
default_value = "unknown"
|
||||
|
||||
[env.TUI_FEATURES.mapping]
|
||||
linux = "serde,crossterm,termion,rustbox,curses"
|
||||
macos = "serde,crossterm,termion,rustbox,curses"
|
||||
windows = "serde,crossterm"
|
||||
|
||||
[tasks.default]
|
||||
dependencies = [
|
||||
"check",
|
||||
]
|
||||
|
||||
[tasks.ci]
|
||||
dependencies = [
|
||||
"fmt",
|
||||
"check",
|
||||
"test",
|
||||
"clippy",
|
||||
]
|
||||
|
||||
|
||||
[tasks.fmt]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"fmt",
|
||||
"--all",
|
||||
"--",
|
||||
"--check",
|
||||
]
|
||||
|
||||
[tasks.check]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"check",
|
||||
"--no-default-features",
|
||||
"--features",
|
||||
"${TUI_FEATURES}",
|
||||
"--all-targets",
|
||||
]
|
||||
|
||||
[tasks.build]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"build",
|
||||
"--no-default-features",
|
||||
"--features",
|
||||
"${TUI_FEATURES}",
|
||||
"--all-targets",
|
||||
]
|
||||
|
||||
[tasks.clippy]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"clippy",
|
||||
"--no-default-features",
|
||||
"--features",
|
||||
"${TUI_FEATURES}",
|
||||
"--",
|
||||
"-D",
|
||||
"warnings",
|
||||
]
|
||||
|
||||
[tasks.test]
|
||||
linux_alias = "test-unix"
|
||||
mac_alias = "test-unix"
|
||||
windows_alias = "test-windows"
|
||||
|
||||
[tasks.test-unix]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"test",
|
||||
"--no-default-features",
|
||||
"--features",
|
||||
"${TUI_FEATURES}"
|
||||
]
|
||||
|
||||
# Documentation tests cannot be run on Windows for now
|
||||
[tasks.test-windows]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"test",
|
||||
"--no-default-features",
|
||||
"--features",
|
||||
"${TUI_FEATURES}",
|
||||
"--lib",
|
||||
"--tests",
|
||||
"--examples",
|
||||
]
|
||||
|
||||
[tasks.run-examples]
|
||||
linux_alias = "run-examples-unix"
|
||||
mac_alias = "run-examples-unix"
|
||||
windows_alias = "run-examples-windows"
|
||||
|
||||
[tasks.run-examples-unix]
|
||||
script = '''
|
||||
#!/usr/bin/env bash
|
||||
cargo build --examples --features ${TUI_FEATURES} --release
|
||||
for file in examples/*.rs; do
|
||||
name="$(basename "${file/.rs/}")"
|
||||
cargo run --features ${TUI_FEATURES} --release --example "${name}"
|
||||
done
|
||||
'''
|
||||
|
||||
[tasks.run-examples-windows]
|
||||
# TODO
|
Loading…
Reference in a new issue