-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
35 lines (26 loc) · 1.19 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
output_dir := app/build/outputs/apk/release
unsigned_apk_filename := app-release-unsigned.apk
unsigned_aligned_apk_filename := app-release-unsigned-aligned.apk
signed_apk_filename := app-release.apk
build: $(output_dir)/$(unsigned_apk_filename) ## Build an unsigned APK
$(output_dir)/$(unsigned_apk_filename):
./gradlew assembleRelease
align: $(output_dir)/$(unsigned_aligned_apk_filename) ## Align the unsigned APK
$(output_dir)/$(unsigned_aligned_apk_filename): $(output_dir)/$(unsigned_apk_filename)
zipalign -v -p 4 "$<" "$@"
sign: $(output_dir)/$(signed_apk_filename) ## Sign the aligned unsigned APK. Example: make sign keystore_path=/path/to/your/keystore.jks
$(output_dir)/$(signed_apk_filename): $(output_dir)/$(unsigned_aligned_apk_filename)
ifeq ($(keystore_path),)
@echo "You must set the variable 'keystore_path'."
exit 1
endif
apksigner sign --ks "$(keystore_path)" --out "$@" "$<"
.PHONY: install
install: $(output_dir)/$(signed_apk_filename) ## Install the signed APK using adb
adb -d install "$<"
.PHONY: clean
clean:
-rm -r app/build
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'