Skip to content

Commit

Permalink
android: create android project in create-android-project.py python s…
Browse files Browse the repository at this point in the history
…cript

This script supersedes androidbuild.sh, and also supports using a SDL3 prefab archive
  • Loading branch information
madebr committed Jul 4, 2024
1 parent 9f8dffb commit af2d2ba
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 123 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ jobs:
- name: Create Gradle project
if: ${{ matrix.platform.gradle }}
run: |
build-scripts/androidbuild.sh org.libsdl.testspriteminimal test/testspriteminimal.c test/icon.h
python build-scripts/create-android-project.py \
--output "build" \
--variant copy \
org.libsdl.testspriteminimal \
test/testspriteminimal.c test/icon.h
echo ""
echo "Project contents:"
echo ""
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,72 @@ jobs:
with:
name: android
path: '${{ github.workspace }}/dist'

android-verify:
needs: [android, src]
runs-on: ubuntu-latest
steps:
- name: 'Set up Python'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: 'Setup Android NDK'
uses: nttld/setup-ndk@v1
id: setup_ndk
with:
local-cache: true
ndk-version: r21e
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: 'Download source archives'
uses: actions/download-artifact@v4
with:
name: sources
path: '${{ github.workspace }}'
- name: 'Download Android .aar archive'
uses: actions/download-artifact@v4
with:
name: android
path: '${{ github.workspace }}'
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
id: src
run: |
mkdir -p /tmp/tardir
tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
- name: 'Create gradle project'
id: create-gradle-project
run: |
python ${{ steps.src.outputs.path }}/build-scripts/create-android-project.py \
org.libsdl.testspriteminimal \
${{ steps.src.outputs.path }}/test/testspriteminimal.c \
${{ steps.src.outputs.path }}/test/icon.h \
--variant aar \
--output "/tmp/projects"
echo "path=/tmp/projects/org.libsdl.testspriteminimal" >>$GITHUB_OUTPUT
echo ""
echo "Project contents:"
echo ""
find "/tmp/projects/org.libsdl.testspriteminimal"
- name: 'Remove SDL sources to make sure they are not used'
run: |
rm -rf "${{ steps.src.outputs.path }}"
- name: 'Copy aar into project'
run: |
cp "${{ github.workspace }}/${{ needs.android.outputs.android-aar }}" "${{ steps.create-gradle-project.outputs.path }}/app/libs"
echo ""
echo "Project contents:"
echo ""
find "${{ steps.create-gradle-project.outputs.path }}"
- name: 'Build app (Gradle & CMake)'
run: |
cd "${{ steps.create-gradle-project.outputs.path }}"
./gradlew -i assembleRelease
- name: 'Build app (Gradle & ndk-build)'
run: |
cd "${{ steps.create-gradle-project.outputs.path }}"
./gradlew -i assembleRelease -PBUILD_WITH_CMAKE=1
5 changes: 0 additions & 5 deletions android-project/app/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ cmake_minimum_required(VERSION 3.6)

project(GAME)

# armeabi-v7a requires cpufeatures library
# include(AndroidNdkModules)
# android_ndk_import_module_cpufeatures()


# SDL sources are in a subfolder named "SDL"
add_subdirectory(SDL)

Expand Down
11 changes: 6 additions & 5 deletions android-project/app/jni/src/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ include $(CLEAR_VARS)

LOCAL_MODULE := main

SDL_PATH := ../SDL
# Add your application source files here...
LOCAL_SRC_FILES := \
YourSourceHere.c

LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include
SDL_PATH := ../SDL # SDL

# Add your application source files here...
LOCAL_SRC_FILES := YourSourceHere.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include # SDL

LOCAL_SHARED_LIBRARIES := SDL3

LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid # SDL

include $(BUILD_SHARED_LIBRARY)
106 changes: 0 additions & 106 deletions build-scripts/androidbuild.sh

This file was deleted.

2 changes: 1 addition & 1 deletion build-scripts/build-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def create_android_archives(self, android_api: int, android_home: Path, android_
zip_object.write(test_library, arcname=f"prefab/modules/{self.project}_test/libs/android.{android_abi}/lib{self.project}_test.a")
zip_object.writestr(f"prefab/modules/{self.project}_test/libs/android.{android_abi}/abi.json", self.get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=False))

self.artifacts[f"android-prefab-aar"] = aar_path
self.artifacts[f"android-aar"] = aar_path

@classmethod
def extract_sdl_version(cls, root: Path, project: str):
Expand Down
Loading

0 comments on commit af2d2ba

Please sign in to comment.