Added support for building for Android on Windows.

This commit is contained in:
XsparkieX 2021-02-01 21:37:07 +01:00
parent 3fbe1a61e1
commit bcc28a0ae3
3 changed files with 79 additions and 5 deletions

View file

@ -433,12 +433,11 @@ else # ifeq Linux
#############################################################################
ifeq ($(PLATFORM),android)
ANDROID_NDK = ~/Android/Sdk/ndk/21.1.6352462
ARCH = aarch64
CC = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang
RANLIB = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ranlib
CC = $(ANDROID_CC)
RANLIB = $(ANDROID_RANLIB)
TOOLS_CFLAGS += -DARCH_STRING=\"$(COMPILE_ARCH)\"
BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes -pipe \
BASE_CFLAGS = $(ANDROID_CFLAGS) -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes -pipe \
-fno-builtin-cos -fno-builtin-sin -fPIC -DARCH_STRING=\\\"$(ARCH)\\\"
CLIENT_CFLAGS += $(SDL_CFLAGS) -DSDL_DISABLE_IMMINTRIN_H -fno-builtin-cos -fno-builtin-sin
@ -1275,7 +1274,7 @@ define DO_REF_STR
$(echo_cmd) "REF_STR $<"
$(Q)rm -f $@
$(Q)echo "const char *fallbackShader_$(notdir $(basename $<)) =" >> $@
$(Q)cat $< | sed -e 's/^/\"/;s/$$/\\n\"/' | tr -d '\r' >> $@
$(Q)cat $< | sed -e 's/^\(.*\)$$/\"\1\"/' >> $@
$(Q)echo ";" >> $@
endef

View file

@ -1,4 +1,15 @@
PLATFORM=android
ANDROID_SDK_VERSION=android26
ANDROID_NDK_VERSION=21.1.6352462
## Uncomment for Windows host platform
# ANDROID_NDK=C:/Users/<user>/AppData/Local/Android/Sdk/ndk/$(ANDROID_NDK_VERSION)
# ANDROID_CC=$(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
# ANDROID_CFLAGS=--target=aarch64-linux-$(ANDROID_SDK_VERSION)
# ANDROID_RANLIB=$(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android-ranlib.exe
## Uncomment for Linux host platform
# ANDROID_NDK=~/Android/Sdk/ndk/$(ANDROID_NDK_VERSION)
# ANDROID_CC=$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-$(ANDROID_SDK_VERSION)-clang
# ANDROID_RANLIB=$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ranlib
BUILD_CLIENT=1
BUILD_CLIENT_SMP=0
BUILD_GAME_QVM=0

64
android/run.bat Normal file
View file

@ -0,0 +1,64 @@
@echo off
setlocal
cd ..
set adb="%AppData%\..\Local\Android\Sdk\platform-tools\adb.exe"
set make="%AppData%\..\Local\Android\Sdk\ndk\21.1.6352462\prebuilt\windows-x86_64\bin\make.exe"
set JAVA_HOME=C:\Program Files\Android\Android Studio\jre\jre
%make% -j %NUMBER_OF_PROCESSORS% debug
if %ERRORLEVEL% NEQ 0 (
echo "Failed to build ioq3"
exit /b 1
)
cd android
set GRADLE_EXIT_CONSOLE=1
call gradlew.bat :app:assembleDebug
if %ERRORLEVEL% NEQ 0 (
echo "Failed to build android project"
exit /b 1
)
set PACKAGE_NAME=com.sparkie.ioq3quest
set ANDROID_STORAGE_LOCATION=/sdcard/Android/data/%PACKAGE_NAME%/files/
set APK_LOCATION=.\app\build\outputs\apk\debug\app-debug.apk
%adb% install -r %APK_LOCATION%
if %ERRORLEVEL% NEQ 0 (
%adb% uninstall %PACKAGE_NAME%
%adb% install %APK_LOCATION%
if %ERRORLEVEL% NEQ 0 (
echo "Failed to install apk."
exit /b 1
)
)
%adb% shell mkdir -p %ANDROID_STORAGE_LOCATION%
%adb% push --sync "C:\Program Files (x86)\Steam\steamapps\common\Quake 3 Arena\baseq3" %ANDROID_STORAGE_LOCATION%
if %ERRORLEVEL% NEQ 0 (
echo "Failed to transfer files."
exit /b 1
)
%adb% push --sync ..\code\renderergl2\glsl %ANDROID_STORAGE_LOCATION%/baseq3/
if %ERRORLEVEL% NEQ 0 (
echo "Failed to transfer shaders."
exit /b 1
)
%adb% push --sync autoexec.cfg %ANDROID_STORAGE_LOCATION%/baseq3/
if %ERRORLEVEL% NEQ 0 (
echo "Failed to transfer autoexec."
exit /b 1
)
%adb% logcat -c
%adb% shell am start -n %PACKAGE_NAME%/.MainActivity
if %ERRORLEVEL% NEQ 0 (
echo "Failed to start application."
exit 1
)
%adb% logcat *:S Quake3:V SDL:V DEBUG:V
endlocal