-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (83 loc) · 3.41 KB
/
Copy pathMakefile
File metadata and controls
103 lines (83 loc) · 3.41 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
SHELL := /bin/sh
CARGO ?= cargo
NPM ?= npm
TARGET_DIR ?= $(if $(CARGO_TARGET_DIR),$(CARGO_TARGET_DIR),target)
DIST_DIR ?= dist/local
RELEASE_DIST_DIR ?= dist/release
RELEASE_ARCH ?= $(shell uname -m)
INSTALL_BIN_DIR ?= $(HOME)/.local/bin
INSTALL_APP_DIR ?= /Applications
DESKTOP_DIR := crates/desktop
CLI_BIN := $(TARGET_DIR)/release/chatnotes
CLI_ASSET := $(DIST_DIR)/bin/chatnotes
APP_BUNDLE := $(TARGET_DIR)/release/bundle/macos/ChatNotes.app
APP_ASSET := $(DIST_DIR)/ChatNotes.app
CLI_RELEASE_ASSET := $(RELEASE_DIST_DIR)/chatnotes-macos-$(RELEASE_ARCH).tar.gz
APP_RELEASE_ASSET := $(RELEASE_DIST_DIR)/ChatNotes-macos-$(RELEASE_ARCH).zip
INSTALLED_CLI := $(INSTALL_BIN_DIR)/chatnotes
INSTALLED_APP := $(INSTALL_APP_DIR)/ChatNotes.app
DESKTOP_NODE_MODULES := $(DESKTOP_DIR)/node_modules/.package-lock.json
TAURI_BUILD_CONFIG := {"bundle":{"active":true}}
.PHONY: help run run-tui run-desktop run-ios assets cli-asset desktop-asset release-assets desktop-deps install clean-assets fmt check test
help:
@printf '%s\n' \
'Targets:' \
' make run Run the TUI (default)' \
' make run-tui Run the terminal UI' \
' make run-desktop Run the desktop app in dev mode' \
' make run-ios Run the iOS app in dev mode' \
' make assets Build local distribution-like CLI and desktop assets' \
' make cli-asset Build dist/local/bin/chatnotes' \
' make desktop-asset Build dist/local/ChatNotes.app without signing' \
' make release-assets Build unsigned GitHub Release archives in dist/release' \
' make install Install CLI to ~/.local/bin and app to /Applications' \
' make clean-assets Remove dist/local' \
' make fmt Run cargo fmt --all' \
' make check Run cargo check --workspace' \
' make test Run cargo test --workspace'
run: run-tui
run-tui:
$(CARGO) run -p tui
run-desktop: $(DESKTOP_NODE_MODULES)
cd "$(DESKTOP_DIR)" && $(NPM) run tauri -- dev
run-ios: $(DESKTOP_NODE_MODULES)
cd "$(DESKTOP_DIR)" && $(NPM) run tauri -- ios dev
assets: cli-asset desktop-asset
cli-asset:
$(CARGO) build -p tui --bin chatnotes --release
mkdir -p "$(DIST_DIR)/bin"
cp "$(CLI_BIN)" "$(CLI_ASSET)"
chmod 755 "$(CLI_ASSET)"
@printf 'CLI asset: %s\n' "$(CLI_ASSET)"
desktop-asset: $(DESKTOP_NODE_MODULES)
cd "$(DESKTOP_DIR)" && $(NPM) run tauri -- build --bundles app --no-sign --ci --config '$(TAURI_BUILD_CONFIG)'
rm -rf "$(APP_ASSET)"
mkdir -p "$(DIST_DIR)"
cp -R "$(APP_BUNDLE)" "$(APP_ASSET)"
@printf 'Desktop asset: %s\n' "$(APP_ASSET)"
release-assets: assets
rm -rf "$(RELEASE_DIST_DIR)"
mkdir -p "$(RELEASE_DIST_DIR)"
tar -C "$(DIST_DIR)/bin" -czf "$(CLI_RELEASE_ASSET)" chatnotes
ditto -c -k --keepParent "$(APP_ASSET)" "$(APP_RELEASE_ASSET)"
@printf 'CLI release asset: %s\n' "$(CLI_RELEASE_ASSET)"
@printf 'Desktop release asset: %s\n' "$(APP_RELEASE_ASSET)"
desktop-deps: $(DESKTOP_NODE_MODULES)
$(DESKTOP_NODE_MODULES): $(DESKTOP_DIR)/package.json $(DESKTOP_DIR)/package-lock.json
cd "$(DESKTOP_DIR)" && $(NPM) ci
install: assets
mkdir -p "$(INSTALL_BIN_DIR)"
install -m 755 "$(CLI_ASSET)" "$(INSTALLED_CLI)"
rm -rf "$(INSTALLED_APP)"
cp -R "$(APP_ASSET)" "$(INSTALLED_APP)"
@printf 'Installed CLI: %s\n' "$(INSTALLED_CLI)"
@printf 'Installed desktop app: %s\n' "$(INSTALLED_APP)"
clean-assets:
rm -rf "$(DIST_DIR)"
rm -rf "$(RELEASE_DIST_DIR)"
fmt:
$(CARGO) fmt --all
check:
$(CARGO) check --workspace
test:
$(CARGO) test --workspace