pull #2

Open
aidan wants to merge 7 commits from aidan/OpenPrestige:main into main
pull from: aidan/OpenPrestige:main
4 changed files with 339 additions and 220 deletions
Showing only changes of commit 6d94493e58 - Show all commits

No files matched your search

+17 -12
View File
@@ -1,12 +1,17 @@
# Build OpenPrestige and collect the host binaries in dist/.
$ErrorActionPreference = 'Continue'
Set-Location $PSScriptRoot
if (Test-Path 'C:\Program Files\Eclipse Adoptium\jdk-21.0.12.101-hotspot') { $env:JAVA_HOME = 'C:\Program Files\Eclipse Adoptium\jdk-21.0.12.101-hotspot' }
& .\gradlew.bat remapJar --console=plain
if ($LASTEXITCODE -ne 0) { throw 'gradle remapJar failed' }
cargo build --release --manifest-path injector\Cargo.toml
if ($LASTEXITCODE -ne 0) { throw 'cargo build failed' }
New-Item -ItemType Directory -Force dist | Out-Null
Copy-Item injector\target\release\OpenPrestigeInjector.exe, injector\target\release\prestige_native.dll dist\ -Force
Get-ChildItem build\libs\prestige-*.jar | Where-Object { $_.Name -notmatch '-(dev|sources)\.jar$' } | Copy-Item -Destination dist\ -Force
Write-Host 'Done: dist\OpenPrestigeInjector.exe + native library + Fabric mod JAR'
# Build OpenPrestige and collect the host binaries in dist/.
param([string]$Python = 'python')
$ErrorActionPreference = 'Stop'
Set-Location $PSScriptRoot
if (Test-Path 'C:\Program Files\Eclipse Adoptium\jdk-21.0.12.101-hotspot') { $env:JAVA_HOME = 'C:\Program Files\Eclipse Adoptium\jdk-21.0.12.101-hotspot' }
& .\gradlew.bat bundlePayloads "-PpythonExecutable=$Python" --console=plain
if ($LASTEXITCODE -ne 0) { throw 'gradle bundlePayloads failed' }
$env:PRESTIGE_PAYLOAD = $null
$env:PRESTIGE_BUNDLE = Join-Path $PSScriptRoot 'build/bundle'
cargo build --release --manifest-path injector\Cargo.toml
if ($LASTEXITCODE -ne 0) { throw 'cargo build failed' }
New-Item -ItemType Directory -Force dist | Out-Null
Copy-Item injector\target\release\OpenPrestigeInjector.exe, injector\target\release\prestige_native.dll dist\ -Force
$version = (Get-Content gradle.properties | Where-Object { $_ -like 'mod_version=*' }) -replace '^mod_version=', ''
& $Python scripts/package_release.py offline dist $version windows-x86_64 dist/OpenPrestigeInjector.exe dist/prestige_native.dll build/bundle/common.jar
if ($LASTEXITCODE -ne 0) { throw 'release packaging failed' }
Write-Host 'Done: dist contains the offline multi-version Windows bundle'
+8 -6
View File
@@ -12,13 +12,15 @@ if [ -n "${JAVA_HOME:-}" ]; then
PATH="$JAVA_HOME/bin:$PATH"
export PATH
fi
./gradlew remapJar --console=plain
./gradlew bundlePayloads "-PpythonExecutable=${PYTHON:-python3}" --console=plain
unset PRESTIGE_PAYLOAD
export PRESTIGE_BUNDLE="$PWD/build/bundle"
cargo build --release --manifest-path injector/Cargo.toml
mkdir -p dist
cp -f "injector/target/release/OpenPrestigeInjector" "injector/target/release/$LIB" dist/
chmod +x dist/OpenPrestigeInjector
for jar in build/libs/prestige-*.jar; do
case "$jar" in *-dev.jar|*-sources.jar) continue ;; esac
cp -f "$jar" dist/
done
echo "Done: dist/OpenPrestigeInjector + dist/$LIB + Fabric mod JAR"
VERSION=$(sed -n 's/^mod_version=//p' gradle.properties)
case "$(uname -s)" in Linux) PLATFORM=linux ;; Darwin) PLATFORM=macos ;; esac
case "$(uname -m)" in x86_64) ARCH=x86_64 ;; arm64|aarch64) ARCH=aarch64 ;; *) echo 'Unsupported architecture' >&2; exit 1 ;; esac
"${PYTHON:-python3}" scripts/package_release.py offline dist "$VERSION" "$PLATFORM-$ARCH" dist/OpenPrestigeInjector "dist/$LIB" build/bundle/common.jar
echo "Done: dist contains the offline multi-version host bundle"
+81 -82
View File
@@ -1,82 +1,81 @@
@echo off
rem Builds fully offline OpenPrestige bundles.
rem OpenPrestige CLI + native library with embedded payload
rem Requires Rust with MSVC x64/ARM64 tools, Python 3 and JDK 21.
rem Fetches pinned ImGui sources and cross-compiles the small JNI libraries.
setlocal EnableExtensions
cd /d "%~dp0"
set "SELF=%~f0"
set "OUT=%CD%\dist\release"
if exist "C:\Program Files\Eclipse Adoptium\jdk-21.0.12.101-hotspot" set "JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-21.0.12.101-hotspot"
for /f "tokens=1,* delims==" %%a in ('findstr /b /c:"mod_version=" gradle.properties') do set "VERSION=%%b"
if not defined VERSION set "VERSION=dev"
echo === Prestige %VERSION% release build
rem ---- tools -------------------------------------------------------------
where cargo >nul 2>&1 || (echo cargo not found: install Rust from https://rustup.rs & goto :fail)
where python >nul 2>&1 || (echo python not found: install Python 3 from https://python.org & goto :fail)
python -m ziglang version >nul 2>&1 || (
echo === Installing zig ^(pip ziglang^)
python -m pip install --user ziglang==0.16.0 || goto :fail
)
where cargo-zigbuild >nul 2>&1 || (
echo === Installing cargo-zigbuild
cargo install --locked cargo-zigbuild || goto :fail
)
rustup target add x86_64-pc-windows-msvc aarch64-pc-windows-msvc x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu x86_64-apple-darwin aarch64-apple-darwin || goto :fail
rem zigbuild's linker wrappers break on paths with spaces, so keep its cache on the 8.3 short path
if not exist "%LOCALAPPDATA%\cargo-zigbuild" mkdir "%LOCALAPPDATA%\cargo-zigbuild"
for %%I in ("%LOCALAPPDATA%\cargo-zigbuild") do set "CARGO_ZIGBUILD_CACHE_DIR=%%~sI"
rem ---- core ImGui JNI libraries ------------------------------------------
echo === Fetching sources and building small ImGui libraries
python scripts\build_release_imgui.py || goto :fail
rem ---- payload jar -------------------------------------------------------
echo === Building payload jar
call "%CD%\gradlew.bat" remapJar --console=plain || goto :fail
set "JAR="
for /f "delims=" %%j in ('dir /b /o-d "build\libs\prestige-*.jar" ^| findstr /v /i /c:"-dev.jar" /c:"-sources.jar"') do if not defined JAR set "JAR=%CD%\build\libs\%%j"
if not defined JAR (echo no remapped jar in build\libs & goto :fail)
rem The native library uses this exact payload JAR.
set "PRESTIGE_PAYLOAD=%JAR%"
if not exist "%OUT%" mkdir "%OUT%" || goto :fail
rem ---- native builds -----------------------------------------------------
call :build windows-x86_64 x86_64-pc-windows-msvc OpenPrestigeInjector.exe prestige_native.dll build || goto :fail
call :build windows-aarch64 aarch64-pc-windows-msvc OpenPrestigeInjector.exe prestige_native.dll build || goto :fail
call :build linux-x86_64 x86_64-unknown-linux-gnu OpenPrestigeInjector libprestige_native.so zigbuild x86_64-unknown-linux-gnu.2.17 || goto :fail
call :build linux-aarch64 aarch64-unknown-linux-gnu OpenPrestigeInjector libprestige_native.so zigbuild aarch64-unknown-linux-gnu.2.17 || goto :fail
call :build macos-universal universal2-apple-darwin OpenPrestigeInjector libprestige_native.dylib zigbuild || goto :fail
copy /y "%JAR%" "%OUT%\" >nul || goto :fail
python scripts\package_release.py checksums "%OUT%" || goto :fail
echo.
echo === Done: %OUT%
call :maybe_pause
exit /b 0
rem platform, target directory, executable, library, cargo command, optional versioned target
:build
set "BUILD_TARGET=%~2"
if not "%~6"=="" set "BUILD_TARGET=%~6"
echo === OpenPrestige %~1 (offline)
cargo %~5 --release --manifest-path injector\Cargo.toml --target "%BUILD_TARGET%" || exit /b 1
python scripts\package_release.py offline "%OUT%" "%VERSION%" %~1 "injector\target\%~2\release\%~3" "injector\target\%~2\release\%~4" "%JAR%"
exit /b %ERRORLEVEL%
:fail
echo.
echo *** Release build FAILED
call :maybe_pause
exit /b 1
rem keep the window open when started by double-click
:maybe_pause
echo %cmdcmdline% | find /i "%SELF%" >nul && pause
exit /b 0
@echo off
rem Builds fully offline OpenPrestige bundles.
rem OpenPrestige CLI + native library with embedded payload
rem Requires Rust with MSVC x64/ARM64 tools, Python 3 and JDK 21.
rem Fetches pinned ImGui sources and cross-compiles the small JNI libraries.
setlocal EnableExtensions
cd /d "%~dp0"
set "SELF=%~f0"
set "OUT=%CD%\dist\release"
if exist "C:\Program Files\Eclipse Adoptium\jdk-21.0.12.101-hotspot" set "JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-21.0.12.101-hotspot"
for /f "tokens=1,* delims==" %%a in ('findstr /b /c:"mod_version=" gradle.properties') do set "VERSION=%%b"
if not defined VERSION set "VERSION=dev"
echo === Prestige %VERSION% release build
rem ---- tools -------------------------------------------------------------
where cargo >nul 2>&1 || (echo cargo not found: install Rust from https://rustup.rs & goto :fail)
where python >nul 2>&1 || (echo python not found: install Python 3 from https://python.org & goto :fail)
python -m ziglang version >nul 2>&1 || (
echo === Installing zig ^(pip ziglang^)
python -m pip install --user ziglang==0.16.0 || goto :fail
)
where cargo-zigbuild >nul 2>&1 || (
echo === Installing cargo-zigbuild
cargo install --locked cargo-zigbuild || goto :fail
)
rustup target add x86_64-pc-windows-msvc aarch64-pc-windows-msvc x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu x86_64-apple-darwin aarch64-apple-darwin || goto :fail
rem zigbuild's linker wrappers break on paths with spaces, so keep its cache on the 8.3 short path
if not exist "%LOCALAPPDATA%\cargo-zigbuild" mkdir "%LOCALAPPDATA%\cargo-zigbuild"
for %%I in ("%LOCALAPPDATA%\cargo-zigbuild") do set "CARGO_ZIGBUILD_CACHE_DIR=%%~sI"
rem ---- core ImGui JNI libraries ------------------------------------------
echo === Fetching sources and building small ImGui libraries
python scripts\build_release_imgui.py || goto :fail
rem ---- payload jar -------------------------------------------------------
echo === Building payload jar
call "%CD%\gradlew.bat" bundlePayloads --console=plain || goto :fail
set "JAR=%CD%\build\bundle\common.jar"
set "PRESTIGE_PAYLOAD="
set "PRESTIGE_BUNDLE=%CD%\build\bundle"
if not exist "%OUT%" mkdir "%OUT%" || goto :fail
rem ---- native builds -----------------------------------------------------
call :build windows-x86_64 x86_64-pc-windows-msvc OpenPrestigeInjector.exe prestige_native.dll build || goto :fail
call :build windows-aarch64 aarch64-pc-windows-msvc OpenPrestigeInjector.exe prestige_native.dll build || goto :fail
call :build linux-x86_64 x86_64-unknown-linux-gnu OpenPrestigeInjector libprestige_native.so zigbuild x86_64-unknown-linux-gnu.2.17 || goto :fail
call :build linux-aarch64 aarch64-unknown-linux-gnu OpenPrestigeInjector libprestige_native.so zigbuild aarch64-unknown-linux-gnu.2.17 || goto :fail
call :build macos-universal universal2-apple-darwin OpenPrestigeInjector libprestige_native.dylib zigbuild || goto :fail
rem Standalone Fabric mods are in versions\*\build\libs.
python scripts\package_release.py checksums "%OUT%" || goto :fail
echo.
echo === Done: %OUT%
call :maybe_pause
exit /b 0
rem platform, target directory, executable, library, cargo command, optional versioned target
:build
set "BUILD_TARGET=%~2"
if not "%~6"=="" set "BUILD_TARGET=%~6"
echo === OpenPrestige %~1 (offline)
cargo %~5 --release --manifest-path injector\Cargo.toml --target "%BUILD_TARGET%" || exit /b 1
python scripts\package_release.py offline "%OUT%" "%VERSION%" %~1 "injector\target\%~2\release\%~3" "injector\target\%~2\release\%~4" "%JAR%"
exit /b %ERRORLEVEL%
:fail
echo.
echo *** Release build FAILED
call :maybe_pause
exit /b 1
rem keep the window open when started by double-click
:maybe_pause
echo %cmdcmdline% | find /i "%SELF%" >nul && pause
exit /b 0
+233 -120
View File
@@ -1,120 +1,233 @@
plugins {
id 'net.fabricmc.fabric-loom-remap' version '1.17.21'
}
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}
loom {
accessWidenerPath = file('src/main/resources/prestige-client.accesswidener')
runs {
client {
client()
ideConfigGenerated(true)
runDir 'run'
programArg '--offlineDeveloperMode'
// dev command file / screenshot facility of the overlay: ./gradlew runClient -PuiCmd=<path>
if (project.hasProperty('uiCmd')) vmArg "-Dprestige.ui.cmd=${project.property('uiCmd')}"
// dev: -PdumpClasses=ap,C,c9 forces class init of instrumented classes (tools/java/ClinitDump.java, bridge/DumpHook)
if (project.hasProperty('dumpClasses')) vmArg "-Dprestige.dump=${project.property('dumpClasses')}"
// engine test driver (engine/EngineDev): ./gradlew runClient -PengineCmd=<command file> [-PengineReport=<seconds>] [-PquickPlay=<world>]
if (project.hasProperty('engineCmd')) vmArg "-Dprestige.engine.cmd=${project.property('engineCmd')}"
if (project.hasProperty('engineReport')) vmArg "-Dprestige.engine.report=${project.property('engineReport')}"
if (project.hasProperty('quickPlay')) { programArg '--quickPlaySingleplayer'; programArg project.property('quickPlay') }
}
}
mods {
"prestige" {
sourceSet sourceSets.main
}
}
}
configurations {
// Libraries copied (unpacked) into the final mod jar so it is self-contained.
shade
implementation.extendsFrom shade
engineMappings
}
repositories {
mavenCentral()
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Dear ImGui. The binding contains the Java classes, lwjgl3 the GL3/GLFW backend and
// natives-* the imgui-java64 libraries (extracted from the jar at runtime by imgui-java).
// Linux natives are x86_64 only; the macOS dylib is universal (x86_64 + arm64).
shade "io.github.spair:imgui-java-binding:${project.imgui_version}"
// imgui-java-lwjgl3 pulls LWJGL 3.4.1 transitively, which replaces Minecraft's 3.3.3 jars and breaks world saving
shade("io.github.spair:imgui-java-lwjgl3:${project.imgui_version}") { exclude group: 'org.lwjgl' }
shade "io.github.spair:imgui-java-natives-windows:${project.imgui_version}"
shade "io.github.spair:imgui-java-natives-linux:${project.imgui_version}"
shade "io.github.spair:imgui-java-natives-macos:${project.imgui_version}"
// ClassTransform (net.lenni0451, customised build); engine/EnginePlugin uses it to apply the client's @CTransformer hooks.
shade files('libs/classtransform-bundled.jar')
// Yarn tiny shipped as prestige-engine/mappings.tiny for the production (Intermediary) runtime
engineMappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
}
processResources {
inputs.property "version", project.version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.release = 21
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withSourcesJar()
}
jar {
// Optional custom native builds take precedence over the upstream binaries.
from('build/core-natives') {
into 'prestige-natives'
}
from('build/arm-natives') {
into 'prestige-natives'
}
// Unpack the shaded libs (imgui classes + native dll, ClassTransform) into the mod jar.
from({
configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
}) {
exclude 'META-INF/MANIFEST.MF', 'META-INF/*.SF', 'META-INF/*.RSA', 'META-INF/*.DSA'
exclude 'module-info.class', 'META-INF/versions/**'
exclude 'imgui/extension/**'
if (file('build/core-natives/windows-x86_64/imgui-java64.dll').isFile()) {
exclude 'io/imgui/java/native-bin/imgui-java64.dll'
}
if (file('build/core-natives/linux-x86_64/libimgui-java64.so').isFile()) {
exclude 'io/imgui/java/native-bin/libimgui-java64.so'
}
if (file('build/core-natives/macos-universal/libimgui-java64.dylib').isFile()) {
exclude 'io/imgui/java/native-bin/libimgui-java64.dylib'
}
}
from({ zipTree(configurations.engineMappings.singleFile) }) {
include 'mappings/mappings.tiny'
eachFile { it.relativePath = new RelativePath(true, 'prestige-engine', 'mappings.tiny') }
includeEmptyDirs = false
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
plugins {
id 'net.fabricmc.fabric-loom-remap' version '1.17.21'
}
version = "${project.mod_version}+${project.minecraft_version}"
group = project.maven_group
base {
archivesName = project.archives_base_name
}
def accessWidener = stonecutter.eval(stonecutter.current.version, '>=1.21.11')
? 'prestige-client.accesswidener' : 'prestige-client-legacy.accesswidener'
loom {
accessWidenerPath = rootProject.file("src/main/resources/${accessWidener}")
runs {
client {
client()
ideConfigGenerated(true)
runDir 'run'
programArg '--offlineDeveloperMode'
// dev command file / screenshot facility of the overlay: ./gradlew runClient -PuiCmd=<path>
if (project.hasProperty('uiCmd')) vmArg "-Dprestige.ui.cmd=${project.property('uiCmd')}"
// dev: -PdumpClasses=ap,C,c9 forces class init of instrumented classes (tools/java/ClinitDump.java, bridge/DumpHook)
if (project.hasProperty('dumpClasses')) vmArg "-Dprestige.dump=${project.property('dumpClasses')}"
// engine test driver (engine/EngineDev): ./gradlew runClient -PengineCmd=<command file> [-PengineReport=<seconds>] [-PquickPlay=<world>]
if (project.hasProperty('engineCmd')) vmArg "-Dprestige.engine.cmd=${project.property('engineCmd')}"
if (project.hasProperty('engineReport')) vmArg "-Dprestige.engine.report=${project.property('engineReport')}"
if (project.hasProperty('quickPlay')) { programArg '--quickPlaySingleplayer'; programArg project.property('quickPlay') }
}
}
mods {
"prestige" {
sourceSet sourceSets.main
}
}
}
configurations {
// Libraries copied (unpacked) into the final mod jar so it is self-contained.
shade
implementation.extendsFrom shade
engineMappings
}
repositories {
mavenCentral()
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Dear ImGui. The binding contains the Java classes, lwjgl3 the GL3/GLFW backend and
// natives-* the imgui-java64 libraries (extracted from the jar at runtime by imgui-java).
// Linux natives are x86_64 only; the macOS dylib is universal (x86_64 + arm64).
shade "io.github.spair:imgui-java-binding:${project.imgui_version}"
// imgui-java-lwjgl3 pulls LWJGL 3.4.1 transitively, which replaces Minecraft's 3.3.3 jars and breaks world saving
shade("io.github.spair:imgui-java-lwjgl3:${project.imgui_version}") { exclude group: 'org.lwjgl' }
shade "io.github.spair:imgui-java-natives-windows:${project.imgui_version}"
shade "io.github.spair:imgui-java-natives-linux:${project.imgui_version}"
shade "io.github.spair:imgui-java-natives-macos:${project.imgui_version}"
// ClassTransform (net.lenni0451, customised build); engine/EnginePlugin uses it to apply the client's @CTransformer hooks.
shade files(rootProject.file('libs/classtransform-bundled.jar'))
// Yarn tiny shipped as prestige-engine/mappings.tiny for the production (Intermediary) runtime
engineMappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
}
processResources {
exclude { it.name.endsWith('.accesswidener') && it.name != accessWidener }
inputs.property "version", project.version
inputs.property "minecraft_version", project.minecraft_version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand "version": project.version, "minecraft_version": project.minecraft_version, "access_widener": accessWidener
}
filesMatching("prestige-engine/minecraft-version.txt") {
expand "minecraft_version": project.minecraft_version
}
if (stonecutter.eval(stonecutter.current.version, '<1.21.11')) {
doLast {
def manifestFile = new File(destinationDir, 'prestige_ui/manifest_live.json')
def manifest = new groovy.json.JsonSlurper().parse(manifestFile)
def unavailable = manifest.modules.findAll { it['class'].contains('.module.spear.') }.collect { it.name }.toSet()
manifest.modules.removeAll { unavailable.contains(it.name) }
manifestFile.text = groovy.json.JsonOutput.toJson(manifest)
['modules.tsv', 'settings.tsv'].each { name ->
def table = new File(destinationDir, "prestige_ui/${name}")
table.text = table.readLines('UTF-8').findAll { row ->
!unavailable.contains(row.split('\t', -1)[name == 'modules.tsv' ? 1 : 0])
}.join('\n') + '\n'
}
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.release = 21
options.compilerArgs += ['-Xmaxerrs', '1000']
}
// Each version's compiled transformer annotations own the target set. Generate
// anchors from them so renamed/merged game classes cannot leave stale targets.
def engineSources = layout.buildDirectory.dir('generated/engine/java')
def engineResources = layout.buildDirectory.dir('generated/engine/resources')
def generateEngineMetadata = tasks.register('generateEngineMetadata') {
dependsOn tasks.named('compileJava')
inputs.files(tasks.named('compileJava').flatMap { it.destinationDirectory })
inputs.files(configurations.engineMappings)
outputs.dirs(engineSources, engineResources)
doLast {
def namedToIntermediary = [:]
new java.util.zip.ZipFile(configurations.engineMappings.singleFile).withCloseable { zip ->
zip.getInputStream(zip.getEntry('mappings/mappings.tiny')).withReader('UTF-8') { reader ->
reader.eachLine { line ->
def fields = line.split('\t')
if (fields[0] == 'c') namedToIntermediary[fields[2]] = fields[1]
}
}
}
def targets = new TreeSet<String>()
def transformers = new TreeSet<String>()
fileTree(tasks.named('compileJava').get().destinationDirectory).matching {
include 'dev/zprestige/prestige/mixin/*.class'
}.each { file ->
def node = new org.objectweb.asm.tree.ClassNode()
new org.objectweb.asm.ClassReader(file.bytes).accept(node, org.objectweb.asm.ClassReader.SKIP_CODE)
def annotation = (node.visibleAnnotations ?: []).find { it.desc == 'Lnet/lenni0451/classtransform/annotations/CTransformer;' }
if (annotation == null) annotation = (node.invisibleAnnotations ?: []).find { it.desc == 'Lnet/lenni0451/classtransform/annotations/CTransformer;' }
if (annotation != null) {
transformers.add(node.name.replace('/', '.'))
def values = annotation.values
for (int i = 0; i < values.size(); i += 2) {
if (values[i] == 'value') values[i + 1].each { targets.add(it.internalName) }
if (values[i] == 'name') values[i + 1].each { targets.add(it.replace('.', '/')) }
}
}
}
def sourceRoot = engineSources.get().asFile
def sources = new File(sourceRoot, 'dev/zprestige/prestige/engine/mixin')
def resources = new File(engineResources.get().asFile, 'prestige-engine')
assert sourceRoot.canonicalPath.startsWith(layout.buildDirectory.get().asFile.canonicalPath + File.separator)
delete sourceRoot
sources.mkdirs()
resources.mkdirs()
def named = targets.toList()
def intermediary = named.collect { target ->
if (!namedToIntermediary.containsKey(target)) throw new GradleException("No intermediary mapping for ${target}")
namedToIntermediary[target]
}
['N': named, 'I': intermediary].each { prefix, names ->
names.eachWithIndex { target, index ->
def name = String.format('%s%02d', prefix, index)
new File(sources, "${name}.java").text = """package dev.zprestige.prestige.engine.mixin;
@org.spongepowered.asm.mixin.Mixin(targets = "${target.replace('/', '.')}", remap = false, priority = 2000)
public abstract class ${name} {}
"""
}
}
new File(resources, 'targets.named.list').text = named.collect { it.replace('/', '.') }.join('\n') + '\n'
new File(resources, 'targets.intermediary.list').text = intermediary.collect { it.replace('/', '.') }.join('\n') + '\n'
new File(resources, 'transformers.list').text = transformers.join('\n') + '\n'
}
}
def compileEngineAnchors = tasks.register('compileEngineAnchors', JavaCompile) {
dependsOn generateEngineMetadata
source engineSources
classpath = sourceSets.main.compileClasspath
destinationDirectory = layout.buildDirectory.dir('classes/engine')
}
sourceSets.main.output.dir(engineResources, builtBy: generateEngineMetadata)
sourceSets.main.output.dir(compileEngineAnchors.flatMap { it.destinationDirectory }, builtBy: compileEngineAnchors)
processResources {
exclude 'prestige-engine/targets.named.list', 'prestige-engine/targets.intermediary.list', 'prestige-engine/transformers.list'
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withSourcesJar()
}
tasks.named('sourcesJar') {
dependsOn generateEngineMetadata
from engineSources
}
// Applied scripts do not inherit plugin implementation classes; pass ASM operations
// from Loom's existing classpath instead of adding another dependency.
ext.hookAsm = [
node: { new org.objectweb.asm.tree.ClassNode() },
reader: { data -> new org.objectweb.asm.ClassReader(data) },
arguments: { descriptor -> org.objectweb.asm.Type.getArgumentTypes(descriptor).toList() },
methodInstruction: { instruction -> instruction instanceof org.objectweb.asm.tree.MethodInsnNode }
]
apply from: rootProject.file('gradle/hook-check.gradle')
jar {
// Optional custom native builds take precedence over the upstream binaries.
from(rootProject.file('build/core-natives')) {
into 'prestige-natives'
}
from(rootProject.file('build/arm-natives')) {
into 'prestige-natives'
}
// Unpack the shaded libs (imgui classes + native dll, ClassTransform) into the mod jar.
from({
configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
}) {
exclude 'META-INF/MANIFEST.MF', 'META-INF/*.SF', 'META-INF/*.RSA', 'META-INF/*.DSA'
exclude 'module-info.class', 'META-INF/versions/**'
exclude 'imgui/extension/**'
if (rootProject.file('build/core-natives/windows-x86_64/imgui-java64.dll').isFile()) {
exclude 'io/imgui/java/native-bin/imgui-java64.dll'
}
if (rootProject.file('build/core-natives/linux-x86_64/libimgui-java64.so').isFile()) {
exclude 'io/imgui/java/native-bin/libimgui-java64.so'
}
if (rootProject.file('build/core-natives/macos-universal/libimgui-java64.dylib').isFile()) {
exclude 'io/imgui/java/native-bin/libimgui-java64.dylib'
}
}
from({ zipTree(configurations.engineMappings.singleFile) }) {
include 'mappings/mappings.tiny'
eachFile { it.relativePath = new RelativePath(true, 'prestige-engine', 'mappings.tiny') }
includeEmptyDirs = false
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}