MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / buildWithCargoDirectly

Function buildWithCargoDirectly

packages/native/scripts/build-native.mjs:341–377  ·  view source on GitHub ↗
(env, host)

Source from the content-addressed store, hash-verified

339}
340
341function buildWithCargoDirectly(env, host) {
342 const cargoExe = getCargoExePath(env) ?? "cargo";
343 try {
344 execFileSync(cargoExe, ["build", "--release", "--target", host], { stdio: "inherit", env });
345 } catch (err) {
346 if (process.platform === "win32") {
347 process.stderr.write(
348 `${[
349 "",
350 "@rezi-ui/native: cargo build failed on Windows.",
351 "If you see linker errors like `LNK1104: cannot open file 'msvcrt.lib'` or missing headers like `stdint.h`,",
352 "install Visual Studio Build Tools (MSVC v143 + Windows 10/11 SDK) and run the build from a VS Developer shell.",
353 "",
354 ].join("\n")}\n`,
355 );
356 }
357 throw err;
358 }
359
360 const crateName = "rezi_ui_native";
361 const targetDir = join(process.cwd(), "target", host, "release");
362 const built =
363 process.platform === "win32"
364 ? join(targetDir, `${crateName}.dll`)
365 : process.platform === "darwin"
366 ? join(targetDir, `lib${crateName}.dylib`)
367 : join(targetDir, `lib${crateName}.so`);
368
369 if (!existsSync(built)) {
370 throw new Error(`@rezi-ui/native: cargo build succeeded but output was not found: ${built}`);
371 }
372
373 // Node loads addons as .node (they are native shared libraries under the hood).
374 // Keep both filenames as candidates for the JS loader.
375 copyFileSync(built, join(process.cwd(), "rezi_ui_native.node"));
376 copyFileSync(built, join(process.cwd(), "index.node"));
377}
378
379function getHostTargetTriple() {
380 let out;

Callers 1

build-native.mjsFile · 0.85

Calls 2

getCargoExePathFunction · 0.85
writeMethod · 0.65

Tested by

no test coverage detected