Compare commits
7 Commits
7a2d7336fb
...
5a2a30ada6
Author | SHA1 | Date | |
---|---|---|---|
5a2a30ada6 | |||
64959270a9 | |||
9d6404d130 | |||
ef4e0d0857 | |||
56f1bf559c | |||
b0e25627b3 | |||
e7b1eec2cc |
86
.github/workflows/cd.yml
vendored
@ -50,12 +50,91 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
# TODO: simpler name?
|
|
||||||
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64
|
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64
|
||||||
# TODO: do propper packing
|
# TODO: do propper packing
|
||||||
path: |
|
path: |
|
||||||
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64.tar.gz
|
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64.tar.gz
|
||||||
|
|
||||||
|
android:
|
||||||
|
timeout-minutes: 30
|
||||||
|
# contains sections copied from sdl repo
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- vcpkg_toolkit: arm64-android
|
||||||
|
ndk_abi: arm64-v8a
|
||||||
|
- vcpkg_toolkit: x64-android
|
||||||
|
ndk_abi: x86_64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- uses: nttld/setup-ndk@v1
|
||||||
|
id: setup_ndk
|
||||||
|
with:
|
||||||
|
local-cache: false # https://github.com/nttld/setup-ndk/issues/518
|
||||||
|
ndk-version: r26d
|
||||||
|
|
||||||
|
- uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '17'
|
||||||
|
|
||||||
|
- name: update vcpkg
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/microsoft/vcpkg.git
|
||||||
|
|
||||||
|
- name: Install Dependencies (host)
|
||||||
|
run: sudo apt update && sudo apt -y install cmake pkg-config nasm
|
||||||
|
|
||||||
|
- name: Install Dependencies (target)
|
||||||
|
env:
|
||||||
|
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
||||||
|
run: vcpkg install --triplet ${{matrix.platform.vcpkg_toolkit}} --overlay-ports=vcpkg/ports libsodium opus libvpx libpng libjpeg-turbo
|
||||||
|
|
||||||
|
# vcpkg scripts root /usr/local/share/vcpkg/scripts
|
||||||
|
- name: Configure CMake
|
||||||
|
env:
|
||||||
|
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
||||||
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{matrix.platform.vcpkg_toolkit}} -DANDROID=1 -DANDROID_PLATFORM=23 -DANDROID_ABI=${{matrix.platform.ndk_abi}} -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DSDL3IMAGE_JPG_SHARED=OFF -DSDL3IMAGE_PNG_SHARED=OFF -DTOMATO_MAIN_SO=ON
|
||||||
|
|
||||||
|
- name: Build (tomato)
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|
||||||
|
- name: Build (SDL3-jar) (workaround)
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t SDL3-jar
|
||||||
|
|
||||||
|
- name: Build (apk)
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato-apk
|
||||||
|
|
||||||
|
- name: Determine tag name
|
||||||
|
id: tag
|
||||||
|
shell: bash
|
||||||
|
# taken from llama.cpp
|
||||||
|
run: |
|
||||||
|
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||||
|
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
||||||
|
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||||
|
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: rename apk
|
||||||
|
id: rename_apk
|
||||||
|
shell: bash
|
||||||
|
run: mv "${{github.workspace}}/build/android/tomato.apk" "${{github.workspace}}/build/android/${{github.event.repository.name}}-${{steps.tag.outputs.name}}-android-${{matrix.platform.ndk_abi}}.apk"
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{github.event.repository.name}}-${{steps.tag.outputs.name}}-${{runner.os}}-android-${{matrix.platform.ndk_abi}}
|
||||||
|
path: |
|
||||||
|
${{github.workspace}}/build/android/${{github.event.repository.name}}-${{steps.tag.outputs.name}}-android-${{matrix.platform.ndk_abi}}.apk
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
@ -110,8 +189,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
# TODO: simpler name?
|
name: ${{github.event.repository.name}}-${{steps.tag.outputs.name}}-${{runner.os}}-msvc-x86_64
|
||||||
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-x86_64
|
|
||||||
# TODO: do propper packing
|
# TODO: do propper packing
|
||||||
path: |
|
path: |
|
||||||
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-x86_64.zip
|
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-x86_64.zip
|
||||||
@ -170,7 +248,6 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
# TODO: simpler name?
|
|
||||||
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-asan-x86_64
|
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-asan-x86_64
|
||||||
# TODO: do propper packing
|
# TODO: do propper packing
|
||||||
path: |
|
path: |
|
||||||
@ -183,6 +260,7 @@ jobs:
|
|||||||
|
|
||||||
needs:
|
needs:
|
||||||
- linux-ubuntu
|
- linux-ubuntu
|
||||||
|
- android
|
||||||
- windows
|
- windows
|
||||||
- windows-asan
|
- windows-asan
|
||||||
|
|
||||||
|
26
.github/workflows/ci.yml
vendored
@ -35,6 +35,14 @@ jobs:
|
|||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- vcpkg_toolkit: arm64-android
|
||||||
|
ndk_abi: arm64-v8a
|
||||||
|
- vcpkg_toolkit: x64-android
|
||||||
|
ndk_abi: x86_64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@ -61,18 +69,30 @@ jobs:
|
|||||||
- name: Install Dependencies (target)
|
- name: Install Dependencies (target)
|
||||||
env:
|
env:
|
||||||
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
||||||
run: vcpkg install --triplet arm64-android --overlay-ports=vcpkg/ports libsodium opus libvpx libpng libjpeg-turbo
|
run: vcpkg install --triplet ${{matrix.platform.vcpkg_toolkit}} --overlay-ports=vcpkg/ports libsodium opus libvpx libpng libjpeg-turbo
|
||||||
|
|
||||||
# vcpkg scripts root /usr/local/share/vcpkg/scripts
|
# vcpkg scripts root /usr/local/share/vcpkg/scripts
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
env:
|
env:
|
||||||
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
||||||
#run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=23 -DANDROID_ABI=arm64-v8a
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{matrix.platform.vcpkg_toolkit}} -DANDROID=1 -DANDROID_PLATFORM=23 -DANDROID_ABI=${{matrix.platform.ndk_abi}} -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DSDL3IMAGE_JPG_SHARED=OFF -DSDL3IMAGE_PNG_SHARED=OFF -DTOMATO_MAIN_SO=ON
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-android -DANDROID=1 -DANDROID_PLATFORM=23 -DANDROID_ABI=arm64-v8a -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DSDL3IMAGE_JPG_SHARED=OFF -DSDL3IMAGE_PNG_SHARED=OFF -DTOMATO_MAIN_SO=ON
|
|
||||||
|
|
||||||
- name: Build (tomato)
|
- name: Build (tomato)
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|
||||||
|
- name: Build (SDL3-jar) (workaround)
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t SDL3-jar
|
||||||
|
|
||||||
|
- name: Build (apk)
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato-apk
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ github.event.repository.name }}-${{matrix.platform.vcpkg_toolkit}}
|
||||||
|
# TODO: do propper packing
|
||||||
|
path: |
|
||||||
|
${{github.workspace}}/build/android/tomato.apk
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
@ -70,3 +70,10 @@ endif()
|
|||||||
|
|
||||||
add_subdirectory(./src)
|
add_subdirectory(./src)
|
||||||
|
|
||||||
|
# TODO: move to src
|
||||||
|
if (ANDROID AND TARGET SDL3::Jar)
|
||||||
|
message("II building for ANDROID!!!")
|
||||||
|
|
||||||
|
add_subdirectory(android)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
100
android/CMakeLists.txt
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR)
|
||||||
|
|
||||||
|
project(tomato_android)
|
||||||
|
|
||||||
|
# here be dragons
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${SDL3_SOURCE_DIR}/cmake/android")
|
||||||
|
|
||||||
|
find_package(SdlAndroid MODULE)
|
||||||
|
find_package(Java)
|
||||||
|
find_package(SdlAndroidPlatform MODULE)
|
||||||
|
# the existence of SDL3::Jar usually implies platform
|
||||||
|
if(SdlAndroid_FOUND)
|
||||||
|
include(SdlAndroidFunctions)
|
||||||
|
sdl_create_android_debug_keystore(tomato-debug-keystore)
|
||||||
|
sdl_android_compile_resources(tomato-resources RESFOLDER app/res)
|
||||||
|
|
||||||
|
|
||||||
|
set(ANDROID_MANIFEST_PACKAGE "org.libsdl.app.tomato")
|
||||||
|
#set(generated_manifest_path "${CMAKE_CURRENT_BINARY_DIR}/android/${TEST}-src/AndroidManifest.xml")
|
||||||
|
string(REPLACE "." "/" JAVA_PACKAGE_DIR "${ANDROID_MANIFEST_PACKAGE}")
|
||||||
|
#set(GENERATED_SRC_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/android/${TEST}-src")
|
||||||
|
#set(GENERATED_RES_FOLDER "${GENERATED_SRC_FOLDER}/res")
|
||||||
|
#set(JAVA_PACKAGE_DIR "${GENERATED_SRC_FOLDER}/${JAVA_PACKAGE_DIR}")
|
||||||
|
set(JAVA_PACKAGE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/app/java/${JAVA_PACKAGE_DIR}")
|
||||||
|
|
||||||
|
sdl_android_link_resources(tomato-apk-linked
|
||||||
|
MANIFEST "app/AndroidManifest.xml"
|
||||||
|
PACKAGE ${ANDROID_MANIFEST_PACKAGE}
|
||||||
|
RES_TARGETS tomato-resources
|
||||||
|
TARGET_SDK_VERSION 31
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding;utf-8")
|
||||||
|
set(classes_path "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/tomato-java.dir/classes")
|
||||||
|
# Some CMake versions have a slow `cmake -E make_directory` implementation
|
||||||
|
if(NOT IS_DIRECTORY "${classes_path}")
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${classes_path}")
|
||||||
|
endif()
|
||||||
|
set(OUT_JAR "${CMAKE_CURRENT_BINARY_DIR}/tomato.jar")
|
||||||
|
# TODO: convert to cmake's add_jar
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${OUT_JAR}"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E rm -rf "${classes_path}"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${classes_path}"
|
||||||
|
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||||
|
-source 1.8 -target 1.8
|
||||||
|
-bootclasspath "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>"
|
||||||
|
"${JAVA_PACKAGE_DIR}/TomatoActivity.java"
|
||||||
|
$<TARGET_PROPERTY:tomato-apk-linked,JAVA_R>
|
||||||
|
-cp "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>:${SDL_ANDROID_PLATFORM_ANDROID_JAR}"
|
||||||
|
-d "${classes_path}"
|
||||||
|
COMMAND ${Java_JAR_EXECUTABLE} cf "${OUT_JAR}" -C "${classes_path}" .
|
||||||
|
DEPENDS $<TARGET_PROPERTY:tomato-apk-linked,OUTPUTS> "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>"
|
||||||
|
)
|
||||||
|
add_custom_target(tomato-jar DEPENDS "${OUT_JAR}")
|
||||||
|
add_dependencies(tomato-jar SDL3::Jar) # HACK: somehow their jar is not registered as an output
|
||||||
|
set_property(TARGET tomato-jar PROPERTY OUTPUT "${OUT_JAR}")
|
||||||
|
|
||||||
|
set(dexworkdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/tomato-dex.dir")
|
||||||
|
# Some CMake versions have a slow `cmake -E make_directory` implementation
|
||||||
|
if(NOT IS_DIRECTORY "${dexworkdir}")
|
||||||
|
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${dexworkdir}")
|
||||||
|
endif()
|
||||||
|
set(classes_dex_base_name "classes.dex")
|
||||||
|
set(classes_dex "${dexworkdir}/${classes_dex_base_name}")
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${classes_dex}"
|
||||||
|
COMMAND SdlAndroid::d8
|
||||||
|
$<TARGET_PROPERTY:tomato-jar,OUTPUT>
|
||||||
|
$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>
|
||||||
|
--lib "${SDL_ANDROID_PLATFORM_ANDROID_JAR}"
|
||||||
|
--output "${dexworkdir}"
|
||||||
|
DEPENDS $<TARGET_PROPERTY:tomato-jar,OUTPUT> $<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>
|
||||||
|
)
|
||||||
|
add_custom_target(tomato-dex DEPENDS "${classes_dex}")
|
||||||
|
set_property(TARGET tomato-dex PROPERTY OUTPUT "${classes_dex}")
|
||||||
|
set_property(TARGET tomato-dex PROPERTY OUTPUT_BASE_NAME "${classes_dex_base_name}")
|
||||||
|
|
||||||
|
# file(GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt)
|
||||||
|
|
||||||
|
sdl_add_to_apk_unaligned(tomato-unaligned-apk
|
||||||
|
APK_IN tomato-apk-linked
|
||||||
|
OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/intermediates"
|
||||||
|
#ASSETS ${RESOURCE_FILES}
|
||||||
|
#NATIVE_LIBS SDL3::SDL3-shared tomato
|
||||||
|
NATIVE_LIBS tomato
|
||||||
|
DEX tomato-dex
|
||||||
|
)
|
||||||
|
|
||||||
|
sdl_apk_align(tomato-aligned-apk tomato-unaligned-apk
|
||||||
|
OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/intermediates"
|
||||||
|
)
|
||||||
|
sdl_apk_sign(tomato-apk tomato-aligned-apk
|
||||||
|
KEYSTORE tomato-debug-keystore
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message("EE SdlAndroid module not found")
|
||||||
|
endif()
|
||||||
|
|
109
android/app/AndroidManifest.xml
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Replace com.test.game with the identifier of your game below, e.g.
|
||||||
|
com.gamemaker.game
|
||||||
|
-->
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="org.libsdl.app.tomato"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0"
|
||||||
|
android:installLocation="auto">
|
||||||
|
|
||||||
|
<!-- OpenGL ES 2.0 -->
|
||||||
|
<uses-feature android:glEsVersion="0x00020000" />
|
||||||
|
|
||||||
|
<!-- Touchscreen support -->
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.touchscreen"
|
||||||
|
android:required="false" />
|
||||||
|
|
||||||
|
<!-- Game controller support -->
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.bluetooth"
|
||||||
|
android:required="false" />
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.gamepad"
|
||||||
|
android:required="false" />
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.usb.host"
|
||||||
|
android:required="false" />
|
||||||
|
|
||||||
|
<!-- External mouse input events -->
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.type.pc"
|
||||||
|
android:required="false" />
|
||||||
|
|
||||||
|
<!-- Audio recording support -->
|
||||||
|
<!-- if you want to capture audio, uncomment this. -->
|
||||||
|
<!-- <uses-feature
|
||||||
|
android:name="android.hardware.microphone"
|
||||||
|
android:required="false" /> -->
|
||||||
|
|
||||||
|
<!-- Camera support -->
|
||||||
|
<!-- if you want to record video, uncomment this. -->
|
||||||
|
<!--
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<!-- Allow downloading to the external storage on Android 5.1 and older -->
|
||||||
|
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22" /> -->
|
||||||
|
|
||||||
|
<!-- Allow access to Bluetooth devices -->
|
||||||
|
<!-- Currently this is just for Steam Controller support and requires setting SDL_HINT_JOYSTICK_HIDAPI_STEAM -->
|
||||||
|
<!-- <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> -->
|
||||||
|
<!-- <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> -->
|
||||||
|
|
||||||
|
<!-- Allow access to the vibrator -->
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
|
||||||
|
<!-- if you want to capture audio, uncomment this. -->
|
||||||
|
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
||||||
|
|
||||||
|
<!-- Create a Java class extending SDLActivity and place it in a
|
||||||
|
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
||||||
|
|
||||||
|
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
|
||||||
|
in the XML below.
|
||||||
|
|
||||||
|
An example Java class can be found in README-android.md
|
||||||
|
-->
|
||||||
|
<application android:label="@string/app_name"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:appCategory="social"
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:theme="@style/AppTheme"
|
||||||
|
android:hardwareAccelerated="true" >
|
||||||
|
|
||||||
|
<!-- setting sdl hints. uses the string value -->
|
||||||
|
<meta-data android:name="SDL_ENV.SDL_ANDROID_BLOCK_ON_PAUSE" android:value="0"/>
|
||||||
|
|
||||||
|
<activity android:name="TomatoActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:alwaysRetainTaskState="true"
|
||||||
|
android:launchMode="singleInstance"
|
||||||
|
android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
|
||||||
|
android:preferMinimalPostProcessing="true"
|
||||||
|
android:exported="true"
|
||||||
|
>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- Let Android know that we can handle some USB devices and should receive this event -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- Drop file event -->
|
||||||
|
<!--
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="*/*" />
|
||||||
|
</intent-filter>
|
||||||
|
-->
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
18
android/app/java/org/libsdl/app/tomato/TomatoActivity.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package org.libsdl.app.tomato;
|
||||||
|
|
||||||
|
import org.libsdl.app.SDLActivity;
|
||||||
|
|
||||||
|
public class TomatoActivity extends SDLActivity {
|
||||||
|
protected String[] getLibraries() {
|
||||||
|
return new String[] {
|
||||||
|
// "SDL3", // we link statically
|
||||||
|
// "SDL3_image",
|
||||||
|
// "SDL3_mixer",
|
||||||
|
// "SDL3_net",
|
||||||
|
// "SDL3_ttf",
|
||||||
|
// "main"
|
||||||
|
"tomato"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
BIN
android/app/play_store_512.png
Normal file
After Width: | Height: | Size: 94 KiB |
6
android/app/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@mipmap/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
|
||||||
|
</adaptive-icon>
|
BIN
android/app/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
android/app/res/mipmap-hdpi/ic_launcher_background.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
android/app/res/mipmap-hdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
android/app/res/mipmap-hdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
android/app/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
android/app/res/mipmap-mdpi/ic_launcher_background.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
android/app/res/mipmap-mdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
android/app/res/mipmap-mdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
android/app/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
android/app/res/mipmap-xhdpi/ic_launcher_background.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
android/app/res/mipmap-xhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
android/app/res/mipmap-xhdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
android/app/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
android/app/res/mipmap-xxhdpi/ic_launcher_background.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
android/app/res/mipmap-xxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
android/app/res/mipmap-xxhdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
android/app/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
android/app/res/mipmap-xxxhdpi/ic_launcher_background.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
android/app/res/mipmap-xxxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
android/app/res/mipmap-xxxhdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 15 KiB |
6
android/app/res/values/colors.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
|
<color name="colorAccent">#FF4081</color>
|
||||||
|
</resources>
|
3
android/app/res/values/strings.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">Tomato</string>
|
||||||
|
</resources>
|
10
android/app/res/values/styles.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<!-- <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> -->
|
||||||
|
<!--<style name="AppTheme" parent="android:Theme.AppCompat">-->
|
||||||
|
<style name="AppTheme" parent="android:Theme">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
2
external/sdl/CMakeLists.txt
vendored
@ -6,6 +6,7 @@ if (NOT TARGET SDL3::SDL3)
|
|||||||
set(SDL_SHARED OFF CACHE INTERNAL "")
|
set(SDL_SHARED OFF CACHE INTERNAL "")
|
||||||
set(SDL_STATIC ON CACHE INTERNAL "")
|
set(SDL_STATIC ON CACHE INTERNAL "")
|
||||||
#TODO: pic ?
|
#TODO: pic ?
|
||||||
|
set(SDL_DISABLE_ANDROID_JAR OFF CACHE INTERNAL "")
|
||||||
|
|
||||||
FetchContent_Declare(SDL3
|
FetchContent_Declare(SDL3
|
||||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
||||||
@ -16,6 +17,7 @@ if (NOT TARGET SDL3::SDL3)
|
|||||||
#GIT_TAG 1103294d33f47ab4c697bb22a9cf27c79c658630 # tip 15-05-2024
|
#GIT_TAG 1103294d33f47ab4c697bb22a9cf27c79c658630 # tip 15-05-2024
|
||||||
#GIT_TAG aacafd62336363077470f678b6217214b3b49473 # tip 28-05-2024
|
#GIT_TAG aacafd62336363077470f678b6217214b3b49473 # tip 28-05-2024
|
||||||
GIT_TAG 5fa9432b7d1c1722de93e1ab46e7a9569a47071e # tip 27-05-2024 - before changes made breaking sdl_image
|
GIT_TAG 5fa9432b7d1c1722de93e1ab46e7a9569a47071e # tip 27-05-2024 - before changes made breaking sdl_image
|
||||||
|
|
||||||
FIND_PACKAGE_ARGS # for the future
|
FIND_PACKAGE_ARGS # for the future
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(SDL3)
|
FetchContent_MakeAvailable(SDL3)
|
||||||
|
18
src/main.cpp
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "./start_screen.hpp"
|
#include "./start_screen.hpp"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@ -23,10 +24,17 @@ int main(int argc, char** argv) {
|
|||||||
args.push_back(argv[i]);
|
args.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
// change current working dir to internal storage
|
||||||
|
std::filesystem::current_path(SDL_AndroidGetInternalStoragePath());
|
||||||
|
#endif
|
||||||
|
|
||||||
// setup hints
|
// setup hints
|
||||||
|
#ifndef __ANDROID__
|
||||||
if (SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1") != SDL_TRUE) {
|
if (SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1") != SDL_TRUE) {
|
||||||
std::cerr << "Failed to set '" << SDL_HINT_VIDEO_ALLOW_SCREENSAVER << "' to 1\n";
|
std::cerr << "Failed to set '" << SDL_HINT_VIDEO_ALLOW_SCREENSAVER << "' to 1\n";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
auto last_time_render = std::chrono::steady_clock::now();
|
auto last_time_render = std::chrono::steady_clock::now();
|
||||||
auto last_time_tick = std::chrono::steady_clock::now();
|
auto last_time_tick = std::chrono::steady_clock::now();
|
||||||
@ -100,7 +108,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
std::unique_ptr<Screen> screen = std::make_unique<StartScreen>(args, renderer.get(), theme);
|
std::unique_ptr<Screen> screen = std::make_unique<StartScreen>(args, renderer.get(), theme);
|
||||||
|
|
||||||
|
bool is_background = false;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
auto new_time = std::chrono::steady_clock::now();
|
auto new_time = std::chrono::steady_clock::now();
|
||||||
@ -125,6 +133,10 @@ int main(int argc, char** argv) {
|
|||||||
if (event.type == SDL_EVENT_QUIT) {
|
if (event.type == SDL_EVENT_QUIT) {
|
||||||
quit = true;
|
quit = true;
|
||||||
break;
|
break;
|
||||||
|
} else if (event.type == SDL_EVENT_WILL_ENTER_BACKGROUND) {
|
||||||
|
is_background = true;
|
||||||
|
} else if (event.type == SDL_EVENT_DID_ENTER_FOREGROUND) {
|
||||||
|
is_background = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screen->handleEvent(event)) {
|
if (screen->handleEvent(event)) {
|
||||||
@ -137,6 +149,10 @@ int main(int argc, char** argv) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_background) {
|
||||||
|
render = false;
|
||||||
|
}
|
||||||
|
|
||||||
// can do both in the same loop
|
// can do both in the same loop
|
||||||
if (render) {
|
if (render) {
|
||||||
ImGui_ImplSDLRenderer3_NewFrame();
|
ImGui_ImplSDLRenderer3_NewFrame();
|
||||||
|
@ -49,6 +49,7 @@ StartScreen::StartScreen(const std::vector<std::string_view>& args, SDL_Renderer
|
|||||||
std::cerr << "TOMATO error: unknown cli arg: '" << args.at(ai) << "'\n";
|
std::cerr << "TOMATO error: unknown cli arg: '" << args.at(ai) << "'\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Screen* StartScreen::render(float, bool&) {
|
Screen* StartScreen::render(float, bool&) {
|
||||||
@ -182,6 +183,7 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ImGui::Button("load", {60, 25})) {
|
if (ImGui::Button("load", {60, 25})) {
|
||||||
|
|
||||||
auto new_screen = std::make_unique<MainScreen>(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths);
|
auto new_screen = std::make_unique<MainScreen>(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths);
|
||||||
return new_screen.release();
|
return new_screen.release();
|
||||||
}
|
}
|
||||||
|