-
-
Notifications
You must be signed in to change notification settings - Fork 184
Description
A small game program written using LWJGL requires the following dependencies to work on various OS/CPU architectures. See PR jbangdev/jbang-examples#15
//DEPS org.lwjgl:lwjgl:3.3.6
//DEPS org.lwjgl:lwjgl-glfw:3.3.6
//DEPS org.lwjgl:lwjgl-opengl:3.3.6
//DEPS org.lwjgl:lwjgl:3.3.6:natives-windows
//DEPS org.lwjgl:lwjgl-glfw:3.3.6:natives-windows
//DEPS org.lwjgl:lwjgl-opengl:3.3.6:natives-windows
//DEPS org.lwjgl:lwjgl:3.3.6:natives-windows-arm64
//DEPS org.lwjgl:lwjgl-glfw:3.3.6:natives-windows-arm64
//DEPS org.lwjgl:lwjgl-opengl:3.3.6:natives-windows-arm64
//DEPS org.lwjgl:lwjgl:3.3.6:natives-linux
//DEPS org.lwjgl:lwjgl-glfw:3.3.6:natives-linux
//DEPS org.lwjgl:lwjgl-opengl:3.3.6:natives-linux
//DEPS org.lwjgl:lwjgl:3.3.6:natives-linux-arm64
//DEPS org.lwjgl:lwjgl-glfw:3.3.6:natives-linux-arm64
//DEPS org.lwjgl:lwjgl-opengl:3.3.6:natives-linux-arm64
//DEPS org.lwjgl:lwjgl:3.3.6:natives-macos
//DEPS org.lwjgl:lwjgl-glfw:3.3.6:natives-macos
//DEPS org.lwjgl:lwjgl-opengl:3.3.6:natives-macos
//DEPS org.lwjgl:lwjgl:3.3.6:natives-macos-arm64
//DEPS org.lwjgl:lwjgl-glfw:3.3.6:natives-macos-arm64
//DEPS org.lwjgl:lwjgl-opengl:3.3.6:natives-macos-arm64
Specifically on macOS (x64 and arm64) a Mac-specific runtime option is also required. This option is not supported by Java VMs on non-Mac operating systems and causes them to display an error message and stop.
//RUNTIME_OPTIONS -XstartOnFirstThread
JBang does not allow platform specific runtime options or dependencies to be configured that only take affect when a pre-determined OS or OS/CPU combination is detected.
This problem could be solved by allowing a small subset of JBang directives to be tagged with a namespace (package name in Java terminology).
//RUNTIME_OPTIONS[namespace]-XstartOnFirstThread//DEPS[namespace]org.lwjgl:lwjgl:3.3.6:natives-macos-arm64
How is this envisioned to work in practice?
//DEPS org.lwjgl:lwjgl:3.3.6 org.lwjgl:lwjgl-glfw:3.3.6 org.lwjgl:lwjgl-opengl:3.3.6
//DEPS[os.windows.cpu.amd64] org.lwjgl:lwjgl:3.3.6:natives-windows org.lwjgl:lwjgl-glfw:3.3.6:natives-windows org.lwjgl:lwjgl-opengl:3.3.6:natives-windows
//DEPS[os.windows.cpu.arm64] org.lwjgl:lwjgl:3.3.6:natives-windows-arm64 org.lwjgl:lwjgl-glfw:3.3.6:natives-windows-arm64 org.lwjgl:lwjgl-opengl:3.3.6:natives-windows-arm64
//DEPS[os.linux.cpu.amd64] org.lwjgl:lwjgl:3.3.6:natives-linux org.lwjgl:lwjgl-glfw:3.3.6:natives-linux org.lwjgl:lwjgl-opengl:3.3.6:natives-linux
//DEPS[os.linux.cpu.arm64] org.lwjgl:lwjgl:3.3.6:natives-linux-arm64 org.lwjgl:lwjgl-glfw:3.3.6:natives-linux-arm64 org.lwjgl:lwjgl-opengl:3.3.6:natives-linux-arm64
//DEPS[os.macos.cpu.amd64] org.lwjgl:lwjgl:3.3.6:natives-macos org.lwjgl:lwjgl-glfw:3.3.6:natives-macos org.lwjgl:lwjgl-opengl:3.3.6:natives-macos
//DEPS[os.macos.cpu.arm64] org.lwjgl:lwjgl:3.3.6:natives-macos-arm64 org.lwjgl:lwjgl-glfw:3.3.6:natives-macos-arm64 org.lwjgl:lwjgl-opengl:3.3.6:natives-macos-arm64
//RUNTIME_OPTIONS[os.macos] -XstartOnFirstThread
When a script is executed JBang would filter the configured directives based on OS and CPU architecture detected.
When JBang exports to Maven or Gradle, the namespace values will be used to ensure dependencies and runtime options only apply to specific OS/CPU combinations.
Fatjar support will also have to be revisited.