Improve Makefile for reproducible builds
- Add build-all target for full clean rebuild - Use file-based dependencies for proper incremental builds - terminal.js depends on terminal.ts and node_modules - ghostty-vt.wasm depends on node_modules - Add build alias for bundle - Add clean-all to remove everything - Improve help text with organized sections - Fix __pycache__ cleanup pattern
This commit is contained in:
@@ -1,11 +1,45 @@
|
|||||||
.PHONY: help install install-dev lint format test coverage check clean bundle bundle-watch bundle-clean
|
.PHONY: help install install-dev lint format test coverage check clean clean-all build build-all bundle bundle-watch bundle-clean
|
||||||
|
|
||||||
PYTHON ?= python3
|
PYTHON ?= python3
|
||||||
PIP ?= $(PYTHON) -m pip
|
PIP ?= $(PYTHON) -m pip
|
||||||
|
|
||||||
|
# Static assets
|
||||||
|
STATIC_JS_DIR = src/textual_webterm/static/js
|
||||||
|
TERMINAL_JS = $(STATIC_JS_DIR)/terminal.js
|
||||||
|
TERMINAL_TS = $(STATIC_JS_DIR)/terminal.ts
|
||||||
|
GHOSTTY_WASM = $(STATIC_JS_DIR)/ghostty-vt.wasm
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Targets: install install-dev lint format test coverage check clean"
|
@echo "Build targets:"
|
||||||
@echo "Frontend: bundle bundle-watch bundle-clean"
|
@echo " build-all - Full reproducible build (clean + deps + bundle + install)"
|
||||||
|
@echo " build - Build frontend only (bundle)"
|
||||||
|
@echo " bundle - Build terminal.js and copy WASM"
|
||||||
|
@echo " bundle-watch - Watch mode for development"
|
||||||
|
@echo ""
|
||||||
|
@echo "Python targets:"
|
||||||
|
@echo " install - Install package in editable mode"
|
||||||
|
@echo " install-dev - Install with dev dependencies"
|
||||||
|
@echo " lint - Run ruff linter"
|
||||||
|
@echo " format - Format code with ruff"
|
||||||
|
@echo " test - Run pytest"
|
||||||
|
@echo " coverage - Run pytest with coverage"
|
||||||
|
@echo " check - Run lint + coverage"
|
||||||
|
@echo ""
|
||||||
|
@echo "Clean targets:"
|
||||||
|
@echo " clean - Remove Python cache files"
|
||||||
|
@echo " bundle-clean - Remove frontend build artifacts"
|
||||||
|
@echo " clean-all - Remove everything (clean + bundle-clean)"
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Full reproducible build
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
build-all: clean-all node_modules bundle install-dev check
|
||||||
|
@echo "Build complete!"
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Python targets
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
install:
|
install:
|
||||||
$(PIP) install -e .
|
$(PIP) install -e .
|
||||||
@@ -28,19 +62,41 @@ coverage:
|
|||||||
|
|
||||||
check: lint coverage
|
check: lint coverage
|
||||||
|
|
||||||
clean:
|
# =============================================================================
|
||||||
rm -rf .pytest_cache .coverage htmlcov .ruff_cache
|
|
||||||
|
|
||||||
# Frontend build targets (requires Bun: https://bun.sh)
|
# Frontend build targets (requires Bun: https://bun.sh)
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
# Install node dependencies (creates bun.lock if missing)
|
||||||
node_modules: package.json
|
node_modules: package.json
|
||||||
bun install
|
bun install
|
||||||
|
@touch node_modules
|
||||||
|
|
||||||
bundle: node_modules
|
# Build terminal.js from TypeScript
|
||||||
bun run build
|
$(TERMINAL_JS): $(TERMINAL_TS) node_modules
|
||||||
|
bun build $(TERMINAL_TS) --outfile=$(TERMINAL_JS) --minify --target=browser
|
||||||
|
|
||||||
bundle-watch: node_modules
|
# Copy WASM file from node_modules
|
||||||
bun run copy-wasm
|
$(GHOSTTY_WASM): node_modules
|
||||||
bun run watch
|
cp node_modules/ghostty-web/ghostty-vt.wasm $(GHOSTTY_WASM)
|
||||||
|
|
||||||
|
# Main bundle target - builds JS and copies WASM
|
||||||
|
bundle: $(TERMINAL_JS) $(GHOSTTY_WASM)
|
||||||
|
|
||||||
|
# Alias for bundle
|
||||||
|
build: bundle
|
||||||
|
|
||||||
|
# Watch mode for development
|
||||||
|
bundle-watch: $(GHOSTTY_WASM)
|
||||||
|
bun build $(TERMINAL_TS) --outfile=$(TERMINAL_JS) --watch --target=browser
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Clean targets
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf .pytest_cache .coverage htmlcov .ruff_cache __pycache__ src/**/__pycache__
|
||||||
|
|
||||||
bundle-clean:
|
bundle-clean:
|
||||||
rm -rf node_modules bun.lock src/textual_webterm/static/js/terminal.js src/textual_webterm/static/js/ghostty-vt.wasm
|
rm -rf node_modules bun.lock $(TERMINAL_JS) $(GHOSTTY_WASM)
|
||||||
|
|
||||||
|
clean-all: clean bundle-clean
|
||||||
|
|||||||
Reference in New Issue
Block a user