MCPcopy Create free account
hub / github.com/cloudflare/computer / buildTarget

Function buildTarget

packages/computerd/scripts/build-bin.mjs:79–135  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

77}
78
79async function buildTarget(target) {
80 const bundlePath = resolve(seaWorkDir, `${target.name}.bundle.mjs`);
81 const blobPath = resolve(seaWorkDir, `${target.name}.blob`);
82 const configPath = resolve(seaWorkDir, `${target.name}.sea-config.json`);
83 const outBin = resolve(outputDir, target.outputName);
84
85 await bundleComputerd({ outfile: bundlePath, target });
86
87 await writeFile(
88 configPath,
89 JSON.stringify(
90 {
91 main: resolve(here, "sea/bootstrap.cjs"),
92 output: blobPath,
93 disableExperimentalSEAWarning: true,
94 useSnapshot: false,
95 useCodeCache: false,
96 assets: {
97 "bundle.mjs": bundlePath,
98 "fuse-native.node": resolve(repoRoot, target.addon),
99 [target.libfuseName]: resolve(repoRoot, target.libfuse),
100 },
101 },
102 null,
103 2,
104 ),
105 );
106
107 await execFileP(process.execPath, ["--experimental-sea-config", configPath]);
108
109 const nodeBinary = await ensureTargetNodeBinary(target);
110 await copyFile(nodeBinary, outBin);
111 await chmod(outBin, 0o755);
112
113 if (target.isMac) {
114 // `codesign --remove-signature` only exists on macOS hosts. Skip with a
115 // warning on linux build hosts — the binary will still load on macOS
116 // after the user (or a downstream signer) re-signs it.
117 await maybe(execFileP("codesign", ["--remove-signature", outBin]));
118 }
119
120 const postjectArgs = [
121 resolve(repoRoot, "node_modules/postject/dist/cli.js"),
122 outBin,
123 "NODE_SEA_BLOB",
124 blobPath,
125 "--sentinel-fuse",
126 "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2",
127 "--overwrite",
128 ];
129 if (target.isMac) postjectArgs.push("--macho-segment-name", "NODE_SEA");
130 await execFileP(process.execPath, postjectArgs);
131
132 if (target.isMac) {
133 await maybe(execFileP("codesign", ["--sign", "-", outBin]));
134 }
135}
136

Callers 1

mainFunction · 0.85

Calls 6

bundleComputerdFunction · 0.90
ensureTargetNodeBinaryFunction · 0.85
maybeFunction · 0.85
pushMethod · 0.65
writeFileFunction · 0.50
chmodFunction · 0.50

Tested by

no test coverage detected