Skip to content

Depend on natives:assemble before running classes task #63

Depend on natives:assemble before running classes task

Depend on natives:assemble before running classes task #63

Workflow file for this run

name: Build
on: push
env:
LIB_NAME: libImagineBreaker
PATH_TO_CODE_FOLDER: natives/src/main/c
CODE_FILE: zone_rong_imaginebreaker_ImagineBreaker
PATH_TO_CODE: natives/src/main/c/zone_rong_imaginebreaker_ImagineBreaker
PATH_TO_CODE_WIN: natives\src\main\c\zone_rong_imaginebreaker_ImagineBreaker
jobs:
linux_compile:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Make Directory
run: mkdir output
- name: Install Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: current
- name: Gradle Build
run: ./gradlew build
- name: Install GCC-Multilib
run: sudo apt-get install gcc-multilib
- name: Compile for x64
run: gcc -c -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux ${{ env.PATH_TO_CODE }}.c -o ${{ env.PATH_TO_CODE }}_x64.o
- name: Compile for x86
run: gcc -m32 -c -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux ${{ env.PATH_TO_CODE }}.c -o ${{ env.PATH_TO_CODE }}_x86.o
- name: Link for x64
run: gcc -shared -fPIC -o output/${{ env.LIB_NAME }}_x64.so ${{ env.PATH_TO_CODE }}_x64.o -lc
- name: Link for x86
run: gcc -m32 -shared -fPIC -o output/${{ env.LIB_NAME }}_x86.so ${{ env.PATH_TO_CODE }}_x86.o -lc
- name: Upload Natives
uses: actions/upload-artifact@v3
with:
name: native
path: output/
windows_compile:
strategy:
matrix:
arch: [[x64, x64], [x86, x86], [amd64_arm64, arm64]]
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Make Directory
run: mkdir output
- name: Install Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: current
- name: Gradle Build
run: ./gradlew build
- name: Install MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch[0] }}
- name: Compile and Link for ${{ matrix.arch[1] }}
run: cl.exe -LD -I${{ env.JAVA_HOME }}\include -I${{ env.JAVA_HOME }}\include\win32 ${{ env.PATH_TO_CODE_WIN }}.c -link -out:output\${{ env.LIB_NAME }}_${{ matrix.arch[1] }}.dll
- name: Upload Natives
uses: actions/upload-artifact@v3
with:
name: native
path: output/
mac_os_compile:
strategy:
matrix:
arch: [[x86_64, x64], [i386, x86], [arm64, arm64]]
runs-on: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Make Directory
run: mkdir output
- name: Install Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: current
- name: Gradle Build
run: ./gradlew build
- name: Compile
run: gcc -c -arch ${{ matrix.arch[0] }} -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin ${{ env.PATH_TO_CODE }}.c -o ${{ env.PATH_TO_CODE }}_${{ matrix.arch[1] }}.o
- name: Link
run: gcc -dynamiclib -o output/${{ env.LIB_NAME }}_${{ matrix.arch[1] }}.dylib ${{ env.PATH_TO_CODE }}_${{ matrix.arch[1] }}.o -lc
- name: Upload Natives
uses: actions/upload-artifact@v3
with:
name: native
path: output/
android_compile:
strategy:
matrix:
arch: [[armeabi-v7a, arm], [arm64-v8a, arm64], [x86, x86], [x86_64, x64]]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Make Directory
run: mkdir output
- name: Install NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r25c
- name: Create Android MakeFile
run: printf "LOCAL_PATH := \$(call my-dir)\ninclude \$(CLEAR_VARS)\nLOCAL_MODULE := ImagineBreaker_android_${{ matrix.arch[1] }}\nLOCAL_SRC_FILES := ${{ env.CODE_FILE }}.c\ninclude \$(BUILD_SHARED_LIBRARY)" > ${{ env.PATH_TO_CODE_FOLDER }}/Android.mk
- name: Compile and Link
run: cd ${{ env.PATH_TO_CODE_FOLDER }} && ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk APP_PLATFORM=android-21 APP_ABI=${{ env.matrix.arch[0] }}
- name: Upload Natives
uses: actions/upload-artifact@v3
with:
name: native
path: ${{ env.PATH_TO_CODE_FOLDER }}/libs/${{ matrix.arch[0] }}