-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathMakefile
More file actions
184 lines (151 loc) · 6.71 KB
/
Copy pathMakefile
File metadata and controls
184 lines (151 loc) · 6.71 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# ArcBox Development Makefile
PROFILE ?= debug
# Local dev signing uses the dev entitlements (disables library validation
# for nix-store libiconv). The release path (.github/workflows/release.yml)
# signs with bundle/arcbox.entitlements, which keeps validation enabled.
ENTITLEMENTS := bundle/arcbox.dev.entitlements
AGENT_TARGET := aarch64-unknown-linux-musl
# Signing identity: auto-detect "Developer ID Application: ArcBox, Inc."
# from keychain. Override with: make sign SIGN_IDENTITY="..."
# Use SIGN_IDENTITY=- for ad-hoc signing (won't work with Virtualization.framework
# on recent macOS).
SIGN_IDENTITY ?= $(shell security find-identity -v -p codesigning 2>/dev/null \
| grep -o '"Developer ID Application: ArcBox, Inc\.[^"]*"' \
| head -1 | tr -d '"')
BINARIES := arcbox-daemon arcbox-helper abctl
ifeq ($(PROFILE),release)
CARGO_FLAGS := --release
TARGET_DIR := target/release
else
CARGO_FLAGS :=
TARGET_DIR := target/debug
endif
.PHONY: build build-release build-cli build-daemon build-helper build-agent \
build-fleet-agent fleet-proto-sync \
test check fmt clean \
setup-boot-assets sign sign-daemon sign-all verify run-daemon \
run-helper install-helper reload-helper test-helper
## ── Build ──────────────────────────────────────────────
build:
cargo build $(CARGO_FLAGS)
build-release:
$(MAKE) build PROFILE=release
build-cli:
cargo build -p arcbox-cli $(CARGO_FLAGS)
build-daemon:
cargo build -p arcbox-daemon $(CARGO_FLAGS)
build-helper:
cargo build -p arcbox-helper $(CARGO_FLAGS)
build-agent:
cargo build -p arcbox-agent --target $(AGENT_TARGET) --release
cargo build -p arcbox-vm-agent --bin vm-agent --target $(AGENT_TARGET) --release
build-fleet-agent:
cargo build -p arcbox-fleet-agent $(CARGO_FLAGS)
# Refresh the vendored Fleet proto from the published BSR module.
fleet-proto-sync:
buf export buf.build/arcboxlabs/fleet -o fleet/arcbox-fleet-proto/proto
# arcbox-connect generates from a committed descriptor set, because its .proto
# sources live in arcbox-protocol and cargo cannot package another package's
# directory. Run this after editing any proto it compiles — its build script
# fails until you do. This is the only step that needs protoc; building the
# crate does not.
refresh-connect-descriptor:
rpc/arcbox-connect/descriptor/refresh.sh
## ── Quality ────────────────────────────────────────────
check:
cargo clippy --workspace --all-targets -- -D warnings
cargo fmt --check
fmt:
cargo fmt
test:
cargo test --workspace
## ── Code Signing ─────────────────────────────────────
sign-daemon: build-daemon
@if [ -z "$(SIGN_IDENTITY)" ]; then \
echo "ERROR: No Developer ID signing identity found." >&2; \
echo " Install the ArcBox Developer ID certificate or set SIGN_IDENTITY:" >&2; \
echo " make sign-daemon SIGN_IDENTITY=\"Developer ID Application: ...\"" >&2; \
exit 1; \
fi
codesign --force --options runtime \
--identifier com.arcboxlabs.desktop.daemon \
--entitlements $(ENTITLEMENTS) \
--sign "$(SIGN_IDENTITY)" \
$(TARGET_DIR)/arcbox-daemon
@codesign -v --deep --strict $(TARGET_DIR)/arcbox-daemon && echo "✓ arcbox-daemon signed"
sign-all: build
@if [ -z "$(SIGN_IDENTITY)" ]; then \
echo "ERROR: No Developer ID signing identity found." >&2; \
exit 1; \
fi
codesign --force --options runtime \
--identifier com.arcboxlabs.desktop.daemon \
--entitlements $(ENTITLEMENTS) \
--sign "$(SIGN_IDENTITY)" \
$(TARGET_DIR)/arcbox-daemon
codesign --force --options runtime \
--identifier com.arcboxlabs.desktop.helper \
--sign "$(SIGN_IDENTITY)" \
$(TARGET_DIR)/arcbox-helper
codesign --force --options runtime \
--identifier com.arcboxlabs.desktop.cli \
--sign "$(SIGN_IDENTITY)" \
$(TARGET_DIR)/abctl
@for bin in $(BINARIES); do \
codesign -v --deep --strict $(TARGET_DIR)/$$bin && echo "✓ $$bin signed"; \
done
# Legacy ad-hoc sign (kept for CI smoke tests where no Developer ID exists).
sign:
codesign --force --options runtime \
--entitlements $(ENTITLEMENTS) \
-s - $(TARGET_DIR)/arcbox-daemon
verify:
@for bin in $(BINARIES); do \
if [ -f $(TARGET_DIR)/$$bin ]; then \
echo "--- $$bin ---"; \
codesign -d -v --entitlements :- $(TARGET_DIR)/$$bin 2>&1 | head -5; \
echo; \
fi; \
done
## ── Dev Workflow ───────────────────────────────────────
setup-boot-assets:
cargo xtask dev boot-assets
run-daemon:
cargo xtask macos dev --sign false
# Run the helper in manual mode (no launchd). Uses /tmp socket by default
# so the daemon can connect without launchd registration.
# Usage:
# make run-helper # default socket /tmp/arcbox-helper.sock
# make run-helper HELPER_SOCKET=/var/run/arcbox-helper.sock
HELPER_SOCKET ?= /tmp/arcbox-helper.sock
run-helper: build-helper
sudo ARCBOX_HELPER_SOCKET=$(HELPER_SOCKET) $(TARGET_DIR)/arcbox-helper
# Install the authenticated release helper into the world-connectable launchd
# socket. Debug helpers skip peer authentication and must only use run-helper's
# user-controlled development socket.
install-helper:
$(MAKE) build-helper PROFILE=release
sudo install -o root -g wheel -m 755 target/release/arcbox-helper /usr/local/libexec/arcbox-helper
sudo cp bundle/com.arcboxlabs.desktop.helper.plist /Library/LaunchDaemons/
-sudo launchctl bootout system/com.arcboxlabs.desktop.helper 2>/dev/null
sudo launchctl bootstrap system /Library/LaunchDaemons/com.arcboxlabs.desktop.helper.plist
@echo "✓ arcbox-helper installed and registered with launchd"
# Rebuild and hot-reload the authenticated release helper.
reload-helper:
$(MAKE) build-helper PROFILE=release
-sudo launchctl bootout system/com.arcboxlabs.desktop.helper 2>/dev/null
sudo cp target/release/arcbox-helper /usr/local/libexec/arcbox-helper
sudo launchctl bootstrap system /Library/LaunchDaemons/com.arcboxlabs.desktop.helper.plist
@echo "✓ arcbox-helper reloaded"
# Full helper regression suite (no root): unit + mock tarpc + real-binary E2E.
# E2E uses ARCBOX_HELPER_TEST_ROOT sandbox (debug builds only).
test-helper:
cargo test -p arcbox-constants --features std --lib helper::
cargo test -p arcbox-constants --features std --lib is_arcbox_owned
cargo test -p arcbox-helper --lib
cargo test -p arcbox-helper --bins
cargo test -p arcbox-helper --tests
cargo clippy -p arcbox-helper -- -D warnings
## ── Cleanup ───────────────────────────────────────────
clean:
cargo clean