@rust-js/native 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/compiler +0 -0
- package/bin/rust-js +30 -0
- package/package.json +27 -0
package/bin/compiler
ADDED
|
Binary file
|
package/bin/rust-js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Packaged beside bin/compiler and package.json; no source-checkout paths.
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
7
|
+
|
|
8
|
+
const bin = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const metadata = JSON.parse(readFileSync(join(bin, "../package.json"), "utf8"));
|
|
10
|
+
const { toolchain } = metadata.rustJs;
|
|
11
|
+
try {
|
|
12
|
+
const result = spawnSync("rustc", [`+${toolchain}`, "--print", "sysroot"], { encoding: "utf8" });
|
|
13
|
+
if (result.error) throw result.error;
|
|
14
|
+
if (result.status !== 0) throw new Error(`rust-js runs with Rust ${toolchain}; install it once:\n rustup toolchain install ${toolchain} --profile minimal --target wasm32-unknown-unknown\n${result.stderr}`);
|
|
15
|
+
const sysroot = result.stdout.toString().trim();
|
|
16
|
+
const key = process.platform === "darwin" ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH";
|
|
17
|
+
const libraryPath = [join(sysroot, "lib"), process.env[key]].filter(Boolean).join(":");
|
|
18
|
+
const child = spawn(join(bin, "compiler"), process.argv.slice(2), {
|
|
19
|
+
env: { ...process.env, [key]: libraryPath },
|
|
20
|
+
stdio: "inherit",
|
|
21
|
+
});
|
|
22
|
+
child.on("error", error => { console.error(error.message); process.exitCode = 1; });
|
|
23
|
+
child.on("exit", (code, signal) => {
|
|
24
|
+
if (signal) process.kill(process.pid, signal);
|
|
25
|
+
else process.exitCode = code;
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(error.message);
|
|
29
|
+
process.exitCode = 1;
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rust-js/native",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/rust-js-lang/rust-js.git"
|
|
9
|
+
},
|
|
10
|
+
"os": [
|
|
11
|
+
"darwin"
|
|
12
|
+
],
|
|
13
|
+
"cpu": [
|
|
14
|
+
"arm64"
|
|
15
|
+
],
|
|
16
|
+
"bin": {
|
|
17
|
+
"rust-js": "bin/rust-js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"bin"
|
|
21
|
+
],
|
|
22
|
+
"rustJs": {
|
|
23
|
+
"version": "0.0.1",
|
|
24
|
+
"toolchain": "1.98.1",
|
|
25
|
+
"abi": 1
|
|
26
|
+
}
|
|
27
|
+
}
|