tibia/templates/android-make/Makefile

95 lines
2.8 KiB
Makefile
Raw Normal View History

2024-01-23 08:22:00 +00:00
include vars.mk
2024-01-23 14:18:39 +00:00
ifeq (${HAS_MIDI_IN}, yes)
MIN_API := 29
else
MIN_API := 26
endif
2024-01-23 08:22:00 +00:00
JAVAC = javac
2024-01-23 14:18:39 +00:00
CXX = ${ANDROID_NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi${MIN_API}-clang++
2024-01-23 08:22:00 +00:00
APKSIGNER = ${BUILD_TOOLS_DIR}/apksigner
ZIPALIGN = ${BUILD_TOOLS_DIR}/zipalign
AAPT = ${BUILD_TOOLS_DIR}/aapt
D8 = ${BUILD_TOOLS_DIR}/d8
2024-01-23 09:39:30 +00:00
ADB = ${ANDROID_SDK_DIR}/platform-tools/adb
2024-01-23 08:22:00 +00:00
JARS := \
${ANDROID_JAR_FILE} \
${ANDROIDX_CORE_FILE} \
${ANDROIDX_LIFECYCLE_COMMON_FILE} \
${ANDROIDX_VERSIONEDPARCELABLE_FILE} \
${KOTLIN_STDLIB_FILE} \
${KOTLINX_COROUTINES_CORE_FILE} \
${KOTLINX_COROUTINES_CORE_JVM_FILE}
2024-01-23 09:39:30 +00:00
CLASSES_PATH := $(subst .,/,$(JAVA_PACKAGE_NAME))
2024-01-23 08:22:00 +00:00
2024-01-23 14:18:39 +00:00
CLASSES := \
MainActivity \
MainActivity$$WebAppInterface
2024-01-28 10:54:30 +00:00
ifeq (${HAS_MIDI_IN}, yes)
CLASSES += MainActivity$$WebAppInterface$$MidiDeviceCallback MainActivity$$WebAppInterface$$1
endif
2024-01-23 14:18:39 +00:00
CXXFLAGS := \
-fPIC \
-DNDEBUG \
-DBW_NO_DEBUG \
-O3 \
-Wall \
-Wextra \
-Wpedantic \
-std=c++11
LDFLAGS := \
-shared \
-static-libstdc++ \
-ljnigraphics \
-llog \
-landroid
2024-01-23 08:22:00 +00:00
2024-01-28 10:54:30 +00:00
ifeq (${HAS_MIDI_IN}, yes)
LDFLAGS += -lamidi
endif
2024-01-23 08:22:00 +00:00
all: build/${BUNDLE_NAME}.apk
build/${BUNDLE_NAME}.apk: build/gen/${BUNDLE_NAME}.aligned.apk ${KEY_STORE}
2024-01-23 09:39:30 +00:00
${APKSIGNER} sign --ks ${KEY_STORE} --ks-key-alias ${KEY_ALIAS} --ks-pass pass:${STORE_PASS} --key-pass pass:${KEY_PASS} --out $@ build/gen/${BUNDLE_NAME}.aligned.apk
2024-01-23 08:22:00 +00:00
build/gen/${BUNDLE_NAME}.aligned.apk: build/gen/${BUNDLE_NAME}.unsigned.apk
${ZIPALIGN} -f -p 4 $^ $@
2024-01-23 14:18:39 +00:00
build/gen/${BUNDLE_NAME}.unsigned.apk: build/apk/classes.dex build/apk/lib/armeabi-v7a/lib${BUNDLE_NAME}.so data/AndroidManifest.xml build/assets/index.html | build/gen
2024-01-23 09:39:30 +00:00
${AAPT} package -f -M data/AndroidManifest.xml -A build/assets $(foreach jar,$(JARS),-I $(jar)) -F $@ build/apk
2024-01-23 08:22:00 +00:00
build/apk/classes.dex: build/apk/my_classes.jar
cd build/apk && ${D8} --min-api ${MIN_API} ../../$^ ${JARS} && cd ../..
build/apk/my_classes.jar: $(foreach class,$(CLASSES),build/obj/$(CLASSES_PATH)/$(class).class) | build/apk
2024-01-23 09:39:30 +00:00
@echo ${CLASSES_PATH}
2024-01-23 08:22:00 +00:00
${D8} $(foreach class,$(CLASSES),'build/obj/$(CLASSES_PATH)/$(class).class') --min-api ${MIN_API} --output $@ --no-desugaring
build/obj/${CLASSES_PATH}/MainActivity.class: src/MainActivity.java | build/obj
${JAVAC} -classpath "$(subst $() $(),:,$(JARS))" -d build/obj $^
2024-01-23 14:18:39 +00:00
build/apk/lib/armeabi-v7a/lib${BUNDLE_NAME}.so: src/jni.cpp | build/apk/lib/armeabi-v7a
2024-01-23 17:38:52 +00:00
${CXX} $^ ${CXXFLAGS} ${CXXFLAGS_EXTRA} ${LDFLAGS} ${LDFLAGS_EXTRA} -o $@
2024-01-23 14:18:39 +00:00
2024-01-23 09:39:30 +00:00
build/assets/index.html: src/index.html | build/assets
cp $^ $@
2024-01-23 14:18:39 +00:00
build/gen build/apk build/obj build/apk/lib/armeabi-v7a build/assets:
2024-01-23 08:22:00 +00:00
mkdir -p $@
clean:
rm -fr build
install: build/${BUNDLE_NAME}.apk
2024-01-23 09:39:30 +00:00
[ -n "`${ADB} shell pm list packages | grep ^package:${JAVA_PACKAGE_NAME}`" ] && ${ADB} uninstall ${JAVA_PACKAGE_NAME}; exit 0
2024-01-23 08:22:00 +00:00
${ADB} install $^
.PHONY: all clean install