Support building both debug and release APKs. Release is too big.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4226 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
d38b41687c
commit
602941104e
49
Makefile
49
Makefile
@ -37,11 +37,22 @@ ANDROID_TARGETS := \
|
|||||||
$(ANDROID_X86_64_TARGETS) \
|
$(ANDROID_X86_64_TARGETS) \
|
||||||
$(ANDROID_ARM64_TARGETS)
|
$(ANDROID_ARM64_TARGETS)
|
||||||
|
|
||||||
debug windebug $(ANDROID_TARGETS): CFLAGS += -Og
|
DEBUG_TARGETS := \
|
||||||
|
out/debug/tildefriends \
|
||||||
|
out/windebug/tildefriends \
|
||||||
|
out/androiddebug/tildefriends \
|
||||||
|
out/androiddebug-x86_64/tildefriends
|
||||||
|
RELEASE_TARGETS := \
|
||||||
|
out/release/tildefriends \
|
||||||
|
out/winrelease/tildefriends \
|
||||||
|
out/androidrelease/tildefriends \
|
||||||
|
out/androidrelease-x86_64/tildefriends
|
||||||
|
|
||||||
debug release out/androidrelease/tildefriends out/androidrelease-x86_64/tildefriends: LDFLAGS += -rdynamic
|
debug release out/androidrelease/tildefriends out/androidrelease-x86_64/tildefriends: LDFLAGS += -rdynamic
|
||||||
$(ANDROID_TARGETS): CFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC
|
$(ANDROID_TARGETS): CFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC
|
||||||
$(ANDROID_TARGETS): LDFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC
|
$(ANDROID_TARGETS): LDFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC
|
||||||
release winrelease: CFLAGS += -DNDEBUG -O3
|
$(DEBUG_TARGETS): CFLAGS += -DDEBUG -Og
|
||||||
|
$(RELEASE_TARGETS): CFLAGS += -DNDEBUG -O3
|
||||||
windebug winrelease: CC = x86_64-w64-mingw32-gcc-win32
|
windebug winrelease: CC = x86_64-w64-mingw32-gcc-win32
|
||||||
windebug winrelease: AS = $(CC)
|
windebug winrelease: AS = $(CC)
|
||||||
windebug winrelease: CFLAGS += \
|
windebug winrelease: CFLAGS += \
|
||||||
@ -399,10 +410,10 @@ $(foreach build_type,$(BUILD_TYPES),$(eval $(call build_rules,$(build_type))))
|
|||||||
out/res/layout_activity_main.xml.flat: src/android/res/layout/activity_main.xml
|
out/res/layout_activity_main.xml.flat: src/android/res/layout/activity_main.xml
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
@echo [aapt2] $@
|
@echo [aapt2] $@
|
||||||
$(ANDROID_BUILD_TOOLS)/aapt2 compile -o out/res/ src/android/res/layout/activity_main.xml
|
@$(ANDROID_BUILD_TOOLS)/aapt2 compile -o out/res/ src/android/res/layout/activity_main.xml
|
||||||
|
|
||||||
out/res.apk out/gen/com/unprompted/tildefriends/R.java: out/res/layout_activity_main.xml.flat src/android/AndroidManifest.xml
|
out/res.apk out/gen/com/unprompted/tildefriends/R.java: out/res/layout_activity_main.xml.flat src/android/AndroidManifest.xml
|
||||||
$(ANDROID_BUILD_TOOLS)/aapt2 link -I $(ANDROID_PLATFORM)/android.jar out/res/layout_activity_main.xml.flat --manifest src/android/AndroidManifest.xml -o out/res.apk --java out/gen/
|
@$(ANDROID_BUILD_TOOLS)/aapt2 link -I $(ANDROID_PLATFORM)/android.jar out/res/layout_activity_main.xml.flat --manifest src/android/AndroidManifest.xml -o out/res.apk --java out/gen/
|
||||||
|
|
||||||
JAVA_FILES := out/gen/com/unprompted/tildefriends/R.java $(wildcard src/android/com/unprompted/tildefriends/*.java)
|
JAVA_FILES := out/gen/com/unprompted/tildefriends/R.java $(wildcard src/android/com/unprompted/tildefriends/*.java)
|
||||||
CLASS_FILES := $(foreach src,$(JAVA_FILES),out/classes/com/unprompted/tildefriends/$(notdir $(src:.java=.class)))
|
CLASS_FILES := $(foreach src,$(JAVA_FILES),out/classes/com/unprompted/tildefriends/$(notdir $(src:.java=.class)))
|
||||||
@ -412,9 +423,9 @@ $(CLASS_FILES) &: $(JAVA_FILES)
|
|||||||
@javac --release 8 -Xlint:deprecation -classpath $(ANDROID_PLATFORM)/android.jar -d out/classes $(JAVA_FILES)
|
@javac --release 8 -Xlint:deprecation -classpath $(ANDROID_PLATFORM)/android.jar -d out/classes $(JAVA_FILES)
|
||||||
|
|
||||||
out/apk/classes.dex: $(CLASS_FILES)
|
out/apk/classes.dex: $(CLASS_FILES)
|
||||||
mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
echo [d8] $@
|
@echo [d8] $@
|
||||||
$(ANDROID_BUILD_TOOLS)/d8 --lib $(ANDROID_PLATFORM)/android.jar --output $(dir $@) out/classes/com/unprompted/tildefriends/*.class
|
@$(ANDROID_BUILD_TOOLS)/d8 --$(BUILD_TYPE) --lib $(ANDROID_PLATFORM)/android.jar --output $(dir $@) out/classes/com/unprompted/tildefriends/*.class
|
||||||
|
|
||||||
PACKAGE_DIRS := \
|
PACKAGE_DIRS := \
|
||||||
apps/ \
|
apps/ \
|
||||||
@ -425,22 +436,28 @@ PACKAGE_DIRS := \
|
|||||||
|
|
||||||
RAW_FILES := $(shell find $(PACKAGE_DIRS) -type f)
|
RAW_FILES := $(shell find $(PACKAGE_DIRS) -type f)
|
||||||
|
|
||||||
out/TildeFriends.unsigned.apk: out/apk/classes.dex out/androiddebug/tildefriends out/androiddebug-x86_64/tildefriends $(RAW_FILES) out/res.apk
|
out/TildeFriends-debug.unsigned.apk: BUILD_TYPE := debug
|
||||||
@mkdir -p $(dir $@) out/apk/lib/arm64-v8a/ out/apk/lib/x86_64/
|
out/TildeFriends-release.unsigned.apk: BUILD_TYPE := release
|
||||||
|
|
||||||
|
out/%.unsigned.apk:
|
||||||
|
@mkdir -p $(dir $@) out/apk$(BUILD_TYPE)/lib/arm64-v8a/ out/apk$(BUILD_TYPE)/lib/x86_64/
|
||||||
@echo [aapt] $@
|
@echo [aapt] $@
|
||||||
@cp out/androiddebug/tildefriends out/apk/lib/arm64-v8a/
|
@cp out/android$(BUILD_TYPE)/tildefriends out/apk$(BUILD_TYPE)/lib/arm64-v8a/
|
||||||
@cp out/androiddebug-x86_64/tildefriends out/apk/lib/x86_64/
|
@cp out/android$(BUILD_TYPE)-x86_64/tildefriends out/apk$(BUILD_TYPE)/lib/x86_64/
|
||||||
@/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk/lib/arm64-v8a/tildefriends
|
@/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/lib/arm64-v8a/tildefriends
|
||||||
@/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk/lib/x86_64/tildefriends
|
@/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/lib/x86_64/tildefriends
|
||||||
@cp out/res.apk $@
|
@cp out/res.apk $@
|
||||||
@cd out/apk && zip -u ../../$@ -q -9 -r . && cd ../../
|
@cd out/apk$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../
|
||||||
@zip -u $@ -q -9 -r $(PACKAGE_DIRS) $(RAW_FILES)
|
@zip -u $@ -q -9 -r $(PACKAGE_DIRS) $(RAW_FILES)
|
||||||
|
|
||||||
out/TildeFriends.apk: out/TildeFriends.unsigned.apk
|
out/TildeFriends-debug.unsigned.apk: out/apk/classes.dex out/androiddebug/tildefriends out/androiddebug-x86_64/tildefriends $(RAW_FILES) out/res.apk
|
||||||
|
out/TildeFriends-release.unsigned.apk: out/apk/classes.dex out/androidrelease/tildefriends out/androidrelease-x86_64/tildefriends $(RAW_FILES) out/res.apk
|
||||||
|
|
||||||
|
out/%.apk: out/%.unsigned.apk
|
||||||
@echo [apksigner] $(notdir $@)
|
@echo [apksigner] $(notdir $@)
|
||||||
@$(ANDROID_BUILD_TOOLS)/apksigner sign --ks keystore.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --out $@ $<
|
@$(ANDROID_BUILD_TOOLS)/apksigner sign --ks keystore.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --out $@ $<
|
||||||
|
|
||||||
apk: out/TildeFriends.apk
|
apk: out/TildeFriends-debug.apk
|
||||||
.PHONY: apk
|
.PHONY: apk
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
Loading…
Reference in New Issue
Block a user