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 theofficialgman committed Feb 26, 2022
1 parent 8f90d7d commit 44a22a6
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 20 deletions.
25 changes: 17 additions & 8 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1255,11 +1255,17 @@
<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 Down Expand Up @@ -1287,23 +1293,18 @@
<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>

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

<!-- Native File Dialog -->
<release-module name="nfd" title="Native File Dialog" if:true="${binding.nfd}">
<natives>
<get-release platform="linux" arch="x64" file="liblwjgl_nfd.so"/>
<get-release platform="macos" arch="x64" file="liblwjgl_nfd.dylib"/>
<get-release platform="windows" arch="x64" file="lwjgl_nfd.dll"/>
<get-release platform="windows" arch="x86" file="lwjgl_nfd.dll"/>
</natives>
</release-module>
<release-module name="nfd" native-library="lwjgl_nfd" title="Native File Dialog" if:true="${binding.nfd}"/>

<!-- Nuklear -->
<release-module name="nuklear" native-library="lwjgl_nuklear" title="Nuklear" if:true="${binding.nuklear}"/>
Expand All @@ -1326,11 +1327,17 @@
<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 @@ -1421,6 +1428,8 @@
<natives>
<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
9 changes: 7 additions & 2 deletions config/build-bindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ This script is included in /config/build-definitions.xml.
</condition>

<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 All @@ -41,7 +46,7 @@ This script is included in /config/build-definitions.xml.
</or>
</condition>
<property name="binding.nanovg" value="true"/>
<condition property="binding.nfd" value="true" else="false"><isset property="notARM"/></condition>
<property name="binding.nfd" value="true"/>
<property name="binding.nuklear" value="true"/>
<property name="binding.odbc" value="true"/>
<property name="binding.openal" value="true"/>
Expand Down
4 changes: 2 additions & 2 deletions config/build-definitions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ This script is included in /build.xml and /config/update-dependencies.xml.

<property name="build.arch.${build.arch}" value="true"/>

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

<!--
This is used as the source of binary dependencies. Valid values:
- nightly
Expand Down Expand Up @@ -149,6 +147,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
11 changes: 5 additions & 6 deletions config/linux/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,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
12 changes: 10 additions & 2 deletions config/macos/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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 @@ -60,6 +62,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 @@ -134,6 +137,7 @@
<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.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 @@ -237,7 +241,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
6 changes: 6 additions & 0 deletions modules/lwjgl/meow/src/main/c/meow_intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,15 @@ typedef struct {
static int
MeowHashesAreEqualImpl(meow_u128 A, meow_u128 B)
{
#ifdef LWJGL_WINDOWS
uint8x16_t Powers = {.n128_u8={
1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128,
}};
#else
uint8x16_t Powers = {
1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128,
};
#endif

uint8x16_t Input = vceqq_u8(A, B);
uint64x2_t Mask = vpaddlq_u32(vpaddlq_u16(vpaddlq_u8(vandq_u8(Input, Powers))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public class CLTest {
private void createCL() {
try {
CL.getFunctionProvider();

try (MemoryStack stack = stackPush()) {
IntBuffer pi = stack.mallocInt(1);
checkCLError(clGetPlatformIDs(null, pi));
}

CL.destroy();
} catch (Throwable t) {
throw new SkipException("Skipped because OpenCL initialization failed [" + t.getMessage() + "]");
Expand Down

0 comments on commit 44a22a6

Please sign in to comment.