Upload files to "/"
This commit is contained in:
1 parent
06269f1f65
commit
6d94493e58
4 files changed
+339
-220
No files matched your search
+17
-12
@@ -1,12 +1,17 @@
|
|||||||
# Build OpenPrestige and collect the host binaries in dist/.
|
# Build OpenPrestige and collect the host binaries in dist/.
|
||||||
$ErrorActionPreference = 'Continue'
|
param([string]$Python = 'python')
|
||||||
Set-Location $PSScriptRoot
|
$ErrorActionPreference = 'Stop'
|
||||||
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' }
|
Set-Location $PSScriptRoot
|
||||||
& .\gradlew.bat remapJar --console=plain
|
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' }
|
||||||
if ($LASTEXITCODE -ne 0) { throw 'gradle remapJar failed' }
|
& .\gradlew.bat bundlePayloads "-PpythonExecutable=$Python" --console=plain
|
||||||
cargo build --release --manifest-path injector\Cargo.toml
|
if ($LASTEXITCODE -ne 0) { throw 'gradle bundlePayloads failed' }
|
||||||
if ($LASTEXITCODE -ne 0) { throw 'cargo build failed' }
|
$env:PRESTIGE_PAYLOAD = $null
|
||||||
New-Item -ItemType Directory -Force dist | Out-Null
|
$env:PRESTIGE_BUNDLE = Join-Path $PSScriptRoot 'build/bundle'
|
||||||
Copy-Item injector\target\release\OpenPrestigeInjector.exe, injector\target\release\prestige_native.dll dist\ -Force
|
cargo build --release --manifest-path injector\Cargo.toml
|
||||||
Get-ChildItem build\libs\prestige-*.jar | Where-Object { $_.Name -notmatch '-(dev|sources)\.jar$' } | Copy-Item -Destination dist\ -Force
|
if ($LASTEXITCODE -ne 0) { throw 'cargo build failed' }
|
||||||
Write-Host 'Done: dist\OpenPrestigeInjector.exe + native library + Fabric mod JAR'
|
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
@@ -12,13 +12,15 @@ if [ -n "${JAVA_HOME:-}" ]; then
|
|||||||
PATH="$JAVA_HOME/bin:$PATH"
|
PATH="$JAVA_HOME/bin:$PATH"
|
||||||
export PATH
|
export PATH
|
||||||
fi
|
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
|
cargo build --release --manifest-path injector/Cargo.toml
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
cp -f "injector/target/release/OpenPrestigeInjector" "injector/target/release/$LIB" dist/
|
cp -f "injector/target/release/OpenPrestigeInjector" "injector/target/release/$LIB" dist/
|
||||||
chmod +x dist/OpenPrestigeInjector
|
chmod +x dist/OpenPrestigeInjector
|
||||||
for jar in build/libs/prestige-*.jar; do
|
VERSION=$(sed -n 's/^mod_version=//p' gradle.properties)
|
||||||
case "$jar" in *-dev.jar|*-sources.jar) continue ;; esac
|
case "$(uname -s)" in Linux) PLATFORM=linux ;; Darwin) PLATFORM=macos ;; esac
|
||||||
cp -f "$jar" dist/
|
case "$(uname -m)" in x86_64) ARCH=x86_64 ;; arm64|aarch64) ARCH=aarch64 ;; *) echo 'Unsupported architecture' >&2; exit 1 ;; esac
|
||||||
done
|
"${PYTHON:-python3}" scripts/package_release.py offline dist "$VERSION" "$PLATFORM-$ARCH" dist/OpenPrestigeInjector "dist/$LIB" build/bundle/common.jar
|
||||||
echo "Done: dist/OpenPrestigeInjector + dist/$LIB + Fabric mod JAR"
|
echo "Done: dist contains the offline multi-version host bundle"
|
||||||
+81
-82
@@ -1,82 +1,81 @@
|
|||||||
@echo off
|
@echo off
|
||||||
rem Builds fully offline OpenPrestige bundles.
|
rem Builds fully offline OpenPrestige bundles.
|
||||||
rem OpenPrestige CLI + native library with embedded payload
|
rem OpenPrestige CLI + native library with embedded payload
|
||||||
rem Requires Rust with MSVC x64/ARM64 tools, Python 3 and JDK 21.
|
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.
|
rem Fetches pinned ImGui sources and cross-compiles the small JNI libraries.
|
||||||
setlocal EnableExtensions
|
setlocal EnableExtensions
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
set "SELF=%~f0"
|
set "SELF=%~f0"
|
||||||
|
|
||||||
set "OUT=%CD%\dist\release"
|
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"
|
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"
|
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"
|
if not defined VERSION set "VERSION=dev"
|
||||||
echo === Prestige %VERSION% release build
|
echo === Prestige %VERSION% release build
|
||||||
|
|
||||||
rem ---- tools -------------------------------------------------------------
|
rem ---- tools -------------------------------------------------------------
|
||||||
where cargo >nul 2>&1 || (echo cargo not found: install Rust from https://rustup.rs & goto :fail)
|
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)
|
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 || (
|
python -m ziglang version >nul 2>&1 || (
|
||||||
echo === Installing zig ^(pip ziglang^)
|
echo === Installing zig ^(pip ziglang^)
|
||||||
python -m pip install --user ziglang==0.16.0 || goto :fail
|
python -m pip install --user ziglang==0.16.0 || goto :fail
|
||||||
)
|
)
|
||||||
where cargo-zigbuild >nul 2>&1 || (
|
where cargo-zigbuild >nul 2>&1 || (
|
||||||
echo === Installing cargo-zigbuild
|
echo === Installing cargo-zigbuild
|
||||||
cargo install --locked cargo-zigbuild || goto :fail
|
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
|
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
|
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"
|
if not exist "%LOCALAPPDATA%\cargo-zigbuild" mkdir "%LOCALAPPDATA%\cargo-zigbuild"
|
||||||
for %%I in ("%LOCALAPPDATA%\cargo-zigbuild") do set "CARGO_ZIGBUILD_CACHE_DIR=%%~sI"
|
for %%I in ("%LOCALAPPDATA%\cargo-zigbuild") do set "CARGO_ZIGBUILD_CACHE_DIR=%%~sI"
|
||||||
|
|
||||||
rem ---- core ImGui JNI libraries ------------------------------------------
|
rem ---- core ImGui JNI libraries ------------------------------------------
|
||||||
echo === Fetching sources and building small ImGui libraries
|
echo === Fetching sources and building small ImGui libraries
|
||||||
python scripts\build_release_imgui.py || goto :fail
|
python scripts\build_release_imgui.py || goto :fail
|
||||||
|
|
||||||
rem ---- payload jar -------------------------------------------------------
|
rem ---- payload jar -------------------------------------------------------
|
||||||
echo === Building payload jar
|
echo === Building payload jar
|
||||||
call "%CD%\gradlew.bat" remapJar --console=plain || goto :fail
|
call "%CD%\gradlew.bat" bundlePayloads --console=plain || goto :fail
|
||||||
set "JAR="
|
set "JAR=%CD%\build\bundle\common.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"
|
set "PRESTIGE_PAYLOAD="
|
||||||
if not defined JAR (echo no remapped jar in build\libs & goto :fail)
|
set "PRESTIGE_BUNDLE=%CD%\build\bundle"
|
||||||
rem The native library uses this exact payload JAR.
|
|
||||||
set "PRESTIGE_PAYLOAD=%JAR%"
|
|
||||||
|
|
||||||
|
if not exist "%OUT%" mkdir "%OUT%" || goto :fail
|
||||||
if not exist "%OUT%" mkdir "%OUT%" || goto :fail
|
|
||||||
|
rem ---- native builds -----------------------------------------------------
|
||||||
rem ---- native builds -----------------------------------------------------
|
call :build windows-x86_64 x86_64-pc-windows-msvc OpenPrestigeInjector.exe prestige_native.dll build || goto :fail
|
||||||
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 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-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 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
|
||||||
call :build macos-universal universal2-apple-darwin OpenPrestigeInjector libprestige_native.dylib zigbuild || goto :fail
|
|
||||||
|
rem Standalone Fabric mods are in versions\*\build\libs.
|
||||||
copy /y "%JAR%" "%OUT%\" >nul || goto :fail
|
python scripts\package_release.py checksums "%OUT%" || goto :fail
|
||||||
python scripts\package_release.py checksums "%OUT%" || goto :fail
|
echo.
|
||||||
echo.
|
echo === Done: %OUT%
|
||||||
echo === Done: %OUT%
|
call :maybe_pause
|
||||||
call :maybe_pause
|
exit /b 0
|
||||||
exit /b 0
|
|
||||||
|
rem platform, target directory, executable, library, cargo command, optional versioned target
|
||||||
rem platform, target directory, executable, library, cargo command, optional versioned target
|
:build
|
||||||
:build
|
set "BUILD_TARGET=%~2"
|
||||||
set "BUILD_TARGET=%~2"
|
if not "%~6"=="" set "BUILD_TARGET=%~6"
|
||||||
if not "%~6"=="" set "BUILD_TARGET=%~6"
|
echo === OpenPrestige %~1 (offline)
|
||||||
echo === OpenPrestige %~1 (offline)
|
cargo %~5 --release --manifest-path injector\Cargo.toml --target "%BUILD_TARGET%" || exit /b 1
|
||||||
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%"
|
||||||
python scripts\package_release.py offline "%OUT%" "%VERSION%" %~1 "injector\target\%~2\release\%~3" "injector\target\%~2\release\%~4" "%JAR%"
|
exit /b %ERRORLEVEL%
|
||||||
exit /b %ERRORLEVEL%
|
|
||||||
|
:fail
|
||||||
:fail
|
echo.
|
||||||
echo.
|
echo *** Release build FAILED
|
||||||
echo *** Release build FAILED
|
call :maybe_pause
|
||||||
call :maybe_pause
|
exit /b 1
|
||||||
exit /b 1
|
|
||||||
|
rem keep the window open when started by double-click
|
||||||
rem keep the window open when started by double-click
|
:maybe_pause
|
||||||
:maybe_pause
|
echo %cmdcmdline% | find /i "%SELF%" >nul && pause
|
||||||
echo %cmdcmdline% | find /i "%SELF%" >nul && pause
|
exit /b 0
|
||||||
exit /b 0
|
|
||||||
+233
-120
@@ -1,120 +1,233 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'net.fabricmc.fabric-loom-remap' version '1.17.21'
|
id 'net.fabricmc.fabric-loom-remap' version '1.17.21'
|
||||||
}
|
}
|
||||||
|
|
||||||
version = project.mod_version
|
version = "${project.mod_version}+${project.minecraft_version}"
|
||||||
group = project.maven_group
|
group = project.maven_group
|
||||||
|
|
||||||
base {
|
base {
|
||||||
archivesName = project.archives_base_name
|
archivesName = project.archives_base_name
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
def accessWidener = stonecutter.eval(stonecutter.current.version, '>=1.21.11')
|
||||||
accessWidenerPath = file('src/main/resources/prestige-client.accesswidener')
|
? 'prestige-client.accesswidener' : 'prestige-client-legacy.accesswidener'
|
||||||
runs {
|
loom {
|
||||||
client {
|
accessWidenerPath = rootProject.file("src/main/resources/${accessWidener}")
|
||||||
client()
|
runs {
|
||||||
ideConfigGenerated(true)
|
client {
|
||||||
runDir 'run'
|
client()
|
||||||
programArg '--offlineDeveloperMode'
|
ideConfigGenerated(true)
|
||||||
// dev command file / screenshot facility of the overlay: ./gradlew runClient -PuiCmd=<path>
|
runDir 'run'
|
||||||
if (project.hasProperty('uiCmd')) vmArg "-Dprestige.ui.cmd=${project.property('uiCmd')}"
|
programArg '--offlineDeveloperMode'
|
||||||
// dev: -PdumpClasses=ap,C,c9 forces class init of instrumented classes (tools/java/ClinitDump.java, bridge/DumpHook)
|
// dev command file / screenshot facility of the overlay: ./gradlew runClient -PuiCmd=<path>
|
||||||
if (project.hasProperty('dumpClasses')) vmArg "-Dprestige.dump=${project.property('dumpClasses')}"
|
if (project.hasProperty('uiCmd')) vmArg "-Dprestige.ui.cmd=${project.property('uiCmd')}"
|
||||||
// engine test driver (engine/EngineDev): ./gradlew runClient -PengineCmd=<command file> [-PengineReport=<seconds>] [-PquickPlay=<world>]
|
// dev: -PdumpClasses=ap,C,c9 forces class init of instrumented classes (tools/java/ClinitDump.java, bridge/DumpHook)
|
||||||
if (project.hasProperty('engineCmd')) vmArg "-Dprestige.engine.cmd=${project.property('engineCmd')}"
|
if (project.hasProperty('dumpClasses')) vmArg "-Dprestige.dump=${project.property('dumpClasses')}"
|
||||||
if (project.hasProperty('engineReport')) vmArg "-Dprestige.engine.report=${project.property('engineReport')}"
|
// engine test driver (engine/EngineDev): ./gradlew runClient -PengineCmd=<command file> [-PengineReport=<seconds>] [-PquickPlay=<world>]
|
||||||
if (project.hasProperty('quickPlay')) { programArg '--quickPlaySingleplayer'; programArg project.property('quickPlay') }
|
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
|
mods {
|
||||||
}
|
"prestige" {
|
||||||
}
|
sourceSet sourceSets.main
|
||||||
}
|
}
|
||||||
|
}
|
||||||
configurations {
|
}
|
||||||
// Libraries copied (unpacked) into the final mod jar so it is self-contained.
|
|
||||||
shade
|
configurations {
|
||||||
implementation.extendsFrom shade
|
// Libraries copied (unpacked) into the final mod jar so it is self-contained.
|
||||||
engineMappings
|
shade
|
||||||
}
|
implementation.extendsFrom shade
|
||||||
|
engineMappings
|
||||||
repositories {
|
}
|
||||||
mavenCentral()
|
|
||||||
}
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
dependencies {
|
}
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
dependencies {
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
// Dear ImGui. The binding contains the Java classes, lwjgl3 the GL3/GLFW backend and
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
// 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).
|
// Dear ImGui. The binding contains the Java classes, lwjgl3 the GL3/GLFW backend and
|
||||||
shade "io.github.spair:imgui-java-binding:${project.imgui_version}"
|
// natives-* the imgui-java64 libraries (extracted from the jar at runtime by imgui-java).
|
||||||
// imgui-java-lwjgl3 pulls LWJGL 3.4.1 transitively, which replaces Minecraft's 3.3.3 jars and breaks world saving
|
// Linux natives are x86_64 only; the macOS dylib is universal (x86_64 + arm64).
|
||||||
shade("io.github.spair:imgui-java-lwjgl3:${project.imgui_version}") { exclude group: 'org.lwjgl' }
|
shade "io.github.spair:imgui-java-binding:${project.imgui_version}"
|
||||||
shade "io.github.spair:imgui-java-natives-windows:${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-natives-linux:${project.imgui_version}"
|
shade("io.github.spair:imgui-java-lwjgl3:${project.imgui_version}") { exclude group: 'org.lwjgl' }
|
||||||
shade "io.github.spair:imgui-java-natives-macos:${project.imgui_version}"
|
shade "io.github.spair:imgui-java-natives-windows:${project.imgui_version}"
|
||||||
|
shade "io.github.spair:imgui-java-natives-linux:${project.imgui_version}"
|
||||||
// ClassTransform (net.lenni0451, customised build); engine/EnginePlugin uses it to apply the client's @CTransformer hooks.
|
shade "io.github.spair:imgui-java-natives-macos:${project.imgui_version}"
|
||||||
shade files('libs/classtransform-bundled.jar')
|
|
||||||
// Yarn tiny shipped as prestige-engine/mappings.tiny for the production (Intermediary) runtime
|
// ClassTransform (net.lenni0451, customised build); engine/EnginePlugin uses it to apply the client's @CTransformer hooks.
|
||||||
engineMappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
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 {
|
}
|
||||||
inputs.property "version", project.version
|
|
||||||
filteringCharset "UTF-8"
|
processResources {
|
||||||
filesMatching("fabric.mod.json") {
|
exclude { it.name.endsWith('.accesswidener') && it.name != accessWidener }
|
||||||
expand "version": project.version
|
inputs.property "version", project.version
|
||||||
}
|
inputs.property "minecraft_version", project.minecraft_version
|
||||||
}
|
filteringCharset "UTF-8"
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
tasks.withType(JavaCompile).configureEach {
|
expand "version": project.version, "minecraft_version": project.minecraft_version, "access_widener": accessWidener
|
||||||
options.encoding = "UTF-8"
|
}
|
||||||
options.release = 21
|
filesMatching("prestige-engine/minecraft-version.txt") {
|
||||||
}
|
expand "minecraft_version": project.minecraft_version
|
||||||
|
}
|
||||||
java {
|
if (stonecutter.eval(stonecutter.current.version, '<1.21.11')) {
|
||||||
sourceCompatibility = JavaVersion.VERSION_21
|
doLast {
|
||||||
targetCompatibility = JavaVersion.VERSION_21
|
def manifestFile = new File(destinationDir, 'prestige_ui/manifest_live.json')
|
||||||
withSourcesJar()
|
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) }
|
||||||
jar {
|
manifestFile.text = groovy.json.JsonOutput.toJson(manifest)
|
||||||
// Optional custom native builds take precedence over the upstream binaries.
|
['modules.tsv', 'settings.tsv'].each { name ->
|
||||||
from('build/core-natives') {
|
def table = new File(destinationDir, "prestige_ui/${name}")
|
||||||
into 'prestige-natives'
|
table.text = table.readLines('UTF-8').findAll { row ->
|
||||||
}
|
!unavailable.contains(row.split('\t', -1)[name == 'modules.tsv' ? 1 : 0])
|
||||||
from('build/arm-natives') {
|
}.join('\n') + '\n'
|
||||||
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) }
|
|
||||||
}) {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
exclude 'META-INF/MANIFEST.MF', 'META-INF/*.SF', 'META-INF/*.RSA', 'META-INF/*.DSA'
|
options.encoding = "UTF-8"
|
||||||
exclude 'module-info.class', 'META-INF/versions/**'
|
options.release = 21
|
||||||
exclude 'imgui/extension/**'
|
options.compilerArgs += ['-Xmaxerrs', '1000']
|
||||||
if (file('build/core-natives/windows-x86_64/imgui-java64.dll').isFile()) {
|
}
|
||||||
exclude 'io/imgui/java/native-bin/imgui-java64.dll'
|
|
||||||
}
|
// Each version's compiled transformer annotations own the target set. Generate
|
||||||
if (file('build/core-natives/linux-x86_64/libimgui-java64.so').isFile()) {
|
// anchors from them so renamed/merged game classes cannot leave stale targets.
|
||||||
exclude 'io/imgui/java/native-bin/libimgui-java64.so'
|
def engineSources = layout.buildDirectory.dir('generated/engine/java')
|
||||||
}
|
def engineResources = layout.buildDirectory.dir('generated/engine/resources')
|
||||||
if (file('build/core-natives/macos-universal/libimgui-java64.dylib').isFile()) {
|
def generateEngineMetadata = tasks.register('generateEngineMetadata') {
|
||||||
exclude 'io/imgui/java/native-bin/libimgui-java64.dylib'
|
dependsOn tasks.named('compileJava')
|
||||||
}
|
inputs.files(tasks.named('compileJava').flatMap { it.destinationDirectory })
|
||||||
}
|
inputs.files(configurations.engineMappings)
|
||||||
from({ zipTree(configurations.engineMappings.singleFile) }) {
|
outputs.dirs(engineSources, engineResources)
|
||||||
include 'mappings/mappings.tiny'
|
doLast {
|
||||||
eachFile { it.relativePath = new RelativePath(true, 'prestige-engine', 'mappings.tiny') }
|
def namedToIntermediary = [:]
|
||||||
includeEmptyDirs = false
|
new java.util.zip.ZipFile(configurations.engineMappings.singleFile).withCloseable { zip ->
|
||||||
}
|
zip.getInputStream(zip.getEntry('mappings/mappings.tiny')).withReader('UTF-8') { reader ->
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
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
|
||||||
|
}
|
||||||
Reference in new issue
Block a user