-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
115 lines (92 loc) · 3.66 KB
/
Copy pathMakefile
File metadata and controls
115 lines (92 loc) · 3.66 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# bfctl — Betaflight config tooling
#
# Usage: make help
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := help
PYTHON ?= python3
VENV := .venv
VENV_BIN := $(VENV)/bin
PIP := $(VENV_BIN)/pip
BFCTL := $(VENV_BIN)/bfctl
PYTHON_VENV := $(VENV_BIN)/python
# Optional device selector for device-facing targets (path, serial, or name fragment).
# Example: make status PORT=STM32G473
PORT ?=
PORT_FLAG := $(if $(PORT),--port $(PORT),)
DEVICE ?=
.PHONY: help venv install reinstall check test clean distclean \
ports select status list pull doctor
help: ## Show this help
@echo "bfctl — Betaflight config tooling"
@echo ""
@echo "Setup"
@grep -E '^(venv|install|reinstall|clean|distclean):.*?##' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Dev / CI"
@grep -E '^(check|test|doctor):.*?##' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Device helpers (optional PORT=name|path|serial)"
@grep -E '^(ports|select|status|list|pull):.*?##' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Examples:"
@echo " make install"
@echo " make check"
@echo " make status PORT=STM32G473"
@echo " make pull PORT=TUNERCF405"
@echo " source .venv/bin/activate && bfctl --help"
# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
$(VENV_BIN)/python:
@echo "Creating virtualenv in $(VENV)…"
$(PYTHON) -m venv $(VENV)
$(PIP) install --upgrade pip
venv: $(VENV_BIN)/python ## Create .venv if missing
install: venv ## Install bfctl into .venv (editable)
$(PIP) install -e .
@echo ""
@echo "Installed. Activate with: source $(VENV)/bin/activate"
@echo "Or run: $(BFCTL) --help"
reinstall: ## Force reinstall into a fresh .venv
rm -rf $(VENV) *.egg-info bfctl.egg-info
$(MAKE) install
# ---------------------------------------------------------------------------
# Dev / CI
# ---------------------------------------------------------------------------
check: install ## Offline unit checks (no FC required)
$(PIP) install -e .[dev]
$(PYTHON_VENV) scripts/check.py
$(PYTHON_VENV) -m pytest -q
test: check
doctor: install
@echo "python: $$($(PYTHON_VENV) --version)"
@echo "bfctl: $$($(BFCTL) --version 2>/dev/null || true)"
@echo "venv: $(abspath $(VENV))"
@echo ""
$(BFCTL) ports || true
# ---------------------------------------------------------------------------
# Device helpers (need a plugged FC for status/pull)
# ---------------------------------------------------------------------------
ports: install ## List serial ports (* = FC, S = sticky)
$(BFCTL) ports
select: install ## Sticky device pick (DEVICE=name optional)
$(BFCTL) select $(DEVICE)
status: install ## FC status (PORT=… optional)
$(BFCTL) status $(PORT_FLAG)
list: install ## List local configs/ dumps
$(BFCTL) list
pull: install ## Pull config from FC (PORT=… optional)
$(BFCTL) pull $(PORT_FLAG)
# ---------------------------------------------------------------------------
# Clean
# ---------------------------------------------------------------------------
clean: ## Remove caches and build artifacts (keep .venv)
rm -rf build/ dist/ *.egg-info bfctl.egg-info
find . -type d -name __pycache__ -not -path './.venv/*' -exec rm -rf {} + 2>/dev/null || true
find . -type f -name '*.py[co]' -not -path './.venv/*' -delete 2>/dev/null || true
distclean: clean ## clean + remove .venv and sticky state
rm -rf $(VENV) .bfctl