diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 102a50a..9a81f74 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,50 @@ jobs: echo "version=$(sed -n 's/.*\(.*\)<\/TargetRaylibTag>.*/\1/p' Raylib-cs/Raylib-cs.csproj)">> ${GITHUB_OUTPUT} echo "pkgversion=$(sed -n 's/.*\(.*\)<\/PackageVersion>.*/\1/p' Raylib-cs/Raylib-cs.csproj)">> ${GITHUB_OUTPUT} + build-android: + runs-on: ubuntu-latest + needs: prepare + strategy: + matrix: + name: [arm, arm64, x86, x64] + include: + - name: arm + arch: armeabi-v7a + - name: arm64 + arch: arm64-v8a + - name: x86 + arch: x86 + - name: x64 + arch: x86_64 + steps: + - name: checkout repository + uses: actions/checkout@v3 + + - name: build raylib + env: + version: ${{ needs.prepare.outputs.version }} + run: | + curl -Lso raylib.zip https://github.com/raysan5/raylib/archive/refs/tags/${version}.zip + unzip -qq raylib.zip + pushd raylib-${version}; patch -p1 < ../android.patch; popd + cmake -S raylib-${version} \ + -B build \ + -D CMAKE_BUILD_TYPE=Release \ + -D BUILD_SHARED_LIBS=ON \ + -D BUILD_EXAMPLES=OFF \ + -D CMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \ + -D PLATFORM=Android \ + -D ANDROID_ABI=${{ matrix.arch }} + cmake --build build --config Release + file build/raylib/libraylib.so # TODO: remove me + + - name: upload build + uses: actions/upload-artifact@v3 + with: + name: android-${{ matrix.name }} + path: build/raylib/libraylib.so + if-no-files-found: error + build-linux: runs-on: ubuntu-latest needs: prepare @@ -130,6 +174,7 @@ jobs: runs-on: ubuntu-latest needs: - prepare + - build-android - build-linux - build-osx - build-windows @@ -137,6 +182,26 @@ jobs: - name: checkout repository uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: android-arm + path: Raylib-cs/runtimes/android-arm/native + + - uses: actions/download-artifact@v3 + with: + name: android-arm64 + path: Raylib-cs/runtimes/android-arm64/native + + - uses: actions/download-artifact@v3 + with: + name: android-x86 + path: Raylib-cs/runtimes/android-x86/native + + - uses: actions/download-artifact@v3 + with: + name: android-x64 + path: Raylib-cs/runtimes/android-x64/native + - uses: actions/download-artifact@v3 with: name: linux-x64 diff --git a/android.patch b/android.patch new file mode 100644 index 0000000..6c4987e --- /dev/null +++ b/android.patch @@ -0,0 +1,24 @@ +diff --git a/src/rcore.c b/src/rcore.c +index eae4951..76e26ad 100644 +--- a/src/rcore.c ++++ b/src/rcore.c +@@ -709,7 +709,18 @@ const char *TextFormat(const char *text, ...); // Formatting of text with + #if defined(PLATFORM_ANDROID) + // To allow easier porting to android, we allow the user to define a + // main function which we call from android_main, defined by ourselves +-extern int main(int argc, char *argv[]); ++ ++typedef void (*RaylibAndroidCallback)(); ++static RaylibAndroidCallback _androidCallback = NULL; ++ ++void RaylibSetAndroidCallback(RaylibAndroidCallback callback) { ++ _androidCallback = callback; ++} ++ ++int main(int argc, char *argv[]) { ++ while(_androidCallback == NULL) {} ++ _androidCallback(); ++} + + void android_main(struct android_app *app) + {