From c26afcb45ee5b22b9541496ae88ae5eb5f7a3151 Mon Sep 17 00:00:00 2001 From: k8ie Date: Tue, 22 Oct 2024 22:16:05 +0200 Subject: [PATCH 01/10] Add ARM Linux target --- arc-core/build.gradle | 7 ++++++- backends/backend-sdl/build.gradle | 31 ++++++++++++++++++++----------- extensions/freetype/build.gradle | 5 +++-- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/arc-core/build.gradle b/arc-core/build.gradle index 5dbf5f85..6fb69141 100644 --- a/arc-core/build.gradle +++ b/arc-core/build.gradle @@ -33,6 +33,11 @@ jnigen{ cppFlags = "-DWITH_MINIAUDIO " + cppFlags libraries += " -lpthread -lrt -lm -ldl" } + add(Linux, x64, ARM){ + cppIncludes += ["soloud/src/backend/miniaudio/*.cpp"] + cppFlags = "-DWITH_MINIAUDIO " + cppFlags + libraries += " -lpthread -lrt -lm -ldl" + } add(Windows, x32){ cppIncludes += ["soloud/src/backend/miniaudio/*.cpp"] cppFlags = "-msse -DWITH_MINIAUDIO " + cppFlags @@ -118,7 +123,7 @@ task preJni{ task postJni{ doLast{ copy{ - from "libs/linux64", "libs/windows32", "libs/windows64", "libs/macosx64" + from "libs/linux64", "libs/linuxarm64", "libs/windows32", "libs/windows64", "libs/macosx64" into "../natives/natives-desktop/libs" include "**" } diff --git a/backends/backend-sdl/build.gradle b/backends/backend-sdl/build.gradle index 9f12325b..6f0fc288 100644 --- a/backends/backend-sdl/build.gradle +++ b/backends/backend-sdl/build.gradle @@ -1,5 +1,5 @@ sourceSets.main.java.srcDirs = ["src"] -sourceSets.main.resources.srcDirs = ["libs/linux64", "libs/macosx64","libs/windows32", "libs/windows64", "libs/openal"] +sourceSets.main.resources.srcDirs = ["libs/linux64", "libs/linuxarm64", "libs/macosx64","libs/windows32", "libs/windows64", "libs/openal"] dependencies { testImplementation libraries.jnigen @@ -79,15 +79,6 @@ jnigen{ cIncludes = ["*.c", "glew-2.2.0/src/glew.c"] headerDirs += ["glew-2.2.0/include"] } - add(Linux, x64){ - cppFlags += " " + execCmd("sdl2-config --cflags") - cFlags = cppFlags - //NOTE: for this to statically link properly, you need to add -L/path/to/folder/with/custom/libSDL2.a - //where this folder contains a custom build of SDL2 with the -fPIC flag (added to the makefile in the cflags section after configure) - //--static-libs and ?.replace("-lSDL2", "-l:libSDL2.a") - libraries = execCmd("sdl2-config --libs") + " -Wl,-Bdynamic -lGL " - linkerFlags = "-shared -m64" - } add(Windows, x64){ def path = "SDL2-$sdlVersion/x86_64-w64-mingw32" def root = "$rootDir/backends/backend-sdl/jni" @@ -113,6 +104,15 @@ jnigen{ linkerFlags = "-shared -arch x86_64 -mmacosx-version-min=10.9 -stdlib=libc++" libraries = "/usr/local/lib/libSDL2.a -lm -liconv -Wl,-framework,CoreAudio -Wl,-framework,CoreHaptics -Wl,-weak_framework,GameController -Wl,-framework,OpenGL,-weak_framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal /usr/local/lib/libGLEW.a" } + add(Linux, x64){ + cppFlags += " " + execCmd("sdl2-config --cflags") + cFlags = cppFlags + //NOTE: for this to statically link properly, you need to add -L/path/to/folder/with/custom/libSDL2.a + //where this folder contains a custom build of SDL2 with the -fPIC flag (added to the makefile in the cflags section after configure) + //--static-libs and ?.replace("-lSDL2", "-l:libSDL2.a") + libraries = execCmd("sdl2-config --libs") + " -Wl,-Bdynamic -lGL " + linkerFlags = "-shared -m64" + } }else{ //doesn't work on CI, have to use native M1 @@ -122,6 +122,15 @@ jnigen{ //execCmd("sdl2-config --static-libs") + " -Wl,-framework,OpenGL" libraries = "/usr/local/lib/libSDL2.a -lm -liconv -Wl,-framework,CoreAudio -Wl,-weak_framework,GameController -Wl,-framework,OpenGL,-weak_framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal /usr/local/lib/libGLEW.a" } + add(Linux, x64, ARM){ + cppFlags += " " + execCmd("sdl2-config --cflags") + cFlags = cppFlags + //NOTE: for this to statically link properly, you need to add -L/path/to/folder/with/custom/libSDL2.a + //where this folder contains a custom build of SDL2 with the -fPIC flag (added to the makefile in the cflags section after configure) + //--static-libs and ?.replace("-lSDL2", "-l:libSDL2.a") + libraries = execCmd("sdl2-config --libs") + " -Wl,-Bdynamic -lGL " + linkerFlags = "-shared -m64" + } } } @@ -130,4 +139,4 @@ getTasksByName("jnigen", true).each{ it.dependsOn preJni it.dependsOn classes it.dependsOn aproj(":arc-core").getTasksByName("compileJava", true) -} \ No newline at end of file +} diff --git a/extensions/freetype/build.gradle b/extensions/freetype/build.gradle index 04362297..91ff19cd 100644 --- a/extensions/freetype/build.gradle +++ b/extensions/freetype/build.gradle @@ -34,6 +34,7 @@ jnigen{ add(Windows, x32) add(Windows, x64) add(Linux, x64) + add(Linux, x64, ARM) add(MacOsX, x64) add(MacOsX, x64, ARM){ cFlags = cppFlags = cppFlags.replace("x86_64", "arm64") @@ -81,7 +82,7 @@ task preJni{ task postJni{ doLast{ copy{ - from "libs/linux64", "libs/windows32", "libs/windows64", "libs/macosx64" + from "libs/linux64", "libs/linuxarm64", "libs/windows32", "libs/windows64", "libs/macosx64" into "../../natives/natives-freetype-desktop/libs" include "**" } @@ -107,4 +108,4 @@ jnigenBuild.finalizedBy postJni getTasksByName("jnigen", true).each{ it.dependsOn preJni -} \ No newline at end of file +} From 17516aee98558f88e5a86cf9b027a86b288de994 Mon Sep 17 00:00:00 2001 From: k8ie Date: Sun, 27 Oct 2024 15:14:18 +0100 Subject: [PATCH 02/10] Add ARM libraries to CI --- .github/workflows/natives.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/natives.yml b/.github/workflows/natives.yml index 68c9787c..1697cc0a 100644 --- a/.github/workflows/natives.yml +++ b/.github/workflows/natives.yml @@ -26,12 +26,14 @@ jobs: name: Arc-core desktop natives path: | natives/natives-desktop/libs/libarc64.so + natives/natives-desktop/libs/libarcarm64.so natives/natives-desktop/libs/arc.dll natives/natives-desktop/libs/arc64.dll backends/backend-sdl/libs/linux64/libsdl-arc64.so backends/backend-sdl/libs/windows32/sdl-arc.dll backends/backend-sdl/libs/windows64/sdl-arc64.dll natives/natives-freetype-desktop/libs/libarc-freetype64.so + natives/natives-freetype-desktop/libs/libarcarm-freetype64.so natives/natives-freetype-desktop/libs/arc-freetype.dll natives/natives-freetype-desktop/libs/arc-freetype64.dll - name: Upload Android natives From a5ccc5e90c11f2e6d445c21cdb7d76878e69e22c Mon Sep 17 00:00:00 2001 From: k8ie Date: Sun, 27 Oct 2024 15:27:27 +0100 Subject: [PATCH 03/10] Add ARM dependencies --- .github/workflows/natives.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/natives.yml b/.github/workflows/natives.yml index 1697cc0a..de1b6b07 100644 --- a/.github/workflows/natives.yml +++ b/.github/workflows/natives.yml @@ -12,7 +12,7 @@ jobs: with: java-version: 1.8 - name: Install dependencies - run: sudo apt install g++-mingw-w64 g++-mingw-w64-i686 g++-mingw-w64-x86-64 gcc-mingw-w64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 libasound2-dev libdrm-dev libsdl2-dev libgbm-dev + run: sudo apt install g++-mingw-w64 g++-mingw-w64-i686 g++-mingw-w64-x86-64 gcc-mingw-w64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 libasound2-dev libdrm-dev libsdl2-dev libgbm-dev binutils-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-aarch64-linux-gnu - name: Set env run: echo "NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV - name: Build natives From 16a4b61b8600360e781a471f7f193f52b58cd95b Mon Sep 17 00:00:00 2001 From: k8ie Date: Sun, 27 Oct 2024 15:37:51 +0100 Subject: [PATCH 04/10] Fix ARM Freetype lib name --- .github/workflows/natives.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/natives.yml b/.github/workflows/natives.yml index de1b6b07..36225cd1 100644 --- a/.github/workflows/natives.yml +++ b/.github/workflows/natives.yml @@ -33,7 +33,7 @@ jobs: backends/backend-sdl/libs/windows32/sdl-arc.dll backends/backend-sdl/libs/windows64/sdl-arc64.dll natives/natives-freetype-desktop/libs/libarc-freetype64.so - natives/natives-freetype-desktop/libs/libarcarm-freetype64.so + natives/natives-freetype-desktop/libs/libarc-freetypearm64.so natives/natives-freetype-desktop/libs/arc-freetype.dll natives/natives-freetype-desktop/libs/arc-freetype64.dll - name: Upload Android natives From baf9e2e92af1e4e8d9f7acb007363c8ba1df55fb Mon Sep 17 00:00:00 2001 From: k8ie Date: Sun, 27 Oct 2024 17:11:17 +0100 Subject: [PATCH 05/10] Add a Docker-based ARM SDL builder --- .github/workflows/natives.yml | 18 ++++++++++++++++++ Dockerfile | 16 ++++++++++++++++ backends/backend-sdl/build.gradle | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.github/workflows/natives.yml b/.github/workflows/natives.yml index 36225cd1..e67c7057 100644 --- a/.github/workflows/natives.yml +++ b/.github/workflows/natives.yml @@ -20,6 +20,23 @@ jobs: ./gradlew arc-core:jnigenBuild ./gradlew extensions:freetype:jnigenBuild ./gradlew backends:backend-sdl:jnigenBuild + # ARM SDL build + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build ARM SDL Docker Image + uses: docker/build-push-action@v6 + with: + tags: arc-arm-sdl:latest + load: true + platforms: linux/arm64 + - uses: shrink/actions-docker-extract@v3 + id: extract + with: + image: arc-arm-sdl:latest + path: /home/Arc/backends/backend-sdl/libs/linuxarm64/libsdl-arcarm64.so + destination: backends/backend-sdl/libs/linuxarm64 - name: Upload natives uses: actions/upload-artifact@v4 with: @@ -30,6 +47,7 @@ jobs: natives/natives-desktop/libs/arc.dll natives/natives-desktop/libs/arc64.dll backends/backend-sdl/libs/linux64/libsdl-arc64.so + backends/backend-sdl/libs/linuxarm64/libsdl-arcarm64.so backends/backend-sdl/libs/windows32/sdl-arc.dll backends/backend-sdl/libs/windows64/sdl-arc64.dll natives/natives-freetype-desktop/libs/libarc-freetype64.so diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..7c830e54 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM docker.io/azul/zulu-openjdk:8-latest + +# Install dependencies +RUN apt update && apt install -y libasound2-dev libdrm-dev libsdl2-dev libgbm-dev ant binutils g++ + +# Create symlinks +# For some reason JNI looks for binaries prefixed with aarch64-linux-gnu- even when they're not set in build-linuxarm64.xml +#RUN ln -s /aarch64-linux-gnu-g++ +#RUN ln -s /aarch64-linux-gnu-strip + +# Copy the repository +COPY . /home/Arc +WORKDIR /home/Arc + +# Run the SDL build +RUN ./gradlew backends:backend-sdl:jnigenBuildLinuxARM64 diff --git a/backends/backend-sdl/build.gradle b/backends/backend-sdl/build.gradle index 6f0fc288..1bd91783 100644 --- a/backends/backend-sdl/build.gradle +++ b/backends/backend-sdl/build.gradle @@ -129,7 +129,7 @@ jnigen{ //where this folder contains a custom build of SDL2 with the -fPIC flag (added to the makefile in the cflags section after configure) //--static-libs and ?.replace("-lSDL2", "-l:libSDL2.a") libraries = execCmd("sdl2-config --libs") + " -Wl,-Bdynamic -lGL " - linkerFlags = "-shared -m64" + linkerFlags = "-shared" } } From 9cb0711397ca3d6145b9e77334001804626631f9 Mon Sep 17 00:00:00 2001 From: k8ie Date: Sun, 27 Oct 2024 17:12:27 +0100 Subject: [PATCH 06/10] Not the case --- Dockerfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7c830e54..e4de7fae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,6 @@ FROM docker.io/azul/zulu-openjdk:8-latest # Install dependencies RUN apt update && apt install -y libasound2-dev libdrm-dev libsdl2-dev libgbm-dev ant binutils g++ -# Create symlinks -# For some reason JNI looks for binaries prefixed with aarch64-linux-gnu- even when they're not set in build-linuxarm64.xml -#RUN ln -s /aarch64-linux-gnu-g++ -#RUN ln -s /aarch64-linux-gnu-strip - # Copy the repository COPY . /home/Arc WORKDIR /home/Arc From 19786340f98d9f91b0c17020f563b8503b222d47 Mon Sep 17 00:00:00 2001 From: k8ie Date: Sun, 27 Oct 2024 17:13:45 +0100 Subject: [PATCH 07/10] Add missing name --- .github/workflows/natives.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/natives.yml b/.github/workflows/natives.yml index e67c7057..fcc331dd 100644 --- a/.github/workflows/natives.yml +++ b/.github/workflows/natives.yml @@ -31,7 +31,8 @@ jobs: tags: arc-arm-sdl:latest load: true platforms: linux/arm64 - - uses: shrink/actions-docker-extract@v3 + - name: Extract ARM SDL library from the container + uses: shrink/actions-docker-extract@v3 id: extract with: image: arc-arm-sdl:latest From e599371fae2e3dd084653454b6389906996a4fe8 Mon Sep 17 00:00:00 2001 From: k8ie Date: Sun, 27 Oct 2024 17:27:10 +0100 Subject: [PATCH 08/10] Add missing dependency --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e4de7fae..5562bc09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM docker.io/azul/zulu-openjdk:8-latest # Install dependencies -RUN apt update && apt install -y libasound2-dev libdrm-dev libsdl2-dev libgbm-dev ant binutils g++ +RUN apt update && apt install -y libasound2-dev libdrm-dev libsdl2-dev libgbm-dev libglew-dev ant binutils g++ # Copy the repository COPY . /home/Arc From 96374a6ab13ff9e013e4dc02b742f3ce3e543aa1 Mon Sep 17 00:00:00 2001 From: k8ie Date: Sun, 27 Oct 2024 18:09:44 +0100 Subject: [PATCH 09/10] Add filedialogs build --- extensions/filedialogs/build.gradle | 3 +- .../filedialogs/jni/build-linuxarm64.xml | 176 ++++++++++++++++++ 2 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 extensions/filedialogs/jni/build-linuxarm64.xml diff --git a/extensions/filedialogs/build.gradle b/extensions/filedialogs/build.gradle index deca452e..f551751f 100644 --- a/extensions/filedialogs/build.gradle +++ b/extensions/filedialogs/build.gradle @@ -20,6 +20,7 @@ jnigen{ libraries = " -lcomdlg32 -lole32" } add(Linux, x64) + add(Linux, x64, ARM) add(MacOsX, x64) add(MacOsX, x64, ARM){ cFlags = cppFlags = cppFlags.replace("x86_64", "arm64") @@ -48,7 +49,7 @@ task preJni{ task postJni{ doLast{ copy{ - from "libs/linux64", "libs/windows32", "libs/windows64", "libs/macosx64" + from "libs/linux64", "libs/linuxarm64", "libs/windows32", "libs/windows64", "libs/macosx64" into "../../natives/natives-filedialogs/libs" include "**" } diff --git a/extensions/filedialogs/jni/build-linuxarm64.xml b/extensions/filedialogs/jni/build-linuxarm64.xml new file mode 100644 index 00000000..cbe232ca --- /dev/null +++ b/extensions/filedialogs/jni/build-linuxarm64.xml @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From dd043b8d58116a08468bbb6912022aae04a923d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kate=C5=99ina=20Medv=C4=9Bdov=C3=A1?= Date: Sun, 17 Nov 2024 11:53:44 +0100 Subject: [PATCH 10/10] Delete extensions/filedialogs/jni/build-linuxarm64.xml --- .../filedialogs/jni/build-linuxarm64.xml | 176 ------------------ 1 file changed, 176 deletions(-) delete mode 100644 extensions/filedialogs/jni/build-linuxarm64.xml diff --git a/extensions/filedialogs/jni/build-linuxarm64.xml b/extensions/filedialogs/jni/build-linuxarm64.xml deleted file mode 100644 index cbe232ca..00000000 --- a/extensions/filedialogs/jni/build-linuxarm64.xml +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -