group = "dev.rdh" version = rootProject.version val lwjglVersion = "3.4.3" repositories { exclusiveContent { forRepository { mavenCentral() } filter { includeGroup("org.lwjgl") } } mavenCentral() } dependencies { api("org.lwjgl:lwjgl:$lwjglVersion") api("org.lwjgl:lwjgl-opengl:$lwjglVersion") api("org.lwjgl:lwjgl-openal:$lwjglVersion") api("org.lwjgl:lwjgl:$lwjglVersion:natives-macos-arm64") api("org.lwjgl:lwjgl-opengl:$lwjglVersion:natives-macos-arm64") api("org.lwjgl:lwjgl-openal:$lwjglVersion:natives-macos-arm64") } val nativeDir = layout.buildDirectory.dir("native") val native = tasks.register("native") { description = "Compiles the native macOS window, event pump and presentation layer." inputs.dir("src/main/native") outputs.dir(nativeDir) val out = nativeDir.get().asFile doFirst { out.mkdirs() } commandLine( "xcrun", "--sdk", "macosx", "clang", "-dynamiclib", "-O2", "-fobjc-arc", "-Wno-deprecated-declarations", "-framework", "AppKit", "-framework", "Foundation", "-framework", "OpenGL", "-framework", "QuartzCore", "-framework", "CoreGraphics", "-framework", "IOSurface", "-install_name", "@rpath/librdhwindow.dylib", "-o", out.resolve("librdhwindow.dylib").absolutePath, *fileTree("src/main/native").matching { include("**/*.m", "**/*.c") }.files.map { it.absolutePath }.toTypedArray() ) } // System.load needs a real file, so the library ships inside the jar and is unpacked on first use sourceSets.main { resources.srcDir(nativeDir) } tasks.named("processResources") { dependsOn(native) } tasks.jar { dependsOn(native) } loom { runConfigs.configureEach { generateRunConfig = false } } tasks.matching { it.name == "runClient" || it.name == "runServer" }.configureEach { enabled = false }