-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (52 loc) · 1.93 KB
/
Copy pathMakefile
File metadata and controls
65 lines (52 loc) · 1.93 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
# linkctl — build helpers. All real work is done by cargo.
CARGO ?= cargo
BIN_DIR ?= bin
BINARY := $(BIN_DIR)/linkctl
PREFIX ?= $(HOME)/.local
VERSION ?= $(shell grep -m1 '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
# Static musl target used for release artifacts; ARCH is the package name
# convention (amd64|arm64) used by the release workflow and mise.
TARGET ?= $(shell uname -m | sed -e 's/x86_64/x86_64-unknown-linux-musl/' -e 's/aarch64/aarch64-unknown-linux-musl/')
ARCH ?= $(shell uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/')
.PHONY: all build debug test lint check install uninstall clean dist release
all: build
## Build the optimised binary into bin/linkctl
build:
$(CARGO) build --release
mkdir -p $(BIN_DIR)
cp target/release/linkctl $(BINARY)
@echo "built $(BINARY)"
## Build an unoptimised binary into bin/linkctl (faster to compile)
debug:
$(CARGO) build
mkdir -p $(BIN_DIR)
cp target/debug/linkctl $(BINARY)
@echo "built $(BINARY) (debug)"
## Run unit tests (never touches the camera)
test:
$(CARGO) test
## Formatting and clippy, as run in CI
lint:
$(CARGO) fmt --check
$(CARGO) clippy --all-targets --all-features -- -D warnings
## lint + test
check: lint test
## Install into $(PREFIX)/bin (default: ~/.local/bin)
install: build
install -Dm755 $(BINARY) $(PREFIX)/bin/linkctl
uninstall:
rm -f $(PREFIX)/bin/linkctl
## Build the static release binary for this machine and package it into
## dist/ (tar.gz always; deb/rpm/pkg.tar.zst when nfpm is installed).
## Same artifacts the release workflow publishes.
dist:
rustup target add $(TARGET)
$(CARGO) build --release --locked --target $(TARGET)
scripts/package.sh target/$(TARGET)/release/linkctl $(VERSION) $(ARCH)
## Interactive release: propose the next semver tag, bump Cargo.toml,
## commit, tag and push. The tag triggers .github/workflows/release.yml.
release:
@scripts/release.sh
clean:
$(CARGO) clean
rm -rf $(BIN_DIR) dist