| 1 | # todo-rust. Cargo's build output lives in .cache/target and Zig's compiled |
| 2 | # libraries (musl, compiler-rt) in .cache/zig, both git-ignored; downloaded |
| 3 | # crate sources stay in ~/.cargo/registry. |
| 4 | SHELL := /bin/bash |
| 5 | TARGET_DIR := .cache/target |
| 6 | ZIG_CACHE := $(CURDIR)/.cache/zig |
| 7 | ARM64 := aarch64-unknown-linux-musl |
| 8 | VERSION := $(shell git rev-parse --short HEAD 2>/dev/null || echo dev) |
| 9 | CARGO := source ../../scripts/env.sh && APP_VERSION=$(VERSION) CARGO_TARGET_DIR=$(TARGET_DIR) \ |
| 10 | ZIG_GLOBAL_CACHE_DIR=$(ZIG_CACHE) ZIG_LOCAL_CACHE_DIR=$(ZIG_CACHE) cargo |
| 11 | APP := todo-rust |
| 12 | HOST := todo-rust.bfj.oncarlos.com |
| 13 | MESSAGE ?= Deploy $(VERSION) |
| 14 | |
| 15 | .PHONY: build build-arm64 test clean clean-deps bump unbump deploy |
| 16 | |
| 17 | build: |
| 18 | $(CARGO) build --release --locked |
| 19 | mkdir -p dist && cp $(TARGET_DIR)/release/$(APP) dist/app |
| 20 | |
| 21 | build-arm64: |
| 22 | $(CARGO) zigbuild --release --locked --target $(ARM64) |
| 23 | mkdir -p dist && cp $(TARGET_DIR)/$(ARM64)/release/$(APP) dist/app-linux-arm64 |
| 24 | |
| 25 | test: |
| 26 | $(CARGO) test --locked |
| 27 | |
| 28 | # Only this crate's own artifacts; compiled dependencies stay. |
| 29 | clean: |
| 30 | rm -rf dist |
| 31 | $(CARGO) clean --release -p $(APP) |
| 32 | $(CARGO) clean --release --target $(ARM64) -p $(APP) |
| 33 | |
| 34 | # Every compiled artifact, dependencies included. Sources stay downloaded. |
| 35 | clean-deps: clean |
| 36 | rm -rf $(TARGET_DIR) $(ZIG_CACHE) |
| 37 | |
| 38 | bump: |
| 39 | sed -i 's/^const BUMP: &str = "unbumped";/const BUMP: \&str = "bumped";/' src/app.rs |
| 40 | |
| 41 | unbump: |
| 42 | sed -i 's/^const BUMP: &str = "bumped";/const BUMP: \&str = "unbumped";/' src/app.rs |
| 43 | |
| 44 | deploy: |
| 45 | carlos deploy --account bfj --app $(APP) --target linux-arm64 --message "$(MESSAGE)" dist/app-linux-arm64 |
| 46 | |