Skip to content

Commit

Permalink
feat(core) add support for FreeBSD x64
Browse files Browse the repository at this point in the history
Close #421
  • Loading branch information
Spasi committed Nov 21, 2023
1 parent 3df27bf commit b693e56
Show file tree
Hide file tree
Showing 39 changed files with 1,099 additions and 86 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,50 @@ jobs:
- name: Build native
run: ant -emacs compile-native -Dgcc.libpath.opengl=/usr/lib/${{matrix.TRIPLET}}/mesa

freebsd-cross:
name: FreeBSD Cross
needs: cache-kotlinc
runs-on: macos-latest
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 3
fetch-tags: true
- name: Install dependencies
run: |
mkdir jdk8
curl -L https://cdn.azul.com/zulu/bin/zulu8.72.0.17-ca-fx-jdk8.0.382-macosx_x64.tar.gz | tar xz -C jdk8 --strip-components 1
- name: Restore kotlinc output
uses: actions/cache/restore@v3
with:
path: |
bin/classes/generator
bin/classes/templates
key: cache-kotlinc-${{ github.sha }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: Generate bindings
run: ant -emacs clean-generated generate
- name: Build Java
run: ant -emacs compile
- name: Build & Test
uses: cross-platform-actions/action@v0.21.1
with:
operating_system: freebsd
architecture: x86-64
version: '13.2'
memory: 8G
shell: bash
environment_variables: ANT_OPTS LWJGL_BUILD_TYPE
run: |
sudo pkg install -y openjdk8 apache-ant git gtk3 dbus
ant -emacs compile-native
ant -emacs tests
ant demo -Dclass=org.lwjgl.demo.util.lz4.HelloLZ4
macos:
name: macOS
needs: cache-kotlinc
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class for more options.
LWJGL 3 requires Java 8 or later to build and run and currently supports the
following platforms/architectures:

- FreeBSD x64
- Linux x64
- Linux arm64 (ARMv8/AArch64)
- Linux arm32 (ARMv7/armhf)
Expand Down
10 changes: 8 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ val deployment = when {
println("${deployment.type.name} BUILD")

enum class Platforms(val classifier: String) {
FREEBSD("freebsd"),
LINUX("linux"),
LINUX_ARM64("linux-arm64"),
LINUX_ARM32("linux-arm32"),
Expand Down Expand Up @@ -90,6 +91,7 @@ enum class Artifacts(
BGFX(
"lwjgl-bgfx", "LWJGL - bgfx bindings",
"A cross-platform, graphics API agnostic rendering library. It provides a high performance, low level abstraction for common platform graphics APIs like OpenGL, Direct3D and Apple Metal.",
Platforms.FREEBSD,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_X86
Expand Down Expand Up @@ -138,6 +140,7 @@ enum class Artifacts(
KTX(
"lwjgl-ktx", "LWJGL - KTX (Khronos Texture) bindings",
"A lightweight container for textures for OpenGL®, Vulkan® and other GPU APIs.",
Platforms.FREEBSD,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_ARM64
Expand Down Expand Up @@ -165,6 +168,7 @@ enum class Artifacts(
MEOW(
"lwjgl-meow", "LWJGL - Meow hash bindings",
"An extremely fast non-cryptographic hash.",
Platforms.FREEBSD,
Platforms.LINUX, Platforms.LINUX_ARM64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_X86, Platforms.WINDOWS_ARM64
Expand Down Expand Up @@ -220,6 +224,7 @@ enum class Artifacts(
OPENXR(
"lwjgl-openxr", "LWJGL - OpenXR bindings",
"A royalty-free, open standard that provides high-performance access to Augmented Reality (AR) and Virtual Reality (VR)—collectively known as XR—platforms and devices.",
Platforms.FREEBSD,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64,
Platforms.WINDOWS, Platforms.WINDOWS_X86, Platforms.WINDOWS_ARM64
),
Expand All @@ -241,6 +246,7 @@ enum class Artifacts(
REMOTERY(
"lwjgl-remotery", "LWJGL - Remotery bindings",
"A realtime CPU/GPU profiler hosted in a single C file with a viewer that runs in a web browser.",
Platforms.FREEBSD,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_X86
Expand All @@ -263,7 +269,7 @@ enum class Artifacts(
SSE(
"lwjgl-sse", "LWJGL - SSE bindings",
"Simple SSE intrinsics.",
Platforms.LINUX, Platforms.MACOS, Platforms.WINDOWS, Platforms.WINDOWS_X86
Platforms.FREEBSD, Platforms.LINUX, Platforms.MACOS, Platforms.WINDOWS, Platforms.WINDOWS_X86
),
STB(
"lwjgl-stb", "LWJGL - stb bindings",
Expand All @@ -283,7 +289,7 @@ enum class Artifacts(
TOOTLE(
"lwjgl-tootle", "LWJGL - AMD Tootle bindings",
"A 3D triangle mesh optimization library that improves on existing mesh preprocessing techniques.",
Platforms.LINUX, Platforms.MACOS, Platforms.WINDOWS, Platforms.WINDOWS_X86
Platforms.FREEBSD, Platforms.LINUX, Platforms.MACOS, Platforms.WINDOWS, Platforms.WINDOWS_X86
),
VMA(
"lwjgl-vma", "LWJGL - Vulkan Memory Allocator bindings",
Expand Down
54 changes: 46 additions & 8 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,6 @@
<compilerarg value="-Xbackend-threads=${backend-threads}" if:set="backend-threads"/>
<compilerarg line="-jvm-target 1.8"/>

<src path="${core.kotlin.path}/jni"/>
<src path="${core.kotlin.path}/libc"/>
<src path="${core.kotlin.path}/libffi"/>
<src path="${core.kotlin.path}/linux"/>
<src path="${core.kotlin.path}/macos"/>
<src path="${core.kotlin.path}/templates"/>
<src path="${core.kotlin.path}/windows"/>

<src path="${module.templatepath}"/>

<src path="${module.lwjgl}/egl/src/templates/kotlin/egl/EGLTypes.kt" if:set="egl_types"/>
Expand Down Expand Up @@ -1037,6 +1029,7 @@

<target name="upload-native" description="Uploads native build artifacts to build.lwjgl.org" depends="compile-native,-check-AWS-credentials">
<local name="revision"/>
<property name="revision" value="liblwjgl.so.git" if:set="platform.freebsd"/>
<property name="revision" value="liblwjgl.so.git" if:set="platform.linux"/>
<property name="revision" value="liblwjgl.dylib.git" if:set="platform.macos"/>
<property name="revision" value="lwjgl.dll.git" if:set="platform.windows"/>
Expand Down Expand Up @@ -1174,6 +1167,7 @@
<attribute name="title"/>
<attribute name="native-library"/>
<element name="content" optional="true"/>
<element name="freebsd-content" optional="true"/>
<element name="linux-content" optional="true"/>
<element name="linux-arm64-content" optional="true"/>
<element name="linux-arm32-content" optional="true"/>
Expand All @@ -1200,6 +1194,9 @@
</condition>

<parallel threadsPerProcessor="4" failonany="true">
<get-release platform="freebsd" arch="x64" file="lib@{native-library}.so" if:set="auto-natives"/>
<get-release platform="freebsd" arch="x64" file="lib@{native-library}.so.git" if:set="git-revision"/>

<get-release platform="linux" arch="x64" file="lib@{native-library}.so" if:set="auto-natives"/>
<get-release platform="linux" arch="x64" file="lib@{native-library}.so.git" if:set="git-revision"/>

Expand Down Expand Up @@ -1273,6 +1270,9 @@

<!-- Create native jar files -->
<parallel threadsPerProcessor="1" failonany="true">
<natives-jar name="@{name}" title="@{title}" platform="freebsd" path="freebsd/x64" type="so">
<freebsd-content/>
</natives-jar>
<natives-jar name="@{name}" title="@{title}" platform="linux" path="linux/x64" type="so">
<linux-content/>
</natives-jar>
Expand Down Expand Up @@ -1313,6 +1313,7 @@
<attribute name="title"/>
<attribute name="native-library" default=""/>
<element name="natives" optional="true"/>
<element name="freebsd" optional="true"/>
<element name="linux" optional="true"/>
<element name="linux-arm64" optional="true"/>
<element name="linux-arm32" optional="true"/>
Expand Down Expand Up @@ -1342,6 +1343,7 @@
<!-- Bundle natives -->
<release-natives name="@{name}" title="@{title}" native-library="@{native-library}" unless:set="java-only.binding.@{name}">
<content><natives/></content>
<freebsd-content><freebsd/></freebsd-content>
<linux-content><linux/></linux-content>
<linux-arm64-content><linux-arm64/></linux-arm64-content>
<linux-arm32-content><linux-arm32/></linux-arm32-content>
Expand Down Expand Up @@ -1545,6 +1547,10 @@
<!-- Assimp -->
<release-module name="assimp" title="assimp" if:true="${binding.assimp}">
<natives>
<get-release platform="freebsd" arch="x64" file="libassimp.so"/>
<get-release platform="freebsd" arch="x64" file="libassimp.so.git"/>
<get-release platform="freebsd" arch="x64" file="libdraco.so"/>

<get-release platform="linux" arch="x64" file="libassimp.so"/>
<get-release platform="linux" arch="x64" file="libassimp.so.git"/>
<get-release platform="linux" arch="x64" file="libdraco.so"/>
Expand Down Expand Up @@ -1590,6 +1596,9 @@
<!-- bgfx -->
<release-module name="bgfx" title="bgfx" if:true="${binding.bgfx}">
<natives>
<get-release platform="freebsd" arch="x64" file="libbgfx.so"/>
<get-release platform="freebsd" arch="x64" file="libbgfx.so.git"/>

<get-release platform="linux" arch="x64" file="libbgfx.so"/>
<get-release platform="linux" arch="x64" file="libbgfx.so.git"/>

Expand Down Expand Up @@ -1634,6 +1643,9 @@
<!-- GLFW -->
<release-module name="glfw" title="GLFW" if:true="${binding.glfw}">
<natives>
<get-release platform="freebsd" arch="x64" file="libglfw.so"/>
<get-release platform="freebsd" arch="x64" file="libglfw.so.git"/>

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

Expand Down Expand Up @@ -1685,13 +1697,17 @@
<!-- KTX -->
<release-module name="ktx" title="KTX" if:true="${binding.ktx}">
<natives>
<get-release platform="freebsd" arch="x64" file="libktx.so"/>

<get-release platform="linux" arch="x64" file="libktx.so"/>
<get-release platform="linux" arch="arm64" file="libktx.so"/>
<get-release platform="linux" arch="arm32" file="libktx.so"/>
<get-release platform="linux" arch="ppc64le" file="libktx.so"/>
<get-release platform="linux" arch="riscv64" file="libktx.so"/>

<get-release platform="macos" arch="x64" file="libktx.dylib"/>
<get-release platform="macos" arch="arm64" file="libktx.dylib"/>

<get-release platform="windows" arch="x64" file="ktx.dll"/>
<get-release platform="windows" arch="arm64" file="ktx.dll"/>
</natives>
Expand All @@ -1712,10 +1728,14 @@
<!-- Meow hash -->
<release-module name="meow" title="Meow hash" if:true="${binding.meow}">
<natives>
<get-release platform="freebsd" arch="x64" file="liblwjgl_meow.so"/>

<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"/>
Expand All @@ -1731,6 +1751,8 @@
<!-- Native File Dialog -->
<release-module name="nfd" native-library="lwjgl_nfd" title="Native File Dialog" if:true="${binding.nfd}">
<natives>
<get-release platform="freebsd" arch="x64" file="liblwjgl_nfd_portal.so"/>

<get-release platform="linux" arch="x64" file="liblwjgl_nfd_portal.so"/>
<get-release platform="linux" arch="arm64" file="liblwjgl_nfd_portal.so"/>
<get-release platform="linux" arch="arm32" file="liblwjgl_nfd_portal.so"/>
Expand All @@ -1748,6 +1770,9 @@
<!-- OpenAL -->
<release-module name="openal" title="OpenAL" if:true="${binding.openal}">
<natives>
<get-release platform="freebsd" arch="x64" file="libopenal.so"/>
<get-release platform="freebsd" arch="x64" file="libopenal.so.git"/>

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

Expand Down Expand Up @@ -1813,6 +1838,9 @@
<!-- OpenXR -->
<release-module name="openxr" title="OpenXR" if:true="${binding.openxr}">
<natives>
<get-release platform="freebsd" arch="x64" file="libopenxr_loader.so"/>
<get-release platform="freebsd" arch="x64" file="libopenxr_loader.so.git"/>

<get-release platform="linux" arch="x64" file="libopenxr_loader.so"/>
<get-release platform="linux" arch="x64" file="libopenxr_loader.so.git"/>

Expand Down Expand Up @@ -1856,6 +1884,8 @@
<!-- Remotery -->
<release-module name="remotery" title="remotery" if:true="${binding.remotery}">
<natives>
<get-release platform="freebsd" arch="x64" file="liblwjgl_remotery.so"/>

<get-release platform="linux" arch="x64" file="liblwjgl_remotery.so"/>
<get-release platform="linux" arch="arm64" file="liblwjgl_remotery.so"/>
<get-release platform="linux" arch="arm32" file="liblwjgl_remotery.so"/>
Expand All @@ -1882,8 +1912,12 @@
<!-- SSE -->
<release-module name="sse" title="SSE" if:true="${binding.sse}">
<natives>
<get-release platform="freebsd" arch="x64" file="liblwjgl_sse.so"/>

<get-release platform="linux" arch="x64" file="liblwjgl_sse.so"/>

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

<get-release platform="windows" arch="x64" file="lwjgl_sse.dll"/>
<get-release platform="windows" arch="x86" file="lwjgl_sse.dll"/>
</natives>
Expand All @@ -1901,8 +1935,12 @@
<!-- AMD Tootle -->
<release-module name="tootle" title="tootle" if:true="${binding.tootle}">
<natives>
<get-release platform="freebsd" arch="x64" file="liblwjgl_tootle.so"/>

<get-release platform="linux" arch="x64" file="liblwjgl_tootle.so"/>

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

<get-release platform="windows" arch="x64" file="lwjgl_tootle.dll"/>
<get-release platform="windows" arch="x86" file="lwjgl_tootle.dll"/>
</natives>
Expand Down
9 changes: 5 additions & 4 deletions config/build-definitions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ This script is included in /build.xml and /config/update-dependencies.xml.
<isset property="env.LWJGL_BUILD_OFFLINE"/>
</condition>

<condition property="platform.freebsd">
<os name="FreeBSD"/>
</condition>
<condition property="platform.linux">
<os name="Linux"/>
</condition>
Expand All @@ -143,17 +146,15 @@ This script is included in /build.xml and /config/update-dependencies.xml.
<os family="Windows"/>
</condition>

<property name="platform" value="freebsd" if:set="platform.freebsd"/>
<property name="platform" value="linux" if:set="platform.linux"/>
<property name="platform" value="macos" if:set="platform.macos"/>
<property name="platform" value="windows" if:set="platform.windows"/>
<fail message="Failed to detect a supported platform."><condition><not><isset property="platform"/></not></condition></fail>

<property name="platform.remote" value="macosx" if:set="platform.macos"/>
<property name="platform.remote" value="${platform}"/>

<property name="platform.linux.remote" value="linux"/>
<property name="platform.macos.remote" value="macosx"/>
<property name="platform.windows.remote" value="windows"/>

<property name="lib.native" location="${lib}/native/${platform}/${build.arch}" relative="true"/>

<!--
Expand Down
Loading

1 comment on commit b693e56

@Kichura
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an ARM64 version of this considered or is it out of scope?

Please sign in to comment.