.DEFAULT_GOAL := all
CARGO := cargo
CARGO_FLAGS := --locked
TAILWIND_BIN := ./tools/tailwindcss
TAILWIND_INPUT := templates/static/css/tailwind.input.css
TAILWIND_OUTPUT := templates/static/css/tailwind.css
TAILWIND_CONTENT := "templates/**/*.html src/**/*.rs"
.PHONY: all fmt lint lint-rust lint-md check test doc doc-open build release install run download-tailwind tailwind tailwind-watch clean help
all: fmt lint check test-all doc build
fmt:
@echo "Formatting code..."
@$(CARGO) fmt
lint: lint-rust lint-md
lint-rust:
@echo "Linting Rust code..."
@$(CARGO) clippy $(CARGO_FLAGS) --all-targets --all-features -- -D warnings
lint-md:
@echo "Linting Markdown files..."
@markdownlint .
check:
@echo "Type-checking code..."
@$(CARGO) check $(CARGO_FLAGS) --all-targets --all-features
test:
@echo "Running unit tests..."
@$(CARGO) test $(CARGO_FLAGS) --lib --bins
test-integration:
@echo "Running integration tests..."
@$(CARGO) test $(CARGO_FLAGS) --test '*'
test-all:
@echo "Running all tests..."
@$(CARGO) test $(CARGO_FLAGS) --all-targets --all-features
doc:
@echo "Building documentation..."
@$(CARGO) doc $(CARGO_FLAGS) --no-deps
doc-open:
@echo "Building and opening documentation..."
@$(CARGO) doc $(CARGO_FLAGS) --no-deps --open
build: tailwind
@echo "Building debug binary..."
@$(CARGO) build $(CARGO_FLAGS)
release: tailwind
@echo "Building release binary..."
@$(CARGO) build $(CARGO_FLAGS) --release
install: tailwind
@echo "Installing oculus..."
@$(CARGO) install $(CARGO_FLAGS) --path .
run: tailwind ## Run (use ARGS="..." for arguments)
@$(CARGO) run $(CARGO_FLAGS) -- $(ARGS)
download-tailwind:
@if [ ! -f $(TAILWIND_BIN) ]; then \
echo "Downloading Tailwind CSS CLI..."; \
mkdir -p tools; \
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64 -o $(TAILWIND_BIN); \
chmod +x $(TAILWIND_BIN); \
echo "✓ Tailwind CSS CLI installed to $(TAILWIND_BIN)"; \
else \
echo "✓ Tailwind CSS CLI already present"; \
fi
tailwind: download-tailwind
@echo "Building Tailwind CSS..."
@mkdir -p $(dir $(TAILWIND_OUTPUT))
@test -f $(TAILWIND_INPUT) || { echo "Missing $(TAILWIND_INPUT); add @import \"tailwindcss\""; exit 1; }
@$(TAILWIND_BIN) -i $(TAILWIND_INPUT) -o $(TAILWIND_OUTPUT) --minify --content $(TAILWIND_CONTENT)
clean:
@echo "Cleaning build artifacts..."
@$(CARGO) clean
update:
@echo "Updating dependencies..."
@$(CARGO) update
help:
@echo "Oculus - Available targets:"
@echo ""
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*##/ { \
printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 \
}' $(MAKEFILE_LIST)
@echo ""
@echo "Examples:"
@echo " make @echo " make run ARGS='--help'"