Create a functional CMake project using androidbuild.sh

This commit is contained in:
Anonymous Maarten 2024-06-17 23:46:08 +02:00
parent 8ab1ffca8a
commit 1a68d846de
4 changed files with 31 additions and 10 deletions

View File

@ -37,16 +37,28 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- name: Build app (Gradle)
- name: Create Gradle project
if: ${{ matrix.platform.gradle }}
run: |
ln -s ${{ github.workspace }} ${{ github.workspace }}/android-project/app/jni/SDL
cd android-project
build-scripts/androidbuild.sh org.libsdl.testcontroller src/test/SDL_test_* test/testcontroller.c test/gamepad* test/testutils*
echo ""
echo "Project contents:"
echo ""
find "build/org.libsdl.testcontroller"
- name: Build app (Gradle & ndk-build)
if: ${{ matrix.platform.gradle }}
run: |
cd build/org.libsdl.testcontroller
./gradlew -i assembleRelease
- name: Build app (Gradle & CMake)
if: ${{ matrix.platform.gradle }}
run: |
cd build/org.libsdl.testcontroller
./gradlew -i assembleRelease -PBUILD_WITH_CMAKE=1
# - name: Build library (Gradle)
# if: ${{ matrix.platform.gradle }}
# run: |
# cd android-project
# cd build/org.libsdl.testcontroller
# ./gradlew -i assembleRelease -PBUILD_AS_LIBRARY=1
- name: Setup (CMake)
if: ${{ matrix.platform.cmake }}

View File

@ -12,7 +12,7 @@ LOCAL_MODULE := SDL3
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/src
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := \
$(subst $(LOCAL_PATH)/,, \

View File

@ -1,3 +1,4 @@
def buildWithCMake = project.hasProperty('BUILD_WITH_CMAKE');
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
def buildAsApplication = !buildAsLibrary
if (buildAsApplication) {
@ -45,11 +46,14 @@ android {
jniLibs.srcDir 'libs'
}
externalNativeBuild {
// ndkBuild {
// path 'jni/Android.mk'
// }
cmake {
path 'jni/CMakeLists.txt'
if (buildWithCMake) {
cmake {
path 'jni/CMakeLists.txt'
}
} else {
ndkBuild {
path 'jni/Android.mk'
}
}
}

View File

@ -61,8 +61,13 @@ else
cp -r $SDLPATH/include $BUILDPATH/app/jni/SDL
fi
cp -r $SDLPATH/LICENSE.txt $BUILDPATH/app/jni/SDL
cp -r $SDLPATH/README.md $BUILDPATH/app/jni/SDL
cp -r $SDLPATH/Android.mk $BUILDPATH/app/jni/SDL
cp -r $SDLPATH/CMakeLists.txt $BUILDPATH/app/jni/SDL
cp -r $SDLPATH/cmake $BUILDPATH/app/jni/SDL
sed -i -e "s|YourSourceHere.c|$MKSOURCES|g" $BUILDPATH/app/jni/src/Android.mk
sed -i -e "s|YourSourceHere.c|$MKSOURCES|g" $BUILDPATH/app/jni/src/CMakeLists.txt
sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/app/build.gradle
sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/app/src/main/AndroidManifest.xml