mirror of
https://github.com/penpot/penpot.git
synced 2026-11-10 03:50:33 +00:00
🔧 Allow skipping renderer build setup via env. var (#12882)
Set PENPOT_WASM_PREPARED=1 to speed up repeated builds
This commit is contained in:
parent
943e63a99e
commit
33602b9114
@ -52,6 +52,11 @@ Each target keeps its own `CARGO_TARGET_DIR` (`target/<target>`), so switching
|
||||
between them does not invalidate the other's cache. Set `BUILD_MODE=release`
|
||||
(or `NODE_ENV=production`) for an optimized build; the default is `debug`.
|
||||
|
||||
Set `PENPOT_WASM_PREPARED=1` when the pinned Rust toolchain is selected, its
|
||||
Emscripten target is installed, and this package's Node dependencies are
|
||||
installed. `./build` and `./test` then skip `rustup` setup and `pnpm install`.
|
||||
Benchmark preparation sets this flag for each retained build.
|
||||
|
||||
### Serialize builds in one checkout
|
||||
|
||||
All targets in one checkout share one `flock` lock stored at
|
||||
|
||||
@ -164,6 +164,11 @@ function setup_rust {
|
||||
}
|
||||
|
||||
function setup {
|
||||
if [ "${PENPOT_WASM_PREPARED:-}" = "1" ]; then
|
||||
echo "Skipping rustup and pnpm setup (PENPOT_WASM_PREPARED=1)" >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
setup_rust
|
||||
pnpm install;
|
||||
}
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
# Usage: ./build [frontend|export] [extra cargo params...]
|
||||
#
|
||||
# With no target, builds both. Set BUILD_MODE=release (or NODE_ENV=production)
|
||||
# for an optimized build. See `_build_env` for what each target changes.
|
||||
# for an optimized build. Set PENPOT_WASM_PREPARED=1 when the pinned toolchain
|
||||
# and Node dependencies are prepared to skip their setup. See `_build_env` for
|
||||
# what each target changes.
|
||||
|
||||
_SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
_RENDER_TARGET=${1:-}
|
||||
|
||||
@ -347,3 +347,58 @@ test("rejects malformed Cargo JSON and removes stale build facts", (t) => {
|
||||
assert.match(result.stderr, /ERROR:/);
|
||||
assert.equal(fs.existsSync(f.info), false);
|
||||
});
|
||||
|
||||
function runSetup(t, prepared) {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "render-wasm-setup-"));
|
||||
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
||||
const bin = path.join(root, "bin");
|
||||
const marker = path.join(root, "calls");
|
||||
fs.mkdirSync(bin);
|
||||
for (const name of ["rustup", "pnpm"]) {
|
||||
fs.writeFileSync(
|
||||
path.join(bin, name),
|
||||
`#!/bin/sh\nprintf '%s\\n' "${name} $*" >> "$MARKER"\n`,
|
||||
{ mode: 0o755 },
|
||||
);
|
||||
}
|
||||
const env = {
|
||||
...process.env,
|
||||
MARKER: marker,
|
||||
PATH: `${bin}:${process.env.PATH}`,
|
||||
};
|
||||
if (prepared === undefined) {
|
||||
delete env.PENPOT_WASM_PREPARED;
|
||||
} else {
|
||||
env.PENPOT_WASM_PREPARED = prepared;
|
||||
}
|
||||
const result = spawnSync(
|
||||
"bash",
|
||||
[
|
||||
"--noprofile",
|
||||
"--norc",
|
||||
"-c",
|
||||
'source "$1" frontend; setup',
|
||||
"setup-test",
|
||||
path.resolve(__dirname, "..", "_build_env"),
|
||||
],
|
||||
{
|
||||
cwd: path.resolve(__dirname, ".."),
|
||||
env,
|
||||
encoding: "utf8",
|
||||
},
|
||||
);
|
||||
assert.equal(result.status, 0, result.stderr);
|
||||
return fs.existsSync(marker) ? fs.readFileSync(marker, "utf8") : "";
|
||||
}
|
||||
|
||||
test("prepared setup skips rustup and pnpm", (t) => {
|
||||
const normal = runSetup(t);
|
||||
assert.match(normal, /^rustup default /m);
|
||||
assert.match(normal, /^pnpm install$/m);
|
||||
|
||||
const disabled = runSetup(t, "0");
|
||||
assert.match(disabled, /^rustup default /m);
|
||||
assert.match(disabled, /^pnpm install$/m);
|
||||
|
||||
assert.equal(runSetup(t, "1"), "");
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user