-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (50 loc) · 1.93 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Variables
PROJECT_NAME := wiki_meilisearch
DOCKER_COMPOSE := docker-compose.yml
PKG_DIR := pkg
SOURCE_FILES := engine.js definition.yml
# Default target (help)
.DEFAULT_GOAL := help
# List of targets with descriptions
help: ## Show this help
@echo "$(PROJECT_NAME)"
@echo "Usage: make <target>"
@echo
@awk 'BEGIN {FS = ":.*##"; printf "\033[1m\033[36m%-20s\033[0m %s\n", "Target", "Help"} \
{ if (NF == 2) printf "\033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) | grep -v 'awk'
setup: ## Install Rust, wasm32 target, and wasm-pack
@echo "Checking and installing necessary tools..."
@if ! command -v rustup &> /dev/null; then \
echo "rustup not found. Installing rustup..."; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
fi
@if ! rustup target list --installed | grep -q wasm32-unknown-unknown; then \
echo "wasm32-unknown-unknown target not found. Adding target..."; \
rustup target add wasm32-unknown-unknown; \
fi
@if ! command -v wasm-pack &> /dev/null; then \
echo "wasm-pack not found. Installing wasm-pack..."; \
cargo install wasm-pack --force; \
fi
build: clean ## Build the project
@echo "Copying necessary files to pkg..."
@mkdir -p $(PKG_DIR)
@cp $(SOURCE_FILES) $(PKG_DIR)
@echo "Building wasm-pack..."
@wasm-pack build --target nodejs
dev: build ## Build the project and start development environment
@echo "Starting Docker Compose..."
@docker compose -f $(DOCKER_COMPOSE) up --remove-orphans
lint: ## Run linters on the Rust code
@echo "Running linters..."
@cargo fmt -- --check
@cargo clippy -- -D warnings
@npx -y prettier --write ./{*,.github/**/*}.{js,md,yaml,yml}
clean: ## Clean up the project
@echo "Cleaning up..."
@rm -rf $(PKG_DIR)
@docker compose -f $(DOCKER_COMPOSE) down --remove-orphans --volumes
stop: ## Stop running Docker containers
@echo "Stopping Docker Compose..."
@docker compose -f $(DOCKER_COMPOSE) down
.PHONY: help setup build dev lint clean stop