-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (79 loc) · 3.69 KB
/
Copy pathMakefile
File metadata and controls
99 lines (79 loc) · 3.69 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# =============================================================================
# swift — On-Device CoreML Bioacoustic Classifier
# =============================================================================
SHELL := /bin/sh
COMPOSE ?= docker compose
ENV_FILE ?= .env
RECORDINGS ?= ./Samples/whales
MODELS ?= ./Samples/models
OUT ?= ./out
MODEL ?= BirdNET-v2.4
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_%-]+:.*?## / {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
$(ENV_FILE):
@cp .env.example $(ENV_FILE)
@echo "Created $(ENV_FILE) from .env.example — edit as desired."
# -----------------------------------------------------------------------------
# Native (Mac, CoreML path)
# -----------------------------------------------------------------------------
.PHONY: build
build: ## swift build (native; CoreML available on Mac)
swift build -c debug
.PHONY: build-release
build-release: ## swift build -c release
swift build -c release
.PHONY: test
test: ## swift test — fast smoke tests, no docker/network required
swift test --parallel
.PHONY: seed
seed: ## Regenerate the bundled synthetic WAV corpus
@mkdir -p $(RECORDINGS)
swift /tmp/gen_samples.swift $(RECORDINGS) 2>/dev/null || \
(echo "Re-creating generator…"; \
cp Samples/Generate/Generate.swift /tmp/gen.swift; \
swift /tmp/gen.swift $(RECORDINGS))
.PHONY: run-host-runtime
run-host-runtime: build ## Run the runtime natively on the host (CoreML mode)
RECORDINGS_DIR=$(RECORDINGS) MODELS_DIR=$(MODELS) ANNOTATIONS_DIR=$(OUT) \
DEFAULT_MODEL=$(MODEL) .build/debug/BioacousticRuntime
.PHONY: annotate
annotate: build ## Submit a job. Usage: make annotate IN=path/to/wavs [MODEL=BirdNET-v2.4]
@if [ -z "$(IN)" ]; then echo "usage: make annotate IN=path/to/wavs"; exit 1; fi
.build/debug/bioacoustic annotate --in $(IN) --model $(MODEL) \
--out $(OUT) --models-dir $(MODELS)
.PHONY: list
list: build ## List annotated job IDs under ./out
.build/debug/bioacoustic list --out $(OUT)
.PHONY: open
open: build ## Print job artifact paths. Usage: make open ID=job_xxx
@if [ -z "$(ID)" ]; then echo "usage: make open ID=job_xxxx"; exit 1; fi
.build/debug/bioacoustic open $(ID) --out $(OUT)
# -----------------------------------------------------------------------------
# Containers (Linux / ONNX fallback path + ollama + client TUI)
# -----------------------------------------------------------------------------
.PHONY: up
up: $(ENV_FILE) ## Bring up ollama + client. Print host-runtime hint on macOS.
@echo ""
@uname -s | grep -qi darwin && \
echo " Detected macOS — start the Swift runtime natively for CoreML:" && \
echo " make run-host-runtime # in another terminal" && echo "" || \
echo " Detected non-macOS — runtime container will use ONNX fallback."
$(COMPOSE) --env-file $(ENV_FILE) up --build --abort-on-container-exit --remove-orphans
.PHONY: down
down: ## Stop and remove containers
$(COMPOSE) --env-file $(ENV_FILE) down --remove-orphans
.PHONY: logs
logs: ## Tail logs from all services
$(COMPOSE) --env-file $(ENV_FILE) logs -f --tail=200
.PHONY: shell
shell: ## Shell into the client container
$(COMPOSE) --env-file $(ENV_FILE) run --rm --entrypoint /bin/bash arcp-client
.PHONY: verify
verify: ## docker build only — proves @latest install resolves cleanly
docker build --build-arg ARCP_SDK_VERSION=$${ARCP_SDK_VERSION:-latest} -t arcp-sdk-examples/swift-verify:test .
.PHONY: clean
clean: down ## Remove built images and the local .build cache
-docker rmi arcp-sdk-examples/swift-runtime:dev arcp-sdk-examples/swift-client:dev arcp-sdk-examples/swift-verify:test 2>/dev/null || true
-rm -rf .build $(OUT)