-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[WRONG BRANCH] feat(standalone): compiled npm-free ocx binary (desktop stack 1/5)
#5256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
09c9bff
22bcf1e
dc351ea
a88aa53
e596e24
20bb8cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { createHash } from "node:crypto"; | ||
| import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; | ||
| import { join, resolve } from "node:path"; | ||
|
|
||
| const targets = new Set([ | ||
| "bun-darwin-arm64", | ||
| "bun-darwin-x64", | ||
| "bun-windows-x64", | ||
| "bun-linux-x64", | ||
| "bun-linux-arm64", | ||
| ]); | ||
|
|
||
| function hostTarget(): string { | ||
| const platform = process.platform === "darwin" ? "darwin" : process.platform === "win32" ? "windows" : "linux"; | ||
| const arch = process.arch === "arm64" ? "arm64" : "x64"; | ||
| return `bun-${platform}-${arch}`; | ||
| } | ||
|
|
||
| function argumentValue(name: string): string | undefined { | ||
| const index = Bun.argv.indexOf(name); | ||
| return index >= 0 ? Bun.argv[index + 1] : undefined; | ||
| } | ||
|
|
||
| const target = argumentValue("--target") ?? hostTarget(); | ||
| if (!targets.has(target)) { | ||
| throw new Error(`Unsupported standalone target: ${target}`); | ||
| } | ||
|
|
||
| const repoRoot = resolve(import.meta.dir, ".."); | ||
| const guiDist = join(repoRoot, "gui", "dist"); | ||
| if (!existsSync(join(guiDist, "index.html"))) { | ||
| throw new Error("gui/dist is missing; run `bun run build:gui` first"); | ||
| } | ||
|
|
||
| const output = resolve(argumentValue("--out") ?? join(repoRoot, "dist", "standalone", target)); | ||
| mkdirSync(output, { recursive: true }); | ||
| const executable = join(output, target.startsWith("bun-windows-") ? "ocx.exe" : "ocx"); | ||
| const result = Bun.spawnSync([ | ||
| process.execPath, | ||
| "build", | ||
| "--compile", | ||
| "--target", | ||
| target, | ||
| join(repoRoot, "src", "cli", "index.ts"), | ||
| "--outfile", | ||
| executable, | ||
| ], { stdout: "inherit", stderr: "inherit" }); | ||
| if (result.exitCode !== 0) process.exit(result.exitCode); | ||
|
|
||
| cpSync(guiDist, join(output, "gui", "dist"), { recursive: true }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The standalone output copies only Useful? React with 👍 / 👎. |
||
| const digest = createHash("sha256").update(readFileSync(executable)).digest("hex"); | ||
| writeFileSync(join(output, "SHA256SUMS"), `${digest} ${executable.split(/[\\/]/).pop()}\n`); | ||
| console.log(`Built ${executable}`); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the
package-standalonearchive step, passingdist/ocx-...tosha256sumrecords that full relative path inside every sidecar. The attach job later flattens the artifacts intodist/release, changes into that directory, and runsshasum -a 256 -c, so it looks fordist/release/dist/ocx-...and fails before uploading any release assets. This is consistent withshasum --help, which says-creads sums from the supplied files and generated checksum lines contain the name of each input file; generate the sidecar while insidedistor otherwise record only the archive basename.Useful? React with 👍 / 👎.