Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 94 additions & 2 deletions kitchen/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions kitchen/electrobun.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,28 @@ export default {
// "show-composited-layer-borders": true,
"user-agent": "BarkusAurelius/1.0 (Macintosh; powered by bunnies)",
},
nsis: {
enabled: true,
// enabled: true, // default: true
// installMode: "currentUser", // "currentUser" | "perMachine"
// allowDowngrades: false,
// publisher: "Blackboard Inc.",
// homepage: "https://electrobun.dev",
// desktopShortcut: true,
// startMenuFolder: "Electrobun Kitchen Sink",
// appDataPaths: ["sh.blackboard.electrobun-kitchen"],
},
msi: {
// enabled: true, // default: true
// publisher: "Blackboard Inc.",
// upgradeCode: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // stable GUID; auto-derived if omitted
// installMode: "currentUser", // "currentUser" | "perMachine"
// allowDowngrades: false,
// desktopShortcut: true,
// startMenuFolder: "Electrobun Kitchen Sink",
// additionalCandleArgs: [],
// additionalLightArgs: [],
},
},
},
scripts: {
Expand Down
5 changes: 2 additions & 3 deletions kitchen/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package/bin/electrobun.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ async function ensureCliBinary() {
// Download tarball
await downloadFile(tarballUrl, tarballPath);

// Extract using system tar (available on macOS, Linux, and Windows 10+)
execSync(`tar -xzf "${tarballPath}"`, { cwd: cacheDir, stdio: 'pipe' });
// Extract using system tar (available on macOS, Linux, and Windows 10+).
// Use basename only: cwd is set to cacheDir, and tar on Windows (Git Bash)
// interprets absolute Windows paths like "C:\..." as remote URLs.
const tarballFilename = require('path').basename(tarballPath);
execSync(`tar -xzf "${tarballFilename}"`, { cwd: cacheDir, stdio: 'pipe' });

// Clean up tarball
unlinkSync(tarballPath);
Expand Down
57 changes: 42 additions & 15 deletions package/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ try {

// Global variables to store build tool paths
var CMAKE_BIN = "cmake";
var VS_CMAKE_GENERATOR = "Visual Studio 17 2022";

async function vendorCmake() {
if (OS !== "macos") return;
Expand Down Expand Up @@ -239,6 +240,27 @@ async function findMsvcTools() {
return;
}

// Detect VS version to pick the correct CMake generator
try {
const vsVersionResult =
await $`powershell -command "& '${vswherePath}' -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationVersion"`.quiet();
const versionStr = vsVersionResult.stdout.toString().trim();
const majorVersion = parseInt(versionStr.split(".")[0], 10);
const generatorMap: Record<number, string> = {
14: "Visual Studio 14 2015",
15: "Visual Studio 15 2017",
16: "Visual Studio 16 2019",
17: "Visual Studio 17 2022",
18: "Visual Studio 18 2026",
};
if (generatorMap[majorVersion]) {
VS_CMAKE_GENERATOR = generatorMap[majorVersion];
console.log(`✓ Detected VS generator: ${VS_CMAKE_GENERATOR}`);
}
} catch {
console.log("Could not detect VS version, using default CMake generator");
}

console.log("✓ Found MSVC tools with vcvarsall.bat");
} catch {
console.log("Could not locate MSVC tools, using default tool names");
Expand Down Expand Up @@ -534,7 +556,10 @@ async function copyToDist() {
await $`cp ${PATH.bun.RUNTIME} ${PATH.bun.DIST}`;
// Zig launcher for all platforms
await $`cp src/launcher/zig-out/bin/launcher${binExt} dist/launcher${binExt}`;
await $`cp src/extractor/zig-out/bin/extractor${binExt} dist/extractor${binExt}`;
// Extractor is only built for macOS/Linux release builds.
if (OS !== "win" && CHANNEL !== "debug") {
await $`cp src/extractor/zig-out/bin/extractor${binExt} dist/extractor${binExt}`;
}
// Copy bsdiff/bspatch from vendored zig-bsdiff
await $`cp vendors/zig-bsdiff/bsdiff${binExt} dist/bsdiff${binExt}`;
await $`cp vendors/zig-bsdiff/bspatch${binExt} dist/bspatch${binExt}`;
Expand Down Expand Up @@ -1209,8 +1234,14 @@ async function vendorAsar() {
// Validate download
validateDownload(tempTarball, "zig-asar");

// Extract to architecture-specific directory
await $`tar -xzf "${tempTarball}" -C "${asarDir}"`;
// Extract to architecture-specific directory.
// On Windows, Git Bash's tar cannot handle absolute Windows paths in -C
// (it interprets "C:" as a remote hostname). Convert to Unix-style path.
const tarExtractDir =
OS === "win"
? asarDir.replace(/\\/g, "/").replace(/^([A-Za-z]):/, "/$1")
: asarDir;
await $`tar -xzf "${tempTarball}" -C "${tarExtractDir}"`;

// Clean up temp file
await $`rm "${tempTarball}"`;
Expand Down Expand Up @@ -1520,7 +1551,7 @@ async function vendorCEF() {
await $`cd vendors/cef && powershell -command "if (Test-Path build) { Remove-Item -Recurse -Force build }"`;
await $`cd vendors/cef && mkdir build`;
// Generate Visual Studio project with sandbox disabled
await $`cd vendors/cef/build && "${CMAKE_BIN}" -G "Visual Studio 17 2022" -A x64 -DCEF_USE_SANDBOX=OFF -DCMAKE_BUILD_TYPE=Release ..`;
await $`cd vendors/cef/build && "${CMAKE_BIN}" -G "${VS_CMAKE_GENERATOR}" -A x64 -DCEF_USE_SANDBOX=OFF -DCMAKE_BUILD_TYPE=Release ..`;
// Build the wrapper library only
// await $`cd vendors/cef/build && msbuild cef.sln /p:Configuration=Release /p:Platform=x64 /target:libcef_dll_wrapper`;
// const msbuildPath = await $`"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\\**\\Bin\\MSBuild.exe | head -n 1`.text();
Expand Down Expand Up @@ -2058,18 +2089,14 @@ async function buildMainJs() {
}

async function buildSelfExtractor() {
const zigArgs =
OS === "win"
? ["-Dtarget=x86_64-windows", "-Dcpu=baseline"]
: ARCH === "x64"
? ["-Dcpu=baseline"]
: [];
// Extractor is only used during release builds (macOS self-extracting .app,
// Linux self-extracting installer). It is never referenced by `electrobun dev`,
// and Windows uses the NSIS/WiX installer pipeline instead.
if (OS === "win" || CHANNEL === "debug") return;

if (CHANNEL === "debug") {
await $`cd src/extractor && ../../vendors/zig/zig build ${zigArgs}`;
} else if (CHANNEL === "release") {
await $`cd src/extractor && ../../vendors/zig/zig build -Doptimize=ReleaseSmall ${zigArgs}`;
}
const zigArgs = ARCH === "x64" ? ["-Dcpu=baseline"] : [];

await $`cd src/extractor && ../../vendors/zig/zig build -Doptimize=ReleaseSmall ${zigArgs}`;
}

async function buildCli() {
Expand Down
Loading