Skip to content

Commit

Permalink
Wipe out LWJGL natives and organize libs.versions.toml
Browse files Browse the repository at this point in the history
Update to polymixin
  • Loading branch information
Wyvest committed Oct 20, 2024
1 parent 77b1a77 commit cf22614
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 85 deletions.
23 changes: 11 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
[versions]

# Libraries
kotlin = "2.0.20"
kotlinx-coroutines = "1.8.1"
kotlinx-atomicfu = "0.24.0"
kotlinx-abi = "0.14.0"
polyui = "1.7.03"
annotations = "24.1.0"
nightconfig = "3.6.6"
hypixel-modapi = "1.0"
universalcraft = "299"
mixin = "0.8.4+build.2"
isolated-lwjgl3-loader = "0.1.1"
lwjgl = "3.3.3" # Natives downloaded by the isolated-lwjgl3-loader

# Gradle
pgt = "0.6.6"
shadow = "8.1.1"
licenser = "2.0.1"
jetbrains-idea-ext = "1.1.8"

# Libraries
polyui = "1.7.03"

log4j-api = "2.0-beta9" # used because this is the version that 1.8.9 supports, so we have to compile against the same (annoying)
annotations = "24.1.0"
nightconfig = "3.6.6"
hypixel-modapi = "1.0"

lwjgl = "3.3.3"
universalcraft = "299"
mixin = "0.7.11-SNAPSHOT"
isolated-lwjgl3-loader = "0.1.1"

# Testing
junit-bom = "5.10.2"
Expand All @@ -31,7 +30,7 @@ log4j-impl = "2.23.1" # unvulnerable version
junit = { module = "org.junit.jupiter:junit-jupiter" }
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit-bom" }

mixin = { module = "org.spongepowered:mixin", version.ref = "mixin" }
mixin = { module = "org.polyfrost:polymixin", version.ref = "mixin" }

isolated-lwjgl3-loader = { module = "org.polyfrost:isolated-lwjgl3-loader", version.ref = "isolated-lwjgl3-loader" }

Expand Down
34 changes: 4 additions & 30 deletions modules/dependencies/legacy/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,42 +1,16 @@
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers

plugins {
alias(libs.plugins.jetbrains.idea.ext)
}

val lwjglVersion = libs.versions.lwjgl.get()

description = "Dependencies for legacy platforms (<1.12)"

val natives = listOf("windows", "windows-arm64", "linux", "macos", "macos-arm64")

dependencies {
// for (dep in listOf("-nanovg", "-tinyfd", "-stb", "")) {
// val lwjglDep = "org.lwjgl:lwjgl$dep:$lwjglVersion"
// api(lwjglDep) {
// isTransitive = false
// }
// for (native in natives) {
// implementation("$lwjglDep:natives-$native") {
// isTransitive = false
// }
// }
// }
}

val build = project.tasks.getByName("build")
project.tasks.withType(Jar::class.java).configureEach {
archiveVersion.set(lwjglVersion)
}
val jar = project.tasks.withType(Jar::class.java).getByName("jar")

rootProject.idea.project.settings {
taskTriggers {
if (!jar.archiveFile.get().asFile.exists()) {
afterSync(build)
beforeBuild(build)
logger.warn("Building legacy LWJGL jar after sync for you...")
for (dep in listOf("-nanovg", "-tinyfd", "-stb", "")) {
val lwjglDep = "org.lwjgl:lwjgl$dep:${libs.versions.lwjgl.get()}"
api(lwjglDep) {
isTransitive = false
}
}
}
7 changes: 0 additions & 7 deletions modules/dependencies/modern/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,4 @@ dependencies {
implementation(libs.lwjgl.nvg) {
isTransitive = false
}
val nvg = libs.lwjgl.nvg.get()
val nvgDep = "${nvg.module}:${nvg.version}:natives-"
for (native in natives) {
implementation("$nvgDep$native") {
isTransitive = false
}
}
}
37 changes: 1 addition & 36 deletions versions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Shared build logic for all versions of OneConfig.

import org.polyfrost.gradle.util.noServerRunConfigs
import org.polyfrost.gradle.util.prebundle
import java.text.SimpleDateFormat
import java.util.zip.ZipFile

plugins {
alias(libs.plugins.kotlin)
Expand Down Expand Up @@ -57,9 +55,7 @@ dependencies {
}

if (platform.isLegacyForge || platform.isLegacyFabric) {
val configuration = configurations.create("tempLwjglConfigurationLegacy")
implementation(configuration(project(":modules:dependencies:legacy"))!!)
runtimeOnly(compileOnly(prebundle(configuration, "lwjgl-legacy.jar"))!!)
implementation(project(":modules:dependencies:legacy"))
} else {
implementation(project(":modules:dependencies:modern"))
}
Expand Down Expand Up @@ -90,7 +86,6 @@ dependencies {
}

tasks {
var lwjglLegacyJarBytes: ByteArray? = null // this can be shared at least in each version
withType(Jar::class) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude("META-INF/com.android.tools/**")
Expand All @@ -108,7 +103,6 @@ tasks {
exclude("mcmod.info")
}
}

// Removes the TestMod entrypoint from the generated JARs.
doLast {
val mainResources = layout.buildDirectory.get().asFile.resolve("resources")
Expand All @@ -119,35 +113,6 @@ tasks {
lines.removeIf { it.contains("TestMod") }
fabricModJson.writeText(lines.joinToString("\n"))
}
if (platform.mcMinor <= 12) {
val legacyLwjgl = mainResources.resolve("lwjgl-legacy.jar")
val output = projectDir
.resolve(".gradle")
.resolve("prebundled-jars")
.resolve("tempLwjglConfigurationLegacy.jar")

if (output.exists()) {
// get the stuff in the jar, get lwjgl-legacy.jar, copy it to legacyLwjgl variable
if (lwjglLegacyJarBytes == null) {
ZipFile(output).use { zip ->
val entry = zip.getEntry("lwjgl-legacy.jar")
zip.getInputStream(entry).use { input ->
lwjglLegacyJarBytes = input.readBytes()
}
}
}
if (lwjglLegacyJarBytes != null) {
legacyLwjgl.outputStream().use { final ->
final.write(lwjglLegacyJarBytes!!)
logger.info("Copied lwjgl-legacy.jar to $legacyLwjgl")
}
} else {
throw IllegalStateException("LWJGL LEGACY JAR WAS NOT FOUND, BUILD WILL **NOT** WORK!!! Please build the :dependencies:legacy project first.")
}
} else {
throw IllegalStateException("LWJGL LEGACY JAR WAS NOT FOUND, BUILD WILL **NOT** WORK!!! Please build the :dependencies:legacy project first.")
}
}
}
}

Expand Down

0 comments on commit cf22614

Please sign in to comment.