farmcontrol-ui/scripts/build-macos-effects.mjs
Tom Butcher 274852b895
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
Add macOS vibrancy support and related build scripts
- Introduced native macOS window effects with a new dynamic library for enhanced UI.
- Updated build scripts to compile the macOS effects library and integrate it into the application.
- Modified Electron context to apply macOS-specific styles and effects based on the platform.
- Enhanced CSS for macOS vibrancy support in the application layout.
- Updated configuration files to include new build steps and dependencies for macOS.
2026-08-02 02:44:24 +01:00

49 lines
1.2 KiB
JavaScript

import { existsSync, mkdirSync, statSync, writeFileSync } from "node:fs";
import path from "node:path";
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const srcFile = path.join(rootDir, "native/macos/window-effects.mm");
const outFile = path.join(rootDir, "src/bun/libMacWindowEffects.dylib");
function createPlaceholder() {
mkdirSync(path.dirname(outFile), { recursive: true });
writeFileSync(outFile, "");
console.log(`build-macos-effects: created placeholder dylib at ${outFile}`);
}
if (process.platform !== "darwin") {
createPlaceholder();
process.exit(0);
}
if (!existsSync(srcFile)) {
console.error(`build-macos-effects: missing source file ${srcFile}`);
process.exit(1);
}
mkdirSync(path.dirname(outFile), { recursive: true });
const result = spawnSync(
"xcrun",
[
"clang++",
"-dynamiclib",
"-fobjc-arc",
"-framework",
"Cocoa",
srcFile,
"-o",
outFile,
],
{ cwd: rootDir, stdio: "inherit" },
);
if (result.status !== 0) {
process.exit(result.status ?? 1);
}
const { size } = statSync(outFile);
console.log(`build-macos-effects: built ${outFile} (${size} bytes)`);