Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

BL29, GD8, GD2: setup on a clean machine needs no uv, git or shasum; smoke scripts; a clean Linux's libraries recorded

shinyobjectz33d55482543d
diff --git a/apps/engines/src/godot.rs b/apps/engines/src/godot.rs
index 878c9985..5f55a667 100644
--- a/apps/engines/src/godot.rs
+++ b/apps/engines/src/godot.rs
@@ -25,7 +25,12 @@ struct Pin {
}
fn pin() -> R<Pin> {
- match (std::env::consts::OS, std::env::consts::ARCH) {
+ pin_for(std::env::consts::OS, std::env::consts::ARCH)
+}
+
+/// A platform GodotJS doesn't build for is told how to bring its own build (GD2), never given a stock Godot.
+fn pin_for(os: &str, arch: &str) -> R<Pin> {
+ match (os, arch) {
// a universal app, ad-hoc signed
("macos", _) => Ok(Pin { asset: "macos-editor-app-4.6.1-jsc.zip", sha256: "8a3022cb07c9740b2acc4a0b6bba6be78fb2fe46ba172b13abd51e6829cdca95", size: 143_940_673, program: "Godot.app/Contents/MacOS/Godot" }),
("linux", "x86_64") => Ok(Pin { asset: "linux-editor-4.6.1-qjs-ng.zip", sha256: "daa91d6cff5862ed9e0b3776694fbe4ea0ebb474d244f46ffb3aa5af0318989d", size: 78_737_089, program: "godot.linuxbsd.editor.x86_64" }),
@@ -190,6 +195,15 @@ mod tests {
}
}
+ #[test]
+ fn a_platform_godotjs_doesnt_build_for_is_told_to_bring_its_own() {
+ for (os, arch) in [("linux", "aarch64"), ("windows", "aarch64"), ("freebsd", "x86_64")] {
+ let e = pin_for(os, arch).err().unwrap_or_default();
+ assert!(e.contains("github.com/godotjs/GodotJS") && e.contains("git config --global raea.godot PATH"), "{os} {arch}: {e}");
+ }
+ assert!(pin_for("macos", "aarch64").is_ok() && pin_for("linux", "x86_64").is_ok() && pin_for("windows", "x86_64").is_ok());
+ }
+
#[test]
fn unzip_drops_the_top_folder() {
let base = std::env::temp_dir().join(format!("raea-godot-unzip-{}", std::process::id()));
diff --git a/apps/tools/src/blender.rs b/apps/tools/src/blender.rs
index db56d231..397f4256 100644
--- a/apps/tools/src/blender.rs
+++ b/apps/tools/src/blender.rs
@@ -53,9 +53,20 @@ pub fn find() -> Option<(PathBuf, &'static str)> {
/// `blender --version`'s first line ("Blender 5.2.1 LTS").
fn version(bin: &Path) -> R<String> {
let o = Command::new(bin).arg("--version").output().map_err(|e| format!("{}: {e}", bin.display()))?;
- String::from_utf8_lossy(&o.stdout).lines().find(|l| l.starts_with("Blender ")).map(str::to_string).ok_or_else(|| format!("{} --version printed no version", bin.display()))
+ String::from_utf8_lossy(&o.stdout).lines().find(|l| l.starts_with("Blender ")).map(str::to_string).ok_or_else(|| {
+ let err = String::from_utf8_lossy(&o.stderr);
+ if err.contains("error while loading shared libraries") {
+ format!("{} can't start: {} (on Debian or Ubuntu: apt install {LINUX_LIBS})", bin.display(), err.trim())
+ } else {
+ format!("{} --version printed no version", bin.display())
+ }
+ })
}
+/// What Blender's Linux build needs that a slim Debian (trixie) lacks: found 11-11 by running it in debian:trixie-slim
+/// (docs/blender.feature BL29); CUDA, HIP and oneAPI are loaded only when Cycles renders on those GPUs.
+const LINUX_LIBS: &str = "libx11-6 libxi6 libxext6 libxfixes3 libxrender1 libxkbcommon0 libsm6 libice6 libgl1 libopengl0";
+
pub fn run(cmd: &mut Command, what: &str) -> R<String> {
let o = cmd.output().map_err(|e| format!("{what}: {e}"))?;
if !o.status.success() {
@@ -94,8 +105,11 @@ fn newest(listing: &str) -> Option<String> {
pub fn sha256(file: &Path) -> R<String> {
let out = if cfg!(windows) {
run(Command::new("certutil").arg("-hashfile").arg(file).arg("SHA256"), "certutil")?.lines().nth(1).unwrap_or_default().replace(' ', "")
- } else {
+ } else if on_path("shasum").is_some() {
run(Command::new("shasum").args(["-a", "256"]).arg(file), "shasum")?.split_whitespace().next().unwrap_or_default().to_string()
+ } else {
+ // a slim Linux (debian:trixie-slim) has coreutils' sha256sum, not perl's shasum
+ run(Command::new("sha256sum").arg(file), "sha256sum")?.split_whitespace().next().unwrap_or_default().to_string()
};
Ok(out.to_lowercase())
}
@@ -174,7 +188,10 @@ fn addon(bin: &Path, check: bool) -> R<String> {
if check {
return Ok("MCP add-on not installed: raea setup blender installs it".into());
}
- let uvx = on_path(if cfg!(windows) { "uvx.exe" } else { "uvx" }).ok_or("the MCP add-on comes from uv's uvx: install uv (https://docs.astral.sh/uv/getting-started/installation/), then run raea setup blender again")?;
+ // the MCP add-on is for agents; scripts don't need it, so a machine without uv still finishes its setup
+ let Some(uvx) = on_path(if cfg!(windows) { "uvx.exe" } else { "uvx" }) else {
+ return Ok("MCP add-on not installed: it comes from uv's uvx (install uv: https://docs.astral.sh/uv/getting-started/installation/, then raea setup blender again)".into());
+ };
let dir = py(bin, ADDONS_DIR, "RAEA_ADDONS=")?;
run(Command::new(&uvx).args(["mcp-for-blender", "install-addon", "--addons-dir", &dir]), "uvx mcp-for-blender install-addon")?;
enable(bin, "blender_mcp", &dir, "MCP for Blender")?;
@@ -223,7 +240,9 @@ pub fn setup(args: &[String]) -> R<String> {
None if check => return Ok(format!("CHECKED no Blender found (raea.blender, {}, PATH): raea setup blender downloads Blender {LTS} LTS", own_dir("blender")?.display())),
None => {
let (b, f) = download()?;
- run(Command::new("git").args(["config", "--global", "raea.blender"]).arg(&b), "git config")?;
+ // remembered for tools that read raea.blender; find() takes raea's download anyway, so a machine without
+ // git (a Mac before its command line tools, Windows) is set up all the same
+ let _ = run(Command::new("git").args(["config", "--global", "raea.blender"]).arg(&b), "git config");
(b, f)
}
};
@@ -283,6 +302,15 @@ mod tests {
assert_eq!(newest("nothing here"), None);
}
+ #[test]
+ fn sha256_of_a_known_file() {
+ let f = std::env::temp_dir().join(format!("raea-sha256-{}", std::process::id()));
+ std::fs::write(&f, b"abc").unwrap();
+ let got = sha256(&f);
+ let _ = std::fs::remove_file(&f);
+ assert_eq!(got.unwrap(), "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
+ }
+
#[test]
fn every_supported_platform_names_one_file() {
assert!(asset("5.2.1").unwrap().starts_with("blender-5.2.1-"));
diff --git a/docs/blender.feature b/docs/blender.feature
index 19e7ab27..7539f2b8 100644
--- a/docs/blender.feature
+++ b/docs/blender.feature
@@ -187,3 +187,14 @@ Feature: Blender as a measured workshop step: an asset passes through it on its
Scenario: BL29. A clean machine on each platform (macOS, Windows, Linux) runs a TypeScript script through raea/blender
Given an empty HOME, `raea setup blender` then `raea blender run smoke.ts`
Then the script prints its PASS line, and the download size and the libraries a clean Linux needs are recorded
+ And 11-11, macOS (Apple silicon): an empty HOME and only the system's PATH (no uv, no Bun), `raea setup blender
+ --download` then `raea blender run smoke.ts alpha --beta` (sdk/blender/test/smoke.ts) printed its PASS line in
+ Blender 5.2.4 LTS: a 346 MB download, 907 MB installed. Setup finishes without uv (the MCP add-on is a note)
+ and without git
+ And 11-11, Linux (debian:trixie-slim, x86_64, on Modal): setup needs curl, ca-certificates and xz-utils, and
+ checks downloads with coreutils' sha256sum where perl's shasum is missing (a slim Debian has none). Blender
+ 5.2.4's Linux build (385 MB download, 1.2 GB installed) needs libx11-6 libxi6 libxext6 libxfixes3 libxrender1
+ libxkbcommon0 libsm6 libice6 libgl1 libopengl0, which setup names when Blender can't start; with them,
+ smoke.ts run under Bun through raea/blender printed its PASS line
+ And still to run: raea's own Windows and Linux builds of this lane (`raea setup blender`, then `raea blender run
+ smoke.ts`), which come with v0.1.1's release builds
diff --git a/docs/godot.feature b/docs/godot.feature
index b8f00b39..8a0fb7a7 100644
--- a/docs/godot.feature
+++ b/docs/godot.feature
@@ -19,8 +19,11 @@ Feature: Godot from TypeScript: raea/godot (sdk/godot) on GodotJS
And it unpacks without unzip (a clean Linux has none) and the program is made executable (the zips keep no modes)
And raea.json beside it names the release, so a moved pin downloads again
And `git config --global raea.godot PATH` names a GodotJS build of the person's own instead
+ @done
Scenario: GD2. A platform GodotJS doesn't build for is told how to bring its own build, not given a stock Godot
Then a stock Godot is never looked for: without GodotJS it can't run raea/godot's scripts
+ And 11-11: find() takes only raea.godot and raea's download; Linux and Windows on arm64, and any other system,
+ are told to build GodotJS and `git config --global raea.godot PATH` (apps/engines godot.rs, a unit test)
Rule: Godot's whole API is typed
@done
@@ -68,6 +71,13 @@ Feature: Godot from TypeScript: raea/godot (sdk/godot) on GodotJS
Scenario: GD8. A clean machine on each platform (macOS, Windows, Linux) runs a TypeScript script through raea/godot
Given an empty HOME, `raea setup godot` then `raea godot run smoke.ts`
Then the script prints its PASS line, and the download size and the libraries a clean Linux needs are recorded
+ And 11-11, macOS: an empty HOME and only the system's PATH, `raea setup godot` then `raea godot run smoke.ts alpha
+ --beta` (sdk/godot/test/scripts/smoke.ts) printed its PASS line: GodotJS v1.1.0.beta1-4.6.1 with
+ JavaScriptCore, a 144 MB download, 280 MB installed
+ And 11-11, Linux (debian:trixie-slim, x86_64, on Modal): GodotJS's QuickJS-ng editor (a 79 MB download, 155 MB
+ installed) needs no library a slim Debian lacks and starts headless; without libfontconfig1 it says system fonts
+ are off. Setup checks the download with coreutils' sha256sum there (a slim Debian has no shasum)
+ And still to run: raea's own Windows and Linux builds of this lane, which come with v0.1.1's release builds
Rule: The guide teaches it
@done
diff --git a/sdk/blender/test/smoke.ts b/sdk/blender/test/smoke.ts
new file mode 100644
index 00000000..0793532f
--- /dev/null
+++ b/sdk/blender/test/smoke.ts
@@ -0,0 +1,25 @@
+// raea blender run's smoke (BL29): a scene built from TypeScript, a value Blender computes, the maths agreeing with
+// Blender's, one PASS line. Run on a clean machine after `raea setup blender`: raea blender run smoke.ts [ARGS...]
+import { bmesh, bpy, mathutils, py } from "raea/blender";
+
+export default async function () {
+ for (let i = 0; i < 3; i++) await bpy.ops.mesh.primitive_cube_add({ size: 1, location: [i * 2, 0, 0] });
+ const last = (await bpy.context.active_object)!;
+ last.rotation_euler.z = Math.PI / 4;
+ const far = (await last.location).length;
+ // a mesh Blender evaluates: its volume, by bmesh
+ const bm = bmesh.new();
+ bm.from_mesh(bpy.data.meshes.$[await last.data.name]);
+ const volume = await bm.calc_volume();
+ bm.free();
+ // mathutils in TypeScript against Blender's own (matrix_world follows the rotation once the depsgraph updates)
+ bpy.context.view_layer.update();
+ const turned = (await last.matrix_world).to_euler().z;
+ const hit = await mathutils.geometry.intersect_ray_tri([0, 0, 1], [1, 0, 1], [0, 1, 1], [0, 0, -1], [0.2, 0.2, 5]);
+ const objects = await py.len(bpy.context.scene.objects);
+ const args = await py.exec<string[]>("import sys; result = sys.argv[sys.argv.index('--') + 1:] if '--' in sys.argv else []");
+ const v = await bpy.app.version_string;
+ const ok = objects >= 4 && Math.abs(far - 4) < 1e-6 && Math.abs(volume - 1) < 1e-6 && Math.abs(turned - Math.PI / 4) < 1e-5 && hit !== null;
+ if (!ok) throw new Error(`smoke: objects ${objects}, the last ${far} m out, volume ${volume}, turned ${turned}, ray hit ${hit}`);
+ console.log(`PASS raea/blender: 3 cubes made (${objects} objects), the last ${far.toFixed(3)} m out, volume ${volume.toFixed(3)}, in Blender ${v}${args.length ? ` (args ${args.join(" ")})` : ""}`);
+}