Sync local working tree: injector, engine, mixin and build updates
Add compatibility notes, resource-provider and hook checks, and payload bundling script. Remove generated engine mixin stubs, engine target lists and prebuilt binaries now produced by the build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6d94493e58
commit
05d169a2dd
210 files changed
+1862
-849
No files matched your search
@@ -1,46 +1,33 @@
|
||||
//! Locates the remapped Prestige payload jar (built by `gradlew remapJar`) so lib.rs can embed it with include_bytes!.
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
//! Embed exact-version payloads and one copy of their common libraries.
|
||||
use std::{env, fs, path::{Path, PathBuf}};
|
||||
|
||||
fn include(path: &Path) -> String {
|
||||
let path = path.canonicalize().unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
format!("include_bytes!({:?})", path.to_str().expect("UTF-8 payload path"))
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-env-changed=PRESTIGE_PAYLOAD");
|
||||
let jar = match env::var("PRESTIGE_PAYLOAD") {
|
||||
Ok(p) => PathBuf::from(p),
|
||||
Err(_) => newest_remapped_jar(),
|
||||
};
|
||||
if !jar.is_file() {
|
||||
panic!(
|
||||
"payload jar not found: {} (run `gradlew remapJar` or set PRESTIGE_PAYLOAD)",
|
||||
jar.display()
|
||||
);
|
||||
}
|
||||
println!("cargo:rerun-if-changed={}", jar.display());
|
||||
println!("cargo:rustc-env=PRESTIGE_PAYLOAD_JAR={}", jar.display());
|
||||
}
|
||||
|
||||
fn newest_remapped_jar() -> PathBuf {
|
||||
let libs = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("../../../build/libs");
|
||||
let mut best: Option<(std::time::SystemTime, PathBuf)> = None;
|
||||
if let Ok(entries) = fs::read_dir(&libs) {
|
||||
for entry in entries.flatten() {
|
||||
let name = entry.file_name().to_string_lossy().to_string();
|
||||
if !name.starts_with("prestige-")
|
||||
|| !name.ends_with(".jar")
|
||||
|| name.ends_with("-dev.jar")
|
||||
|| name.ends_with("-sources.jar")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let time = entry
|
||||
.metadata()
|
||||
.and_then(|m| m.modified())
|
||||
.unwrap_or(std::time::UNIX_EPOCH);
|
||||
if best.as_ref().map_or(true, |(t, _)| time > *t) {
|
||||
best = Some((time, entry.path()));
|
||||
}
|
||||
println!("cargo:rerun-if-env-changed=PRESTIGE_BUNDLE");
|
||||
let generated = if let Ok(jar) = env::var("PRESTIGE_PAYLOAD") {
|
||||
// Explicit single-target developer builds retain Java's exact-target guard.
|
||||
format!("static COMMON: &[u8] = &[];\nstatic PAYLOADS: &[(&str, &[u8])] = &[(\"\", {})];", include(Path::new(&jar)))
|
||||
} else {
|
||||
let dir = env::var_os("PRESTIGE_BUNDLE").map(PathBuf::from).unwrap_or_else(||
|
||||
PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("../../../build/bundle"));
|
||||
let manifest = dir.join("versions.txt");
|
||||
println!("cargo:rerun-if-changed={}", manifest.display());
|
||||
let versions = fs::read_to_string(&manifest)
|
||||
.expect("run gradlew bundlePayloads before building the native bundle");
|
||||
let expected: Vec<_> = (1..=11).map(|n| format!("1.21.{n}")).collect();
|
||||
assert_eq!(versions.lines().collect::<Vec<_>>(), expected, "incomplete payload matrix");
|
||||
let mut code = format!("static COMMON: &[u8] = {};\nstatic PAYLOADS: &[(&str, &[u8])] = &[\n", include(&dir.join("common.jar")));
|
||||
for version in versions.lines() {
|
||||
code.push_str(&format!("({version:?}, {}),\n", include(&dir.join(format!("{version}.jar")))));
|
||||
}
|
||||
}
|
||||
best.map(|(_, p)| p)
|
||||
.unwrap_or_else(|| libs.join("prestige-0.1.0.jar"))
|
||||
code.push_str("];\n");
|
||||
code
|
||||
};
|
||||
fs::write(PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("payloads.rs"), generated).unwrap();
|
||||
}
|
||||
Reference in new issue
Block a user