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: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '17' java-version: '17'
- name: Build app (Gradle) - name: Create Gradle project
if: ${{ matrix.platform.gradle }} if: ${{ matrix.platform.gradle }}
run: | run: |
ln -s ${{ github.workspace }} ${{ github.workspace }}/android-project/app/jni/SDL build-scripts/androidbuild.sh org.libsdl.testcontroller src/test/SDL_test_* test/testcontroller.c test/gamepad* test/testutils*
cd android-project 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 ./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) # - name: Build library (Gradle)
# if: ${{ matrix.platform.gradle }} # if: ${{ matrix.platform.gradle }}
# run: | # run: |
# cd android-project # cd build/org.libsdl.testcontroller
# ./gradlew -i assembleRelease -PBUILD_AS_LIBRARY=1 # ./gradlew -i assembleRelease -PBUILD_AS_LIBRARY=1
- name: Setup (CMake) - name: Setup (CMake)
if: ${{ matrix.platform.cmake }} if: ${{ matrix.platform.cmake }}

View File

@ -12,7 +12,7 @@ LOCAL_MODULE := SDL3
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/src 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 := \ LOCAL_SRC_FILES := \
$(subst $(LOCAL_PATH)/,, \ $(subst $(LOCAL_PATH)/,, \

View File

@ -1,3 +1,4 @@
def buildWithCMake = project.hasProperty('BUILD_WITH_CMAKE');
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY'); def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
def buildAsApplication = !buildAsLibrary def buildAsApplication = !buildAsLibrary
if (buildAsApplication) { if (buildAsApplication) {
@ -45,11 +46,14 @@ android {
jniLibs.srcDir 'libs' jniLibs.srcDir 'libs'
} }
externalNativeBuild { externalNativeBuild {
// ndkBuild { if (buildWithCMake) {
// path 'jni/Android.mk' cmake {
// } path 'jni/CMakeLists.txt'
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 cp -r $SDLPATH/include $BUILDPATH/app/jni/SDL
fi 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/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/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/build.gradle
sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/app/src/main/AndroidManifest.xml sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/app/src/main/AndroidManifest.xml