Skip to content

Commit

Permalink
build: add support for windows-arm64 & macos-arm64. Close LWJGL#601
Browse files Browse the repository at this point in the history
  • Loading branch information
Spasi authored and kalkafox committed Sep 14, 2021
1 parent 330c019 commit 8a4e9ef
Show file tree
Hide file tree
Showing 10 changed files with 749 additions and 56 deletions.
478 changes: 478 additions & 0 deletions build.gradle.kts

Large diffs are not rendered by default.

103 changes: 78 additions & 25 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1199,17 +1199,35 @@
<!-- GLFW -->
<release-module package="org.lwjgl.glfw" name="glfw" title="GLFW" if:true="${binding.glfw}">
<natives>
<get-release url="linux/x64/libglfw.so"/>
<get-release url="linux/x64/libglfw_wayland.so"/>
<get-release url="macosx/x64/libglfw.dylib"/>
<get-release url="windows/x64/glfw.dll"/>
<get-release url="windows/x86/glfw32.dll"/>

<get-release url="linux/x64/libglfw.so.git"/>
<get-release url="linux/x64/libglfw_wayland.so.git"/>
<get-release url="macosx/x64/libglfw.dylib.git"/>
<get-release url="windows/x64/glfw.dll.git"/>
<get-release url="windows/x86/glfw32.dll.git"/>
<get-release platform="linux" arch="x64" file="libglfw.so"/>
<get-release platform="linux" arch="x64" file="libglfw.so.git"/>
<get-release platform="linux" arch="x64" file="libglfw_wayland.so"/>
<get-release platform="linux" arch="x64" file="libglfw_wayland.so.git"/>

<get-release platform="linux" arch="arm64" file="libglfw.so"/>
<get-release platform="linux" arch="arm64" file="libglfw.so.git"/>
<get-release platform="linux" arch="arm64" file="libglfw_wayland.so"/>
<get-release platform="linux" arch="arm64" file="libglfw_wayland.so.git"/>

<get-release platform="linux" arch="arm32" file="libglfw.so"/>
<get-release platform="linux" arch="arm32" file="libglfw.so.git"/>
<get-release platform="linux" arch="arm32" file="libglfw_wayland.so"/>
<get-release platform="linux" arch="arm32" file="libglfw_wayland.so.git"/>

<get-release platform="macos" arch="x64" file="libglfw.dylib"/>
<get-release platform="macos" arch="x64" file="libglfw.dylib.git"/>

<get-release platform="macos" arch="arm64" file="libglfw.dylib"/>
<get-release platform="macos" arch="arm64" file="libglfw.dylib.git"/>

<get-release platform="windows" arch="x64" file="glfw.dll"/>
<get-release platform="windows" arch="x64" file="glfw.dll.git"/>

<get-release platform="windows" arch="x86" file="glfw.dll"/>
<get-release platform="windows" arch="x86" file="glfw.dll.git"/>

<get-release platform="windows" arch="arm64" file="glfw.dll"/>
<get-release platform="windows" arch="arm64" file="glfw.dll.git"/>
</natives>
</release-module>

Expand All @@ -1232,13 +1250,26 @@
<release-module package="org.lwjgl.util.lz4" name="lz4" native-library="lwjgl_lz4" title="lz4" if:true="${binding.lz4}"/>

<!-- Meow hash -->
<release-module package="org.lwjgl.util.meow" name="meow" native-library="lwjgl_meow" title="Meow hash" if:true="${binding.meow}"/>
<release-module name="meow" title="Meow hash" if:true="${binding.meow}">
<natives>
<get-release platform="linux" arch="x64" file="liblwjgl_meow.so"/>
<get-release platform="linux" arch="arm64" file="liblwjgl_meow.so"/>
<get-release platform="macos" arch="x64" file="liblwjgl_meow.dylib"/>
<get-release platform="macos" arch="arm64" file="liblwjgl_meow.dylib"/>
<get-release platform="windows" arch="x64" file="lwjgl_meow.dll"/>
<get-release platform="windows" arch="x86" file="lwjgl_meow.dll"/>
<get-release platform="windows" arch="arm64" file="lwjgl_meow.dll"/>
</natives>
</release-module>

<!-- meshoptimizer -->
<release-module name="meshoptimizer" native-library="lwjgl_meshoptimizer" title="meshoptimizer" if:true="${binding.meshoptimizer}"/>

<!-- NanoVG -->
<release-module package="org.lwjgl.nanovg" name="nanovg" native-library="lwjgl_nanovg" title="NanoVG" if:true="${binding.nanovg}"/>

<!-- Native File Dialog -->
<release-module package="org.lwjgl.util.nfd" name="nfd" native-library="lwjgl_nfd" title="Native File Dialog" if:true="${binding.nfd}"/>
<release-module name="nfd" native-library="lwjgl_nfd" title="Native File Dialog" if:true="${binding.nfd}"/>

<!-- Nuklear -->
<release-module package="org.lwjgl.nuklear" name="nuklear" native-library="lwjgl_nuklear" title="Nuklear" if:true="${binding.nuklear}"/>
Expand All @@ -1249,15 +1280,29 @@
<!-- OpenAL -->
<release-module package="org.lwjgl.openal" name="openal" title="OpenAL" if:true="${binding.openal}">
<natives>
<get-release url="linux/x64/libopenal.so"/>
<get-release url="macosx/x64/libopenal.dylib"/>
<get-release url="windows/x64/OpenAL.dll"/>
<get-release url="windows/x86/OpenAL32.dll"/>

<get-release url="linux/x64/libopenal.so.git"/>
<get-release url="macosx/x64/libopenal.dylib.git"/>
<get-release url="windows/x64/OpenAL.dll.git"/>
<get-release url="windows/x86/OpenAL32.dll.git"/>
<get-release platform="linux" arch="x64" file="libopenal.so"/>
<get-release platform="linux" arch="x64" file="libopenal.so.git"/>

<get-release platform="linux" arch="arm64" file="libopenal.so"/>
<get-release platform="linux" arch="arm64" file="libopenal.so.git"/>

<get-release platform="linux" arch="arm32" file="libopenal.so"/>
<get-release platform="linux" arch="arm32" file="libopenal.so.git"/>

<get-release platform="macos" arch="x64" file="libopenal.dylib"/>
<get-release platform="macos" arch="x64" file="libopenal.dylib.git"/>

<get-release platform="macos" arch="arm64" file="libopenal.dylib"/>
<get-release platform="macos" arch="arm64" file="libopenal.dylib.git"/>

<get-release platform="windows" arch="x64" file="OpenAL.dll"/>
<get-release platform="windows" arch="x64" file="OpenAL.dll.git"/>

<get-release platform="windows" arch="x86" file="OpenAL.dll"/>
<get-release platform="windows" arch="x86" file="OpenAL.dll.git"/>

<get-release platform="windows" arch="arm64" file="OpenAL.dll"/>
<get-release platform="windows" arch="arm64" file="OpenAL.dll.git"/>
</natives>
</release-module>

Expand Down Expand Up @@ -1308,7 +1353,13 @@
<release-module package="org.lwjgl.util.remotery" name="remotery" native-library="lwjgl_remotery" title="remotery" if:true="${binding.remotery}"/>

<!-- rpmalloc -->
<release-module package="org.lwjgl.system.rpmalloc" name="rpmalloc" native-library="lwjgl_rpmalloc" title="rpmalloc" if:true="${binding.rpmalloc}"/>
<release-module name="rpmalloc" native-library="lwjgl_rpmalloc" title="rpmalloc" if:true="${binding.rpmalloc}"/>

<!-- shaderc -->
<release-module name="shaderc" native-library="shaderc" title="Shaderc" if:true="${binding.shaderc}"/>

<!-- SPIRV-Cross -->
<release-module name="spvc" native-library="spirv-cross" title="SPIRV-Cross" if:true="${binding.spvc}"/>

<!-- SSE -->
<release-module package="org.lwjgl.util.simd" name="sse" native-library="lwjgl_sse" title="SSE" if:true="${binding.sse}"/>
Expand All @@ -1331,8 +1382,10 @@
<!-- Vulkan -->
<release-module package="org.lwjgl.vulkan" name="vulkan" title="Vulkan" if:true="${binding.vulkan}">
<natives>
<get-release url="macosx/x64/libMoltenVK.dylib"/>
<get-release url="macosx/x64/libMoltenVK.dylib.git"/>
<get-release platform="macos" arch="x64" file="libMoltenVK.dylib"/>
<get-release platform="macos" arch="x64" file="libMoltenVK.dylib.git"/>
<get-release platform="macos" arch="arm64" file="libMoltenVK.dylib"/>
<get-release platform="macos" arch="arm64" file="libMoltenVK.dylib.git"/>
</natives>
</release-module>

Expand Down
14 changes: 13 additions & 1 deletion config/build-bindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ This script is included in /config/build-definitions.xml.
<!-- // ========== BINDING FLAGS ======== // -->

<property name="binding.assimp" value="true"/>
<property name="binding.bgfx" value="true"/>
<condition property="binding.bgfx" value="false" else="true">
<and>
<isset property="platform.windows"/>
<isset property="build.arch.arm"/>
</and>
</condition>
<property name="binding.bullet" value="false"/>
<property name="binding.cuda" value="true"/>
<property name="binding.egl" value="true"/>
Expand Down Expand Up @@ -61,6 +66,13 @@ This script is included in /config/build-definitions.xml.
<!-- Set the path to the Oculus SDK to enable. -->
<!-- TODO: add headers in here -->
<property name="OCULUS_SDK_PATH" location="../OculusSDK" relative="false"/>
<condition property="binding.ovr" value="true" else="false">
<and>
<isset property="OCULUS_SDK_PATH"/>
<available file="${OCULUS_SDK_PATH}/LibOVR/Include/OVR_CAPI.h"/>
<not><isset property="build.arch.arm"/></not>
</and>
</condition>

<!-- // ================================ // -->

Expand Down
31 changes: 26 additions & 5 deletions config/build-definitions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,32 @@ Defines global properties and useful macros.
This script is included in /build.xml and /config/update-dependencies.xml.
-->
<project name="definitions" basedir="../" xmlns:if="ant:if" xmlns:unless="ant:unless">
<import file="build-bindings.xml"/>

<!-- ================================================================== -->
<!-- Global properties for build -->
<!-- ================================================================== -->
<property environment="env"/>

<!--
The target native architecture.
By default, os.arch of the JVM that runs ANT is used, but this can be overridden for cross-compiling to another architecture.
Valid values: x64, x86, arm64, arm32
-->
<property name="build.arch" value="${env.LWJGL_BUILD_ARCH}" if:set="env.LWJGL_BUILD_ARCH"/>
<condition property="build.arch" value="x64" else="x86" unless:set="build.arch"> <!-- Normalize os.arch -->
<contains string="${os.arch}" substring="64"/>
</condition>

<fail message="Invalid or unsupported build architecture: ${build.arch}. Supported: x64, x86, arm64, arm32">
<condition><not><matches string="${build.arch}" pattern="^(x64|x86|arm64|arm32)$"/></not></condition>
</fail>

<property name="build.arch.${build.arch}" value="true"/>
<condition property="build.arch.arm" value="true">
<or>
<isset property="build.arch.arm64"/>
<isset property="build.arch.arm32"/>
</or>
</condition>

<!--
This is used as the source of binary dependencies. Valid values:
- nightly
Expand Down Expand Up @@ -145,6 +164,8 @@ This script is included in /build.xml and /config/update-dependencies.xml.
<!-- Different location per platform/architecture. This is intentional. -->
<property name="bin.native" location="bin/${platform}/${build.arch}" relative="true"/>

<import file="build-bindings.xml"/>

<presetdef name="lwjgl.javac">
<javac sourcepath="" debug="yes" source="8" target="8" encoding="UTF-8">
<compilerarg line='--boot-class-path "${env.JAVA8_HOME}/jre/lib/rt.jar"' if:set="set-boot-class-path"/>
Expand Down
29 changes: 15 additions & 14 deletions config/linux/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,13 @@
<!-- NativeFileDialog -->
<build module="nfd" simple="true" if:true="${binding.nfd}">
<beforeCompile>
<local name="gtk3"/>
<local name="stderr"/>
<exec outputproperty="gtk3" errorproperty="stderr" executable="pkg-config" failonerror="true" taskname="gtk-3.0">
<arg line="--cflags gtk+-3.0"/>
</exec>
<local name="linux.triplet"/>
<condition property="linux.triplet" value="x86_64-linux-gnu"><not><isset property="build.arch.arm"/></not></condition>
<condition property="linux.triplet" value="arm-linux-gnueabihf"><isset property="build.arch.arm32"/></condition>
<condition property="linux.triplet" value="aarch64-linux-gnu"><isset property="build.arch.arm64"/></condition>

<compile>
<arg line="${gtk3}"/>
<arg line="-I/usr/include/gtk-3.0 -I/usr/include/glib-2.0 -I/usr/lib/${linux.triplet}/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0"/>
<arg value="-I${src.main.rel}"/>
<arg value="-I${src.main.rel}/include"/>
<fileset dir="." includes="${src.main}/nfd_common.c"/>
Expand Down Expand Up @@ -457,14 +456,16 @@

<parallel threadsPerProcessor="4" failonany="true">

<update-dependency name="Assimp" artifact="${build.arch}/libassimp.so" dest="${lib}" if:true="${binding.assimp}"/>
<update-dependency name="bgfx" artifact="${build.arch}/libbgfx.so" dest="${lib}" if:true="${binding.bgfx}"/>
<update-dependency name="jemalloc" artifact="${build.arch}/libjemalloc.so" dest="${lib}" if:true="${binding.jemalloc}"/>
<update-dependency name="GLFW" artifact="${build.arch}/libglfw.so" dest="${lib}" if:true="${binding.glfw}"/>
<update-dependency name="GLFW" artifact="${build.arch}/libglfw_wayland.so" dest="${lib}" if:true="${binding.glfw}"/>
<update-dependency name="OpenAL32" artifact="${build.arch}/libopenal.so" dest="${lib}" if:true="${binding.openal}"/>
<update-dependency name="OpenVR" artifact="${build.arch}/libopenvr_api.so" dest="${lib}" if:true="${binding.openvr}"/>
<update-dependency name="Opus" artifact="${build.arch}/libopus.so" dest="${lib}" if:true="${binding.opus}"/>
<update-dependency module="assimp" artifact="libassimp.so"/>
<update-dependency module="bgfx" artifact="libbgfx.so"/>
<update-dependency module="jemalloc" artifact="libjemalloc.so"/>
<update-dependency module="glfw" artifact="libglfw.so"/>
<update-dependency module="glfw" artifact="libglfw_wayland.so"/>
<update-dependency module="openal" artifact="libopenal.so"/>
<update-dependency module="openvr" artifact="libopenvr_api.so"/>
<update-dependency module="opus" artifact="libopus.so"/>
<update-dependency module="shaderc" artifact="libshaderc.so"/>
<update-dependency module="spvc" artifact="libspirv-cross.so"/>

</parallel>

Expand Down
24 changes: 20 additions & 4 deletions config/macos/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
<find-sdkroot version="10.9"/>
<fail unless="sdkroot" message="Failed to find the macOS SDK."/>

<property name="macosx-version-min" value="10.9"/>
<condition property="macosx-version-min" value="11.0" else="10.9">
<isset property="build.arch.arm"/>
</condition>

<property name="module.lwjgl.rel" value="../../../../${module.lwjgl}"/>

Expand All @@ -59,6 +61,7 @@
<arg line="-c -std=c11 -ObjC" unless:set="cpp"/>
<arg line="-c -std=c++11" if:set="cpp"/>
<arg line="-O3 -flto -fPIC @{flags} -DNDEBUG -DLWJGL_MACOS -DLWJGL_${build.arch} -isysroot ${sdkroot} -mmacosx-version-min=${macosx-version-min}"/>
<arg line="-target aarch64-apple-darwin -arch arm64" if:set="build.arch.arm"/>

<arg value="-I${jni.headers}"/>
<arg value="-I${jni.headers}/darwin"/>
Expand Down Expand Up @@ -128,7 +131,8 @@
<beforeLink/>
<apply executable="${clang}" failonerror="true" parallel="true" taskname="Linker" unless:set="lib-uptodate">
<srcfile/>
<arg line='-dynamiclib -Wl,-no_compact_unwind -mmacosx-version-min=${macosx-version-min} -o ${lib}/lib${name}.dylib -O3 -flto -fPIC'/>
<arg line='-dynamiclib -Wl,-no_compact_unwind -mmacosx-version-min=${macosx-version-min} -o ${lib.arch}/lib${name}.dylib -O3 -flto -fPIC'/>
<arg line="-target aarch64-apple-darwin -arch arm64" if:set="build.arch.arm"/>
<fileset dir="${dest}" includes="*.o"/>
<link/>
</apply>
Expand Down Expand Up @@ -234,7 +238,11 @@
</build>

<!-- Meow -->
<build module="meow" simple="true" flags="-Werror -Wfatal-errors -maes" if:true="${binding.meow}"/>
<local name="meow.flags"/>
<condition property="meow.flags" value="" else="-maes">
<isset property="build.arch.arm"/>
</condition>
<build module="meow" simple="true" flags="-Werror -Wfatal-errors ${meow.flags}" if:true="${binding.meow}"/>

<!-- NanoVG -->
<build module="nanovg" simple="true" if:true="${binding.nanovg}">
Expand Down Expand Up @@ -396,7 +404,15 @@
<sequential unless:set="native-dependencies-uptodate">
<mkdir dir="${lib}/${platform}/${build.arch}"/>

<parallel threadsPerProcessor="4" failonany="true">
<update-dependency module="assimp" artifact="libassimp.dylib"/>
<update-dependency module="bgfx" artifact="libbgfx.dylib"/>
<update-dependency module="jemalloc" artifact="libjemalloc.dylib"/>
<update-dependency module="glfw" artifact="libglfw.dylib"/>
<update-dependency module="openal" artifact="libopenal.dylib"/>
<update-dependency module="openvr" artifact="libopenvr_api.dylib"/>
<update-dependency module="opus" artifact="libopus.dylib"/>
<update-dependency module="shaderc" artifact="libshaderc.dylib"/>
<update-dependency module="spvc" artifact="libspirv-cross.dylib"/>

<update-dependency name="Assimp" artifact="${build.arch}/libassimp.dylib" dest="${lib}" if:true="${binding.assimp}"/>
<update-dependency name="bgfx" artifact="${build.arch}/libbgfx.dylib" dest="${lib}" if:true="${binding.bgfx}"/>
Expand Down
16 changes: 9 additions & 7 deletions config/windows/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,15 @@ EXPORTS

<parallel threadsPerProcessor="4" failonany="true">

<update-dependency name="Assimp" artifact="${build.arch}/assimp${LIB_POSTFIX}.dll" dest="${lib}" if:true="${binding.assimp}"/>
<update-dependency name="bgfx" artifact="${build.arch}/bgfx${LIB_POSTFIX}.dll" dest="${lib}" if:true="${binding.bgfx}"/>
<update-dependency name="jemalloc" artifact="${build.arch}/jemalloc${LIB_POSTFIX}.dll" dest="${lib}" if:true="${binding.jemalloc}"/>
<update-dependency name="GLFW" artifact="${build.arch}/glfw${LIB_POSTFIX}.dll" dest="${lib}" if:true="${binding.glfw}"/>
<update-dependency name="OpenAL32" artifact="${build.arch}/OpenAL${LIB_POSTFIX}.dll" dest="${lib}" if:true="${binding.openal}"/>
<update-dependency name="OpenVR" artifact="${build.arch}/openvr_api${LIB_POSTFIX}.dll" dest="${lib}" if:true="${binding.openvr}"/>
<update-dependency name="Opus" artifact="${build.arch}/opus${LIB_POSTFIX}.dll" dest="${lib}" if:true="${binding.opus}"/>
<update-dependency module="assimp" artifact="assimp.dll"/>
<update-dependency module="bgfx" artifact="bgfx.dll"/>
<update-dependency module="jemalloc" artifact="jemalloc.dll"/>
<update-dependency module="glfw" artifact="glfw.dll"/>
<update-dependency module="openal" artifact="OpenAL.dll"/>
<update-dependency module="openvr" artifact="openvr_api.dll"/>
<update-dependency module="opus" artifact="opus.dll"/>
<update-dependency module="shaderc" artifact="shaderc.dll"/>
<update-dependency module="spvc" artifact="spirv-cross.dll"/>

</parallel>

Expand Down
Loading

0 comments on commit 8a4e9ef

Please sign in to comment.