2021-04-11 21:02:03 +02:00
|
|
|
# Configuration
|
|
|
|
|
|
|
|
PACKAGE_NAME = juloo.keyboard2
|
|
|
|
|
2021-12-12 23:48:05 +01:00
|
|
|
ANDROID_PLATFORM_VERSION = android-30
|
2022-04-16 23:36:54 +02:00
|
|
|
JAVA_VERSION = 1.7
|
2021-04-11 21:02:03 +02:00
|
|
|
|
|
|
|
SRC_DIR = srcs
|
|
|
|
RES_DIR = res
|
|
|
|
|
|
|
|
EXTRA_JARS =
|
|
|
|
|
|
|
|
# /
|
|
|
|
|
|
|
|
debug: _build/$(PACKAGE_NAME).debug.apk
|
|
|
|
release: _build/$(PACKAGE_NAME).apk
|
|
|
|
|
|
|
|
installd: _build/$(PACKAGE_NAME).debug.apk
|
2022-04-16 23:38:16 +02:00
|
|
|
adb install -r "$<"
|
2021-04-11 21:02:03 +02:00
|
|
|
|
2022-03-14 18:37:37 +01:00
|
|
|
clean:
|
|
|
|
rm -rf _build/*.dex _build/class _build/gen _build/*.apk _build/*.unsigned-apk \
|
2022-03-18 12:24:29 +01:00
|
|
|
_build/*.idsig _build/assets
|
2022-03-14 18:37:37 +01:00
|
|
|
|
2022-04-24 20:52:36 +02:00
|
|
|
rebuild_special_font:
|
|
|
|
cd srcs/special_font && fontforge -lang=ff -script build.pe *.svg
|
|
|
|
|
|
|
|
.PHONY: release debug installd clean rebuild_special_font
|
2021-04-11 21:02:03 +02:00
|
|
|
|
|
|
|
$(shell mkdir -p _build)
|
|
|
|
|
|
|
|
ifndef ANDROID_HOME
|
|
|
|
$(error ANDROID_HOME not set)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ANDROID_BUILD_TOOLS = $(lastword $(sort $(wildcard $(ANDROID_HOME)/build-tools/*)))
|
|
|
|
ANDROID_PLATFORM = $(ANDROID_HOME)/platforms/$(ANDROID_PLATFORM_VERSION)
|
|
|
|
|
|
|
|
ifeq ($(shell [ -d "$(ANDROID_PLATFORM)" ] && echo ok),)
|
|
|
|
$(error Android platform not found. Want $(ANDROID_PLATFORM_VERSION), \
|
|
|
|
found $(notdir $(wildcard $(ANDROID_HOME)/platforms/*)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
JAVAC_FLAGS = -source $(JAVA_VERSION) -target $(JAVA_VERSION) -encoding utf8
|
|
|
|
|
|
|
|
# Source files
|
|
|
|
|
|
|
|
MANIFEST_FILE = AndroidManifest.xml
|
|
|
|
JAVA_FILES = $(shell find $(SRC_DIR) -name '*.java')
|
|
|
|
RES_FILES = $(shell find $(RES_DIR) -type f)
|
|
|
|
|
|
|
|
# Debug signing
|
|
|
|
|
|
|
|
DEBUG_KEYSTORE = _build/debug.keystore
|
|
|
|
DEBUG_PASSWD = debug0
|
|
|
|
|
|
|
|
$(DEBUG_KEYSTORE):
|
|
|
|
echo y | keytool -genkeypair -dname "cn=d, ou=e, o=b, c=ug" \
|
|
|
|
-alias debug -keypass $(DEBUG_PASSWD) -keystore "$@" \
|
|
|
|
-keyalg rsa -storepass $(DEBUG_PASSWD) -validity 10000
|
|
|
|
|
2021-12-14 00:13:34 +01:00
|
|
|
_build/%.debug.apk: _build/%.debug.unsigned-apk $(DEBUG_KEYSTORE)
|
2022-02-02 22:02:58 +01:00
|
|
|
$(ANDROID_BUILD_TOOLS)/apksigner sign --in "$<" --out "$@" \
|
2022-01-20 21:21:27 +01:00
|
|
|
--ks $(DEBUG_KEYSTORE) --ks-key-alias debug --ks-pass "pass:$(DEBUG_PASSWD)"
|
2021-04-11 21:02:03 +02:00
|
|
|
|
|
|
|
# Debug apk
|
|
|
|
|
2022-03-14 18:37:37 +01:00
|
|
|
_build/$(PACKAGE_NAME).debug.unsigned-apk: AAPT_PACKAGE_FLAGS+=--rename-manifest-package $(PACKAGE_NAME).debug --product debug
|
2021-04-11 21:02:03 +02:00
|
|
|
|
|
|
|
# Release signing
|
|
|
|
|
2021-12-14 00:13:34 +01:00
|
|
|
# %-keystore.conf should declare KEYSTORE, KEYNAME and KEYSTOREPASS
|
2021-04-11 21:02:03 +02:00
|
|
|
# it is interpreted as a shell script
|
2021-12-14 00:13:34 +01:00
|
|
|
_build/%.apk: _build/%.unsigned-apk %-keystore.conf
|
2021-04-11 21:02:03 +02:00
|
|
|
eval `cat $(word 2,$^)` && \
|
2022-02-05 20:22:40 +01:00
|
|
|
$(ANDROID_BUILD_TOOLS)/apksigner sign --in "$<" --out "$@" \
|
2021-12-14 00:13:34 +01:00
|
|
|
--ks "$$KEYSTORE" --ks-key-alias "$$KEYNAME" --ks-pass "pass:$$KEYSTOREPASS"
|
2021-04-11 21:02:03 +02:00
|
|
|
|
|
|
|
# Package
|
|
|
|
|
2021-12-14 00:13:34 +01:00
|
|
|
_build/%.unsigned-apk: _build/%.unaligned-apk
|
|
|
|
$(ANDROID_BUILD_TOOLS)/zipalign -fp 4 "$<" "$@"
|
|
|
|
|
2022-03-17 20:08:26 +01:00
|
|
|
APK_EXTRA_FILES = classes.dex assets/special_font.ttf
|
|
|
|
|
|
|
|
_build/%.unaligned-apk: $(addprefix _build/,$(APK_EXTRA_FILES)) $(MANIFEST_FILE)
|
2021-04-11 21:02:03 +02:00
|
|
|
$(ANDROID_BUILD_TOOLS)/aapt package -f -M $(MANIFEST_FILE) -S $(RES_DIR) \
|
|
|
|
-I $(ANDROID_PLATFORM)/android.jar -F "$@" $(AAPT_PACKAGE_FLAGS)
|
2022-03-17 20:08:26 +01:00
|
|
|
cd $(@D) && $(ANDROID_BUILD_TOOLS)/aapt add $(@F) $(APK_EXTRA_FILES)
|
2021-04-11 21:02:03 +02:00
|
|
|
|
2022-04-24 20:52:36 +02:00
|
|
|
# Copy the special font file into _build because aapt requires relative paths
|
|
|
|
_build/assets/special_font.ttf: srcs/special_font/result.ttf
|
|
|
|
mkdir -p $(@D)
|
|
|
|
cp "$<" "$@"
|
|
|
|
|
2021-04-11 21:02:03 +02:00
|
|
|
# R.java
|
|
|
|
|
|
|
|
GEN_DIR = _build/gen
|
|
|
|
R_FILE = $(GEN_DIR)/$(subst .,/,$(PACKAGE_NAME))/R.java
|
|
|
|
|
|
|
|
$(R_FILE): $(RES_FILES) $(MANIFEST_FILE)
|
|
|
|
mkdir -p "$(@D)"
|
|
|
|
$(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(RES_DIR) -J $(GEN_DIR) \
|
|
|
|
-M $(MANIFEST_FILE) -I $(ANDROID_PLATFORM)/android.jar
|
|
|
|
|
|
|
|
# Compile java classes and build classes.dex
|
|
|
|
|
|
|
|
OBJ_DIR = _build/class
|
|
|
|
# A$B.class files are ignored
|
|
|
|
# CLASS_FILES = $(JAVA_FILES:$(SRC_DIR)/%.java=$(OBJ_DIR)/%.class) \
|
|
|
|
# $(R_FILE:$(GEN_DIR)/%.java=$(OBJ_DIR)/%.class)
|
|
|
|
|
|
|
|
_build/classes.dex: $(JAVA_FILES) $(R_FILE)
|
|
|
|
mkdir -p $(OBJ_DIR)
|
|
|
|
javac -d $(OBJ_DIR) $(JAVAC_FLAGS) \
|
|
|
|
-classpath $(ANDROID_PLATFORM)/android.jar:$(EXTRA_JARS) \
|
|
|
|
-sourcepath $(SRC_DIR):$(GEN_DIR) \
|
|
|
|
$^
|
2022-02-07 01:11:55 +01:00
|
|
|
$(ANDROID_BUILD_TOOLS)/d8 --output $(@D) $(OBJ_DIR)/*/*/* $(subst :, ,$(EXTRA_JARS))
|