forked from agateau/pixelwheels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
263 lines (196 loc) · 7.14 KB
/
Makefile
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
# Shell to use, stop on errors, stop on undefined variables, report errors
# if a command in a pipe fails (not just the last)
SHELL := bash
.SHELLFLAGS := -euo pipefail -c
# Do not start a new shell for each command of a target
# Makes it possible to have `cd foo` on its own line. Be sure to configure the
# shell to stop on errors though (the -e in .SHELLFLAGS)
.ONESHELL:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
# Give the user the opportunity to customize environment variables
-include ./env.mk
DESKTOP_JAR=$(CURDIR)/desktop/build/libs/desktop-1.0.jar
TOOLS_JAR=$(CURDIR)/tools/build/libs/tools-1.0.jar
GRADLEW=./gradlew
ifdef OFFLINE
GRADLEW=./gradlew --offline
endif
GAME_CP=com.agateau.pixelwheels
EXECUTABLE=pixelwheels
include ./version.properties
DIST_OUT_BASE_DIR=dist-out
DIST_NAME=$(EXECUTABLE)-$(VERSION)
DIST_OUT_DIR=$(DIST_OUT_BASE_DIR)/$(DIST_NAME)
DESKTOP_RUN_DIST_NAME=$(EXECUTABLE)-$(VERSION)-linux64
ANDROID_ITCHIO_RUN_DIST_NAME=$(EXECUTABLE)-itchio-$(VERSION)
ANDROID_GPLAY_RUN_DIST_NAME=$(EXECUTABLE)-gplay-$(VERSION)
ARCHIVE_DIR=$(CURDIR)/archives
ANDROID_PACKAGE_NAME=com.agateau.tinywheels.android
CONF_BACKUP_DIR=$(CURDIR)/.conf-backup
# Install variables
## Standard directory variables
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
datadir = $(prefix)/share
libdir = $(exec_prefix)/lib
## Handy shortcuts
INSTALL_BIN_DIR=$(DESTDIR)$(bindir)
INSTALL_JAR_DIR=$(DESTDIR)$(libdir)/pixelwheels
INSTALL_SHARE_DIR=$(DESTDIR)$(datadir)
INSTALL_ASSETS_DIR=$(INSTALL_SHARE_DIR)/pixelwheels
INSTALL_BIN_PATH=$(INSTALL_BIN_DIR)/pixelwheels
INSTALL_JAR_PATH=$(INSTALL_JAR_DIR)/$(GAME_CP).jar
# Update VERSION variable for snapshots
ifdef SNAPSHOT
BRANCH:=$(shell git rev-parse --abbrev-ref HEAD | sed s,/,-,g)
VERSION:=$(VERSION)+$(BRANCH)-$(shell git show --no-patch --format="%cd-%h" --date=format:%Y%m%dT%H%M%S)
endif
all: build
clean: clean-assets clean-desktop clean-tools
clean-desktop:
rm -f $(DESKTOP_JAR)
clean-tools:
rm -f $(TOOLS_JAR)
$(TOOLS_JAR):
${GRADLEW} tools:dist
build:
${GRADLEW} desktop:dist
tools: $(TOOLS_JAR)
run: build
cd android/assets && java -jar $(DESKTOP_JAR)
# Classic Unix `make install` target
install:
mkdir -p $(INSTALL_JAR_DIR)
mkdir -p $(INSTALL_BIN_DIR)
mkdir -p $(INSTALL_ASSETS_DIR)
cp $(DESKTOP_JAR) $(INSTALL_JAR_PATH)
cp -a android/assets/* $(INSTALL_ASSETS_DIR)
echo -e "#!/bin/bash\ncd $(INSTALL_ASSETS_DIR)\nexec java -jar $(INSTALL_JAR_PATH)" > $(INSTALL_BIN_PATH)
chmod +x $(INSTALL_BIN_PATH)
cp -a tools/packaging/linux/share/* $(INSTALL_SHARE_DIR)
# Assets
packer: tools assets
java -cp $(TOOLS_JAR) $(GAME_CP).tools.Packer
mapscreenshotgenerator: tools
java -cp $(TOOLS_JAR) $(GAME_CP).tools.MapScreenshotGenerator
vehiclethumbnailgenerator: tools
java -cp $(TOOLS_JAR) $(GAME_CP).tools.VehicleThumbnailGenerator tmp
assets:
$(MAKE) -C core/assets-src
clean-assets:
$(MAKE) -C core/assets-src clean
# Automatically regenerates assets when ase files are modified (requires the
# `entr` command)
auto-assets:
find core/assets-src -name '*.ase' | entr $(MAKE) assets packer
# Dist
desktop-archives:
@rm -rf $(DIST_OUT_BASE_DIR)
@mkdir -p $(DIST_OUT_BASE_DIR)
@echo Creating desktop archives
@tools/packaging/create-archives $(VERSION)
@echo Moving desktop archives
@mkdir -p $(ARCHIVE_DIR)
mv -v $(DIST_OUT_BASE_DIR)/*.zip $(ARCHIVE_DIR)
apk-archives:
@echo Creating apk files
@$(GRADLEW) android:assembleRelease
@echo Moving apk files
@mkdir -p $(ARCHIVE_DIR)
@for store in itchio gplay ; do \
mv android/build/outputs/apk/$$store/release/android-$$store-release.apk $(ARCHIVE_DIR)/$(EXECUTABLE)-$$store-$(VERSION).apk ; \
done
aab-archives:
@echo Creating aab
@$(GRADLEW) bundleGPlayRelease
@echo Moving aab file
mv android/build/outputs/bundle/gplayRelease/android-gplay-release.aab $(ARCHIVE_DIR)/$(ANDROID_GPLAY_RUN_DIST_NAME).aab
dist: assets packer check build desktop-archives apk-archives aab-archives
desktop-dist: assets packer check build desktop-archives
clean-desktop-dist: clean desktop-dist
clean-dist: clean dist
desktop-run-from-dist:
@echo "This target only works on Linux right now"
rm -rf tmp
mkdir -p tmp
unzip $(ARCHIVE_DIR)/$(DESKTOP_RUN_DIST_NAME).zip -d tmp
tmp/$(DESKTOP_RUN_DIST_NAME)/pixelwheels
android-run-from-dist:
# uninstall any existing version in case we have an unsigned version installed
adb uninstall $(ANDROID_PACKAGE_NAME) || true
adb install -f $(ARCHIVE_DIR)/$(ANDROID_ITCHIO_RUN_DIST_NAME).apk
adb shell am start -n $(ANDROID_PACKAGE_NAME)/com.agateau.pixelwheels.android.AndroidLauncher
# coding style
codingstyle-check:
tools/apply-codingstyle --check
codingstyle-apply:
tools/apply-codingstyle
# Tag
tag:
git tag -f -m "Pixel Wheels $(VERSION)" $(VERSION)
tagpush: tag
git push
git push --tags
# Uploading
fastlane-beta:
fastlane supply --track beta --aab $(ARCHIVE_DIR)/$(ANDROID_GPLAY_RUN_DIST_NAME).aab
upload:
ci/upload-build pixelwheels \
$(ARCHIVE_DIR)/$(DIST_NAME)-*.zip \
$(ARCHIVE_DIR)/$(ANDROID_GPLAY_RUN_DIST_NAME).apk \
$(ARCHIVE_DIR)/$(ANDROID_ITCHIO_RUN_DIST_NAME).apk \
butler-upload:
butler push --userversion $(VERSION) $(ARCHIVE_DIR)/$(DIST_NAME)-linux* agateau/pixelwheels:linux-stable
butler push --userversion $(VERSION) $(ARCHIVE_DIR)/$(DIST_NAME)-mac* agateau/pixelwheels:macos-stable
butler push --userversion $(VERSION) $(ARCHIVE_DIR)/$(DIST_NAME)-windows* agateau/pixelwheels:windows-stable
butler push --userversion $(VERSION) $(ARCHIVE_DIR)/$(ANDROID_ITCHIO_RUN_DIST_NAME).apk agateau/pixelwheels:android-stable
gh-upload:
gh release create ${VERSION} \
-F .changes/${VERSION}.md \
${ARCHIVE_DIR}/${DIST_NAME}-linux* \
${ARCHIVE_DIR}/${DIST_NAME}-mac* \
${ARCHIVE_DIR}/${DIST_NAME}-windows* \
${ARCHIVE_DIR}/${ANDROID_ITCHIO_RUN_DIST_NAME}.apk
# Cleaning conf
backup-desktop-conf:
mkdir -p $(CONF_BACKUP_DIR)
cp ~/.config/agateau.com/pixelwheels.conf $(CONF_BACKUP_DIR) || true
cp -R ~/.local/share/pixelwheels $(CONF_BACKUP_DIR)
restore-desktop-conf:
@if ! [ -d "$(CONF_BACKUP_DIR)" ] ; then echo "$(CONF_BACKUP_DIR) does not exist. No backup to restore."; exit 1; fi
rm ~/.config/agateau.com/pixelwheels.conf
rm -rf ~/.local/share/pixelwheels
cp $(CONF_BACKUP_DIR)/pixelwheels.conf ~/.config/agateau.com || true
cp -R $(CONF_BACKUP_DIR)/pixelwheels ~/.local/share
clean-desktop-conf:
rm -f ~/.config/agateau.com/pixelwheels.conf
rm -rf ~/.local/share/pixelwheels
clean-android-conf:
adb shell "pm clear $(ANDROID_PACKAGE_NAME)"
# tests
check: codingstyle-check po-check font-check
@$(GRADLEW) check
@$(GRADLEW) test
smoke-tests: smoke-tests-from-dist smoke-tests-from-install
smoke-tests-from-dist:
rm -rf tmp
mkdir -p tmp
unzip $(ARCHIVE_DIR)/$(DESKTOP_RUN_DIST_NAME).zip -d tmp
tools/smoke-test tmp/$(DESKTOP_RUN_DIST_NAME)/pixelwheels
smoke-tests-from-install:
rm -rf tmp
mkdir -p tmp
$(MAKE) install DESTDIR=$(CURDIR)/tmp
tools/smoke-test tmp/usr/local/bin/pixelwheels
# Translations
po-update:
tools/po-update
po-check:
tools/po-update --check
font-update:
tools/fonts/font-update
font-check:
tools/fonts/font-update --check
.PHONY: desktop-dist apk-dist dist clean-dist tag tagpush fastlane-beta check tools build release-archives