-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathGNUmakefile
More file actions
243 lines (196 loc) · 7.99 KB
/
GNUmakefile
File metadata and controls
243 lines (196 loc) · 7.99 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
# Wrapper around the qmake-generated Makefile that adds a docs target.
# GNU make prefers GNUmakefile over Makefile, so this is picked up
# automatically while the qmake Makefile is left untouched.
export ANDROID_HOME ?= $(HOME)/android-sdk
export PATH := $(HOME)/flutter/bin:$(PATH)
SPHINXBUILD ?= sphinx-build
SPHINXOPTS ?= -q
DOCDIR = doc
BUILDDIR = $(DOCDIR)/_build
.DEFAULT_GOAL := all
all: paperman paperman-server app docs
paperman:
$(MAKE) -f Makefile $@
dark-icons:
python3 scripts/invert_xpm.py
.PHONY: dark-icons paperman
# Targets handled here
.PHONY: builddate.h
builddate.h:
@echo '#define SERVER_BUILD_DATE "$(BUILD_DATE)"' > $@
paperman-server: Makefile.server builddate.h
$(MAKE) -f Makefile.server
Makefile.server: paperman-server.pro
qmake paperman-server.pro -o Makefile.server
test-setup: paperman
python3 scripts/make_test_files.py
app-test:
cd app && flutter test
test: paperman-server paperman test-setup app-test
scripts/test_page_fetch.sh
scripts/test_parallel.sh
test-progressive: paperman-server
scripts/test_progressive.sh
test-parallel: paperman
scripts/test_parallel.sh
docs:
$(SPHINXBUILD) -b html $(SPHINXOPTS) $(DOCDIR) $(BUILDDIR)/html
BUILD_DATE := $(shell date "+%a %d %b %H:%M:%S %Z %Y")
APP_VERSION := $(shell sed -n 's/.*CONFIG_version_str "\(.*\)"/\1.0/p' config.h)
DART_DEFINES = app/dart-defines.json
FLUTTER_ARGS = --build-name=$(APP_VERSION) --dart-define-from-file=dart-defines.json
app: app-apk app-linux
rm -f $(DART_DEFINES)
GH_REMOTE ?= gh
rparen := )
DEB_VERSION := $(shell head -1 debian/changelog.in | sed -n 's/.*(\([^$(rparen)]*\)).*/\1/p' | sed 's/VENDOR_VERSION//')
DEB_UPSTREAM := $(firstword $(subst -, ,$(DEB_VERSION)))
RELEASE_TAG = v$(DEB_UPSTREAM)
RELEASE_DEBS = $(wildcard ../release/all/paperman_$(DEB_VERSION)_*.deb)
.PHONY: release release-upload
release:
@TAG=$(RELEASE_TAG); \
if git rev-parse "$$TAG" >/dev/null 2>&1; then \
echo "Tag $$TAG already exists"; exit 1; \
fi; \
if [ -z "$(RELEASE_DEBS)" ]; then \
echo "No .deb files found — run scripts/do-build first"; exit 1; \
fi; \
echo "Creating tag $$TAG and pushing to $(GH_REMOTE)..."; \
git tag "$$TAG" || exit 1; \
git push $(GH_REMOTE) "$$TAG" || { echo "Push failed"; exit 1; }; \
echo "Waiting for GitHub Release to be created..."; \
found=0; \
for i in 1 2 3 4 5 6 7 8 9 10; do \
sleep 10; \
if gh release view "$$TAG" >/dev/null 2>&1; then found=1; break; fi; \
echo " (waiting...)"; \
done; \
if [ "$$found" -eq 0 ]; then \
echo "Timed out waiting for release — run 'make release-upload' later"; \
exit 1; \
fi; \
$(MAKE) -f GNUmakefile release-upload
release-upload:
@TAG=$(RELEASE_TAG); \
if ! gh release view "$$TAG" >/dev/null 2>&1; then \
echo "GitHub Release $$TAG does not exist"; exit 1; \
fi; \
if [ -z "$(RELEASE_DEBS)" ]; then \
echo "No .deb files found — run scripts/do-build first"; exit 1; \
fi; \
echo "Uploading .deb packages to $$TAG..."; \
gh release upload "$$TAG" $(RELEASE_DEBS); \
echo "Done: https://github.com/sjg20/paperman/releases/tag/$$TAG"
.PHONY: setup
setup:
scripts/setup.sh
.PHONY: app app-demo app-test dart-defines app-apk app-aab app-publish
.PHONY: app-upload app-scp app-scp-only app-scp-watch app-ios app-ios-install app-ipa app-ipa-upload app-linux app-clean
dart-defines:
@echo '{"BUILD_DATE":"$(BUILD_DATE)"}' > $(DART_DEFINES)
app-demo:
python3 app/tools/gen_demo_assets.py
app-apk: app-demo dart-defines
cd app && flutter build apk $(FLUTTER_ARGS)
app-aab: app-demo dart-defines
cd app && flutter build appbundle $(FLUTTER_ARGS)
app-publish: app-aab
cd app/android && ./gradlew publishReleaseBundle
app-upload: app-apk
rclone copy $(APP_APK) gdrive:apps/
server.mk: ;
-include server.mk
app-scp: app-apk app-scp-only
app-scp-only:
@test -n "$(APP_SERVER)" || { echo "Set APP_SERVER in server.mk (e.g. APP_SERVER = user@host:/var/www/app.apk)"; exit 1; }
scp $(APP_APK) $(APP_SERVER)
app-scp-watch:
@test -n "$(APP_SERVER)" || { echo "Set APP_SERVER in server.mk (e.g. APP_SERVER = user@host:/var/www/app.apk)"; exit 1; }
@echo "Watching $(APP_APK) for changes..."
@while inotifywait -qq -e close_write $(APP_APK); do \
date; \
scp $(APP_APK) $(APP_SERVER); \
done
app-ios: dart-defines
cd app && flutter build ios $(FLUTTER_ARGS)
app-ios-install: app-ios
xcrun devicectl device install app --device $(IOS_DEVICE) $(APP_IOS)
app-ipa: dart-defines
cd app && flutter build ipa --build-name=$(IPA_VERSION) --build-number=$(IPA_BUILD) $(FLUTTER_ARGS)
app-ipa-upload: app-ipa
xcrun altool --upload-app --type ios -f $(APP_IPA) \
--apiKey $(ASC_KEY_ID) --apiIssuer $(ASC_ISSUER_ID)
# Set IOS_DEVICE to your iPad/iPhone device ID (from Xcode or
# `xcrun devicectl list devices`).
IOS_DEVICE ?= 00008122-0001786226E8401C
APP_IOS = app/build/ios/iphoneos/Runner.app
APP_IPA = app/build/ios/ipa/paperman.ipa
# App Store Connect API key for TestFlight uploads. Create at
# https://appstoreconnect.apple.com/access/integrations/api
# and place the .p8 file in ~/.appstoreconnect/private_keys/
ASC_KEY_ID ?= 9WUW42HYF2
ASC_ISSUER_ID ?= 88e66a40-c926-4812-82f4-1c80e7064078
IPA_VERSION ?= 1.3.1
IPA_BUILD ?= 1
app-linux: dart-defines
# Clear CMake cache so find_library() re-discovers libpdfium.so from
# the printing plugin's download rather than a stale bundle/lib/ path.
rm -f app/build/linux/x64/release/CMakeCache.txt
cd app && flutter build linux $(FLUTTER_ARGS)
APP_APK = app/build/app/outputs/flutter-apk/app-release.apk
APP_AAB = app/build/app/outputs/bundle/release/app-release.aab
APP_BIN = app/build/linux/x64/release/bundle/paperman
info:
@ls -l paperman paperman-server $(APP_APK) $(APP_AAB) $(APP_BIN) 2>/dev/null || echo "No binaries found (run 'make' first)"
help:
@echo "Build targets:"
@echo " all Build everything (default)"
@echo " paperman Build the Qt desktop app"
@echo " paperman-server Build the standalone server"
@echo " app Build the Flutter app (Android + Linux)"
@echo " app-apk Build the Flutter Android APK only"
@echo " app-aab Build the Flutter Android App Bundle only"
@echo " app-publish Build AAB and upload to Play Store internal testing"
@echo " app-upload Build APK and upload to Google Drive"
@echo " app-scp Build APK and scp to server (needs server.mk)"
@echo " app-scp-only Copy previously built APK to server"
@echo " app-scp-watch Watch APK and copy to server on change"
@echo " app-demo Generate demo assets (PDFs + thumbnails)"
@echo " app-linux Build the Flutter Linux binary only"
@echo " docs Build the Sphinx documentation"
@echo ""
@echo "Test targets:"
@echo " test Run all tests"
@echo " test-setup Generate test files in test/files/"
@echo " test-progressive Run progressive-loading tests"
@echo " test-parallel Run parallel tests"
@echo " app-test Run Flutter widget tests"
@echo ""
@echo "Release targets:"
@echo " release Tag, push and upload .debs to GitHub Release"
@echo " release-upload Upload .debs to an existing GitHub Release"
@echo ""
@echo "Other targets:"
@echo " setup Install build dependencies (apt)"
@echo " info List built binaries"
@echo " clean Clean all build outputs"
@echo " app-clean Clean Flutter build outputs"
@echo " docs-clean Clean Sphinx build outputs"
app-clean:
-cd app && flutter clean
-rm -rf app/build app/android/.gradle
rm -f $(DART_DEFINES)
clean: app-clean docs-clean
-test -f Makefile && $(MAKE) -f Makefile clean
-test -f Makefile.server && $(MAKE) -f Makefile.server clean
rm -f paperman paperman-server builddate.h Makefile.server *.o moc_*.cpp moc_predefs.h
distclean: app-clean docs-clean
rm -f paperman paperman-server builddate.h *.o moc_*.cpp moc_predefs.h
rm -f Makefile Makefile.qt6 Makefile.server server.mk .qmake.stash
rm -rf .obj .moc .ui
docs-clean:
rm -rf $(BUILDDIR)
# Forward everything else to the qmake-generated Makefile
%:
$(MAKE) -f Makefile $@