// deno run --allow-read --allow-write desktop/linux_launcher.ts dist/bworld // deno desktop has no setting for chromium's command line, but its linux launcher passes its arguments on to chromium. // so this moves the launcher to bworld-bin and puts a script in its place that starts it with the switches webgpu // needs on some linux setups. run it on the app folder after deno desktop builds it; running it again does nothing const SWITCHES = [ "--enable-unsafe-webgpu", "--ozone-platform=x11", "--use-angle=vulkan", "--enable-features=Vulkan,VulkanFromANGLE", ]; const dir = Deno.args[0]; if (!dir) { console.error("usage: linux_launcher.ts , like dist/bworld"); Deno.exit(1); } const name = dir.replace(/\/+$/, "").split("/").pop()!; const launcher = `${dir}/${name}`; const binary = `${launcher}-bin`; // already wrapped: the launcher is a script now const head = new Uint8Array(4); const file = Deno.openSync(launcher); file.readSync(head); file.close(); const is_elf = head[0] === 0x7f && head[1] === 0x45 && head[2] === 0x4c && head[3] === 0x46; if (!is_elf) { console.log(`${launcher} is already wrapped`); Deno.exit(0); } Deno.renameSync(launcher, binary); Deno.writeTextFileSync( launcher, `#!/bin/sh # starts ${name} with the chromium switches webgpu needs on some linux setups, see desktop/linux_launcher.ts. # BWORLD_CHROMIUM_FLAGS replaces them, set it to "" to start without any here="$(dirname "$(readlink -f "$0")")" # the binary finds its runtime by its own name, which is ${name}.so and not ${name}-bin.so export LAUFEY_RUNTIME_PATH="$here/${name}.so" exec "$here/${name}-bin" \${BWORLD_CHROMIUM_FLAGS-${SWITCHES.join(" ")}} "$@" `, ); Deno.chmodSync(launcher, 0o755); console.log(`Wrapped ${launcher}: ${SWITCHES.join(" ")}`);