-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
437 lines (390 loc) · 19 KB
/
Makefile
File metadata and controls
437 lines (390 loc) · 19 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# Makefile for ZimaOS-Blue
# Supports building single binary with embedded frontend
.PHONY: all build build-frontend build-frontend-embedded build-web-module build-backend dev clean help
.PHONY: workspace-templates-bundle embedded-asset-bundles
.PHONY: build-linux build-linux-bare build-darwin build-windows build-all
.PHONY: tauri-dev tauri-build tauri-build-debug tauri-clean tauri-sidecar tauri-verify-macos-package
.PHONY: build-blue-lib-macos build-blue-lib-arm64 build-blue-lib-x64 build-blue-lib-universal
.PHONY: provider-catalog provider-catalog-check stage-windows-codex-assets build-zimaos-raw
# Version info
VERSION ?= 0.10.39
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Directories
PROJECT_ROOT := $(shell pwd)
WEB_DIR := $(PROJECT_ROOT)/web
SERVER_DIR := $(PROJECT_ROOT)/server
EMBED_DIR := $(SERVER_DIR)/internal/web/dist
DIST_DIR := $(PROJECT_ROOT)/dist
TAURI_DIR := $(PROJECT_ROOT)/tauri-app
TAURI_LIB_DIR := $(TAURI_DIR)/src-tauri/lib
WEB_MODULE_OUT_DIR ?= dist-module
WEB_MODULE_DIST_DIR := $(WEB_DIR)/$(WEB_MODULE_OUT_DIR)
SKILLS_SRC := $(PROJECT_ROOT)/assets/skills
SKILLS_EMBED := $(SERVER_DIR)/internal/skill/embedded/skills
EMBEDDED_DISABLE_MERMAID ?= 1
WINDOWS_CODEX_ASSET_DIR ?= $(DIST_DIR)/windows-codex
ZIMAOS_RAW_MODULE ?= zimaos-blue
ZIMAOS_RAW_COMMAND ?= blue
ZIMAOS_RAW_BINARY ?= $(DIST_DIR)/zimaos-blue-linux-amd64
ZIMAOS_RAW_OUTPUT ?= $(DIST_DIR)/$(ZIMAOS_RAW_MODULE).raw
# Go build flags
GO_BUILD_FLAGS ?= -trimpath -buildvcs=false
LDFLAGS := -s -w
LDFLAGS += -X main.version=$(VERSION)
LDFLAGS += -X main.buildTime=$(BUILD_TIME)
LDFLAGS += -X main.gitCommit=$(GIT_COMMIT)
# Default target
all: build
# Build everything (frontend + backend)
build: build-frontend copy-frontend copy-skills build-backend
@echo "Build complete! Binary at $(DIST_DIR)/zimaos-blue"
# Build frontend only
build-frontend:
@echo "Building frontend..."
@cd $(WEB_DIR) && npm install && npm run build
# Build the embedded frontend bundle for the macOS launcher/CLI path
build-frontend-embedded:
@echo "Building embedded frontend (all locales, Mermaid fallback: $(EMBEDDED_DISABLE_MERMAID))..."
@cd $(WEB_DIR) && npm install && VITE_EMBED_DISABLE_MERMAID="$(EMBEDDED_DISABLE_MERMAID)" npm run build
# Build the CasaOS/ZimaOS module frontend bundle used inside the raw image
build-web-module:
@echo "Building module frontend for $(ZIMAOS_RAW_MODULE)..."
@cd $(WEB_DIR) && npm install && VITE_MODULE_UI=1 VITE_MODULE_NAME="$(ZIMAOS_RAW_MODULE)" VITE_OUT_DIR="$(WEB_MODULE_OUT_DIR)" npm run build
# Copy frontend to embed directory (exclude source maps)
copy-frontend:
@echo "Copying frontend to embed directory..."
@rm -rf $(EMBED_DIR)
@mkdir -p $(EMBED_DIR)
@cd $(WEB_DIR)/dist && find . -type f ! -name '*.map' ! -name '.DS_Store' -exec cp --parents {} $(EMBED_DIR)/ \; 2>/dev/null || \
cd $(WEB_DIR)/dist && rsync -av --exclude='*.map' --exclude='.DS_Store' . $(EMBED_DIR)/ 2>/dev/null || \
(cd $(WEB_DIR)/dist && for f in $$(find . -type f ! -name '*.map' ! -name '.DS_Store'); do mkdir -p $(EMBED_DIR)/$$(dirname $$f) && cp $$f $(EMBED_DIR)/$$f; done)
# Copy canonical skills from assets/skills/ to server/internal/skill/embedded/skills/ for go:embed
copy-skills:
@echo "Copying skills to server/internal/skill/embedded/skills..."
@rm -rf $(SKILLS_EMBED)
@mkdir -p $(SKILLS_EMBED)
@cp -r $(SKILLS_SRC)/* $(SKILLS_EMBED)/
# Regenerate the compressed workspace templates bundle used by go:embed.
workspace-templates-bundle:
@echo "Generating workspace templates bundle..."
@cd $(SERVER_DIR) && go run ./tools/generate_embed_bundle -source internal/workspace/templates -output internal/workspace/templates_bundle.tar.gz -prefix templates
# Regenerate compressed embedded asset bundles that live fully inside server/.
embedded-asset-bundles: workspace-templates-bundle
# Regenerate the canonical provider catalog JSON and sync the embedded fallback copy.
provider-catalog:
@echo "Generating provider catalog..."
@cd $(SERVER_DIR) && go run ./tools/generate_provider_catalog
# Verify the checked-in provider catalog files match generated output.
provider-catalog-check:
@echo "Checking provider catalog..."
@cd $(SERVER_DIR) && go run ./tools/generate_provider_catalog --check
# Build backend only (assumes frontend is already built and copied)
build-backend:
@echo "Building backend..."
@mkdir -p $(DIST_DIR)
@$(MAKE) embedded-asset-bundles
@cd $(SERVER_DIR) && CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue ./cmd/blue
@echo "Binary size: $$(du -h $(DIST_DIR)/zimaos-blue | cut -f1)"
# Development mode (run frontend and backend separately)
dev:
@echo "Starting development servers..."
@echo "Run 'cd web && npm run dev' in one terminal"
@echo "Run 'cd server && go run -tags dev ./cmd/blue' in another terminal"
# Cross-compilation targets
build-linux: build-frontend copy-frontend copy-skills
@echo "Building for Linux (amd64)..."
@mkdir -p $(DIST_DIR)
@$(MAKE) embedded-asset-bundles
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-linux-amd64 ./cmd/blue
build-linux-bare: copy-skills
@echo "Building bare Linux binary for ZimaOS raw (amd64)..."
@mkdir -p $(DIST_DIR)
@$(MAKE) embedded-asset-bundles
@cd $(SERVER_DIR) && \
if [ "$(shell uname -s)" = "Linux" ]; then \
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build $(GO_BUILD_FLAGS) -tags 'fts5' -ldflags "$(LDFLAGS)" -o $(ZIMAOS_RAW_BINARY) ./cmd/blue; \
elif command -v zig >/dev/null 2>&1; then \
CC="zig cc -target x86_64-linux-gnu" CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build $(GO_BUILD_FLAGS) -tags 'fts5' -ldflags "$(LDFLAGS)" -o $(ZIMAOS_RAW_BINARY) ./cmd/blue; \
else \
echo "zig is required to cross-compile linux/amd64 with CGO from $(shell uname -s)" >&2; \
exit 1; \
fi
build-linux-arm64: build-frontend copy-frontend copy-skills
@echo "Building for Linux (arm64)..."
@mkdir -p $(DIST_DIR)
@$(MAKE) embedded-asset-bundles
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-linux-arm64 ./cmd/blue
build-darwin: build-frontend copy-frontend copy-skills
@echo "Building for macOS (amd64)..."
@mkdir -p $(DIST_DIR)
@$(MAKE) embedded-asset-bundles
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-darwin-amd64 ./cmd/blue
build-darwin-arm64: build-frontend copy-frontend copy-skills
@echo "Building for macOS (arm64)..."
@mkdir -p $(DIST_DIR)
@$(MAKE) embedded-asset-bundles
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-darwin-arm64 ./cmd/blue
build-windows: build-frontend copy-frontend copy-skills
@echo "Building for Windows (amd64)..."
@mkdir -p $(DIST_DIR)
@$(MAKE) embedded-asset-bundles
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-windows-amd64.exe ./cmd/blue
# Build for all platforms
build-all: build-frontend copy-frontend copy-skills
@echo "Building for all platforms..."
@mkdir -p $(DIST_DIR)
@$(MAKE) embedded-asset-bundles
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-linux-amd64 ./cmd/blue
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-linux-arm64 ./cmd/blue
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-darwin-amd64 ./cmd/blue
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-darwin-arm64 ./cmd/blue
@cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/zimaos-blue-windows-amd64.exe ./cmd/blue
@echo "All builds complete!"
@ls -lh $(DIST_DIR)/
build-zimaos-raw: build-web-module build-linux-bare
@echo "Building ZimaOS squashfs raw module..."
@bash $(PROJECT_ROOT)/scripts/build_zimaos_raw.sh \
--binary $(ZIMAOS_RAW_BINARY) \
--output $(ZIMAOS_RAW_OUTPUT) \
--dist-dir $(WEB_MODULE_DIST_DIR) \
--module-name $(ZIMAOS_RAW_MODULE) \
--command-name $(ZIMAOS_RAW_COMMAND) \
--version $(VERSION)
@ls -lh $(ZIMAOS_RAW_OUTPUT)
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(DIST_DIR)
@rm -rf $(EMBED_DIR)
@rm -rf $(WEB_MODULE_DIST_DIR)
@rm -rf $(SKILLS_EMBED)
@rm -rf $(WEB_DIR)/dist
@rm -rf $(WEB_DIR)/node_modules/.cache
@echo "Clean complete!"
# GoReleaser targets
.PHONY: release release-snapshot release-check
# Check GoReleaser configuration
release-check:
@echo "Checking GoReleaser configuration..."
@goreleaser check
# Build snapshot release (for testing, no publish)
release-snapshot: build-frontend copy-frontend copy-skills
@echo "Building snapshot release..."
@goreleaser release --snapshot --clean
# Build and publish release (requires GITHUB_TOKEN)
release: build-frontend copy-frontend copy-skills
@echo "Building and publishing release..."
@goreleaser release --clean
# Stage Windows Codex sandbox assets for local testing/manual staging.
stage-windows-codex-assets:
@echo "Staging Windows Codex sandbox assets..."
@mkdir -p $(WINDOWS_CODEX_ASSET_DIR)
@python3 $(PROJECT_ROOT)/scripts/windows_codex_release_assets.py --output-dir $(WINDOWS_CODEX_ASSET_DIR)
@ls -lh $(WINDOWS_CODEX_ASSET_DIR)
# Tauri Desktop App targets
TAURI_DIR := $(PROJECT_ROOT)/tauri-app
TAURI_BIN_DIR := $(TAURI_DIR)/src-tauri/bin
# Build Go sidecar for Tauri (current platform)
tauri-sidecar: build-frontend copy-frontend copy-skills
@echo "Building Go sidecar for Tauri..."
@mkdir -p $(TAURI_BIN_DIR)
@$(MAKE) embedded-asset-bundles
ifeq ($(shell uname -s),Darwin)
ifeq ($(shell uname -m),arm64)
@cd $(SERVER_DIR) && CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(TAURI_BIN_DIR)/blue-server-aarch64-apple-darwin ./cmd/blue
else
@cd $(SERVER_DIR) && CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(TAURI_BIN_DIR)/blue-server-x86_64-apple-darwin ./cmd/blue
endif
else ifeq ($(shell uname -s),Linux)
@cd $(SERVER_DIR) && CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(TAURI_BIN_DIR)/blue-server-x86_64-unknown-linux-gnu ./cmd/blue
else
@cd $(SERVER_DIR) && CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(TAURI_BIN_DIR)/blue-server-x86_64-pc-windows-msvc.exe ./cmd/blue
endif
@echo "Sidecar built successfully"
# Run Tauri in development mode
tauri-dev: tauri-sidecar
@echo "Starting Tauri development mode..."
@cd $(TAURI_DIR) && npm install && npm run dev
# Build Tauri app for production
tauri-build: tauri-sidecar
@echo "Building Tauri app..."
ifeq ($(shell uname -s),Darwin)
@echo "Note: make tauri-build runs plain Tauri bundling and does not notarize the macOS package."
@echo "Use make tauri-package for a signed/notarized DMG."
endif
@rm -rf $(TAURI_DIR)/src-tauri/data
@mkdir -p $(TAURI_DIR)/src-tauri/data
@cd $(TAURI_DIR) && npm install && npm run build
ifeq ($(shell uname -s),Darwin)
@echo "Setting DMG file icon..."
@DMG_FILE=$$(find $(TAURI_DIR)/src-tauri/target/release/bundle/dmg -name "*.dmg" -type f 2>/dev/null | head -1); \
if [ -n "$$DMG_FILE" ] && command -v fileicon >/dev/null 2>&1; then \
fileicon set "$$DMG_FILE" "$(TAURI_DIR)/src-tauri/icons/icon.icns"; \
echo "DMG file icon set successfully"; \
elif [ -n "$$DMG_FILE" ]; then \
echo "Warning: fileicon not found. Install with: brew install fileicon"; \
fi
endif
# Build Tauri app in debug mode
tauri-build-debug: tauri-sidecar
@echo "Building Tauri app (debug)..."
@cd $(TAURI_DIR) && npm install && npm run build:debug
# Clean Tauri build artifacts
tauri-clean:
@echo "Cleaning Tauri build artifacts..."
@rm -rf $(TAURI_DIR)/src-tauri/target
@rm -rf $(TAURI_BIN_DIR)/blue-server-*
@rm -rf $(TAURI_DIR)/src-tauri/data
@echo "Tauri clean complete!"
# Verify macOS Tauri package signatures and notarization
tauri-verify-macos-package:
ifeq ($(shell uname -s),Darwin)
@echo "Verifying macOS Tauri package..."
@bash $(TAURI_DIR)/verify-macos-package.sh
else
@echo "tauri-verify-macos-package is only supported on macOS"
@exit 1
endif
# Build Tauri app using the full build script (recommended)
tauri-package: build-frontend copy-frontend copy-skills
@echo "Building Tauri package..."
ifeq ($(shell uname -s),Darwin)
@echo "macOS package builds require Apple signing/notarization credentials by default."
@echo "Set MACOS_REQUIRE_NOTARIZATION=0 only if you intentionally want a local non-notarized package."
endif
@chmod +x $(TAURI_DIR)/build.sh
@$(TAURI_DIR)/build.sh
# Show help
help:
@echo "ZimaOS-Blue Build System"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Go Binary Targets:"
@echo " build Build binary"
@echo " build-frontend Build frontend only"
@echo " build-frontend-embedded Build embedded frontend with all locales and Mermaid fallback"
@echo " build-backend Build backend only (requires frontend to be built)"
@echo " dev Show development mode instructions"
@echo " build-linux Build for Linux (amd64)"
@echo " build-linux-arm64 Build for Linux (arm64)"
@echo " build-darwin Build for macOS (amd64)"
@echo " build-darwin-arm64 Build for macOS (arm64)"
@echo " build-windows Build for Windows (amd64)"
@echo " build-all Build for all platforms"
@echo " build-zimaos-raw Build a ZimaOS/CasaOS squashfs raw module from a bare Linux amd64 binary + module UI"
@echo " build-web-module Build the CasaOS/ZimaOS module frontend dist"
@echo " clean Remove build artifacts"
@echo " provider-catalog Regenerate docs and embedded provider catalog JSON"
@echo " provider-catalog-check Verify provider catalog files match generated output"
@echo ""
@echo "Tauri Desktop App Targets:"
@echo " tauri-sidecar Build Go sidecar for Tauri"
@echo " tauri-dev Run Tauri in development mode"
@echo " tauri-build Build Tauri app for production (non-notarized on macOS)"
@echo " tauri-package Build Tauri package with full signing/notarization flow"
@echo " tauri-build-debug Build Tauri app in debug mode"
@echo " tauri-verify-macos-package Verify macOS package signatures/notarization"
@echo " tauri-clean Clean Tauri build artifacts"
@echo ""
@echo "macOS CGO Library Targets:"
@echo " build-blue-lib-arm64 Build Go static library for macOS ARM64"
@echo " build-blue-lib-x64 Build Go static library for macOS x64"
@echo " build-blue-lib-universal Create universal binary (fat library)"
@echo " build-blue-lib-macos Build all macOS libraries (recommended)"
@echo ""
@echo "Release Targets:"
@echo " release-check Check GoReleaser configuration"
@echo " release-snapshot Build snapshot release (for testing)"
@echo " release Build and publish release (requires GITHUB_TOKEN)"
@echo " stage-windows-codex-assets Stage Windows Codex sandbox runtime assets for local testing"
@echo " help Show this help message"
@echo ""
@echo "Environment variables:"
@echo " VERSION Set version string (default: $(VERSION))"
@echo " MACOS_REQUIRE_NOTARIZATION Require Apple signing/notarization creds in tauri-package (default: 1)"
@echo ""
@echo "Examples:"
@echo " make build # Build the app"
@echo " make tauri-dev # Run Tauri desktop app in dev mode"
@echo " make tauri-build # Build Tauri desktop app"
@echo " make tauri-package # Build signed/notarized macOS package when creds are present"
@echo " make tauri-verify-macos-package # Verify built macOS package signatures and notarization"
@echo " make build-blue-lib-macos # Build Go library for macOS CGO integration"
@echo " make build-zimaos-raw # Build dist/zimaos-blue.raw"
# =============================================================================
# macOS CGO Library Build Targets
# =============================================================================
# These targets build the Go server as a static library for linking into Rust
# This approach is used on macOS for faster startup (no process spawn overhead)
# =============================================================================
# Build Go static library for macOS ARM64 (Apple Silicon)
build-blue-lib-arm64:
@echo "Building Go static library for macOS ARM64..."
@mkdir -p $(TAURI_LIB_DIR)
@cd $(SERVER_DIR) && CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 \
go build $(GO_BUILD_FLAGS) -buildmode=c-archive \
-tags 'fts5' \
-ldflags "$(LDFLAGS)" \
-o $(TAURI_LIB_DIR)/libblue_arm64.a \
./cmd/bluelib
@echo "Built: $(TAURI_LIB_DIR)/libblue_arm64.a"
@ls -lh $(TAURI_LIB_DIR)/libblue_arm64.a
# Build Go static library for macOS x64 (Intel)
build-blue-lib-x64:
@echo "Building Go static library for macOS x64..."
@mkdir -p $(TAURI_LIB_DIR)
@cd $(SERVER_DIR) && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 \
go build $(GO_BUILD_FLAGS) -buildmode=c-archive \
-tags 'fts5' \
-ldflags "$(LDFLAGS)" \
-o $(TAURI_LIB_DIR)/libblue_x64.a \
./cmd/bluelib
@echo "Built: $(TAURI_LIB_DIR)/libblue_x64.a"
@ls -lh $(TAURI_LIB_DIR)/libblue_x64.a
# Create universal binary (fat library) from ARM64 and x64
build-blue-lib-universal: build-blue-lib-arm64 build-blue-lib-x64
@echo "Creating universal binary (fat library)..."
@lipo -create \
$(TAURI_LIB_DIR)/libblue_arm64.a \
$(TAURI_LIB_DIR)/libblue_x64.a \
-output $(TAURI_LIB_DIR)/libblue.a
@echo "Built: $(TAURI_LIB_DIR)/libblue.a"
@ls -lh $(TAURI_LIB_DIR)/libblue.a
@echo "Verifying architectures:"
@lipo -info $(TAURI_LIB_DIR)/libblue.a
# Build all macOS libraries (recommended target)
# Builds for current architecture only for faster builds
build-blue-lib-macos:
@echo "Building Go static library for macOS..."
@mkdir -p $(TAURI_LIB_DIR)
ifeq ($(shell uname -m),arm64)
@echo "Detected Apple Silicon, building ARM64 library..."
@cd $(SERVER_DIR) && CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 \
go build $(GO_BUILD_FLAGS) -buildmode=c-archive \
-tags 'fts5' \
-ldflags "$(LDFLAGS)" \
-o $(TAURI_LIB_DIR)/libblue.a \
./cmd/bluelib
else
@echo "Detected Intel, building x64 library..."
@cd $(SERVER_DIR) && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 \
go build $(GO_BUILD_FLAGS) -buildmode=c-archive \
-tags 'fts5' \
-ldflags "$(LDFLAGS)" \
-o $(TAURI_LIB_DIR)/libblue.a \
./cmd/bluelib
endif
@echo "Built: $(TAURI_LIB_DIR)/libblue.a"
@ls -lh $(TAURI_LIB_DIR)/libblue.a
# Build Tauri app for macOS with CGO library (no sidecar)
tauri-build-macos-cgo: build-frontend copy-frontend copy-skills build-blue-lib-macos
@echo "Building Tauri app for macOS with CGO library..."
@cd $(TAURI_DIR) && npm install && npm run build
@echo "macOS app built with embedded Go library"
# Clean CGO library artifacts
clean-blue-lib:
@echo "Cleaning CGO library artifacts..."
@rm -rf $(TAURI_LIB_DIR)
@echo "Clean complete!"