Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ release/**
.history/

# Native capture build artifacts
electron/native/wgc-capture/build/
electron/native/windows-capture/build/
electron/native/cursor-monitor/build/
2 changes: 2 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))

if (process.platform === 'darwin') {
app.commandLine.appendSwitch('disable-features', 'MacCatapLoopbackAudioForScreenShare')
} else if (process.platform === 'win32') {
app.commandLine.appendSwitch('disable-gpu-shader-disk-cache')
}

export const RECORDINGS_DIR = path.join(app.getPath('userData'), 'recordings')
Expand Down
2 changes: 2 additions & 0 deletions electron/native/windows-capture/src/dxgi_session.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define NOMINMAX

#include "dxgi_session.h"

#include <dwmapi.h>
Expand Down
12 changes: 8 additions & 4 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@types/uuid": "^10.0.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.21",
"baseline-browser-mapping": "^2.10.8",
"electron": "^39.2.7",
"electron-builder": "^26.7.0",
"electron-icon-builder": "^2.0.1",
Expand Down
167 changes: 89 additions & 78 deletions scripts/build-cursor-monitor.mjs
Original file line number Diff line number Diff line change
@@ -1,103 +1,114 @@
import { execSync } from "node:child_process";
import { existsSync, mkdirSync } from "node:fs";
import path from "node:path";
import { execSync } from 'node:child_process';
import { mkdirSync, existsSync } from 'node:fs';
import path from 'node:path';

const projectRoot = process.cwd();
const sourceDir = path.join(projectRoot, "electron", "native", "cursor-monitor");
const buildDir = path.join(sourceDir, "build");
const sourceDir = path.join(projectRoot, 'electron', 'native', 'cursor-monitor');
const buildDir = path.join(sourceDir, 'build');

if (process.platform !== "win32") {
console.log("[build-cursor-monitor] Skipping: host platform is not Windows.");
process.exit(0);
if (process.platform !== 'win32') {
console.log('[build-cursor-monitor] Skipping: host platform is not Windows.');
process.exit(0);
}

if (!existsSync(path.join(sourceDir, "CMakeLists.txt"))) {
console.error("[build-cursor-monitor] CMakeLists.txt not found at", sourceDir);
process.exit(1);
if (!existsSync(path.join(sourceDir, 'CMakeLists.txt'))) {
console.error('[build-cursor-monitor] CMakeLists.txt not found at', sourceDir);
process.exit(1);
}

function findCmake() {
// Check PATH first
try {
execSync("cmake --version", { stdio: "pipe" });
return "cmake";
} catch {
// not on PATH
}

// VS 2022 bundled CMake
const vsEditions = ["Community", "Professional", "Enterprise", "BuildTools"];
for (const edition of vsEditions) {
const cmakePath = path.join(
"C:",
"Program Files",
"Microsoft Visual Studio",
"2022",
edition,
"Common7",
"IDE",
"CommonExtensions",
"Microsoft",
"CMake",
"CMake",
"bin",
"cmake.exe",
);
if (existsSync(cmakePath)) {
return `"${cmakePath}"`;
}
}

return null;
// Check PATH first (your standalone CMake)
try {
execSync('cmake --version', { stdio: 'pipe' });
return 'cmake';
} catch {
// not on PATH
}

// Look for bundled CMake in Visual Studio (prefer 2026)
const vsYears = ['2026', '2022'];
const vsEditions = ['Community', 'Professional', 'Enterprise', 'BuildTools'];

for (const year of vsYears) {
for (const edition of vsEditions) {
const cmakePath = path.join(
'D:', // ← changed to D: because that's where your VS is
'Program Files',
'Microsoft Visual Studio',
year,
edition,
'Common7',
'IDE',
'CommonExtensions',
'Microsoft',
'CMake',
'CMake',
'bin',
'cmake.exe'
);
if (existsSync(cmakePath)) {
console.log(`[build-cursor-monitor] Found CMake at: ${cmakePath}`);
return `"${cmakePath}"`;
}
}
}

return null;
}

const cmake = findCmake();

if (!cmake) {
console.error(
"[build-cursor-monitor] CMake not found. Install Visual Studio with C++ CMake tools or standalone CMake.",
);
process.exit(1);
console.error(
'[build-cursor-monitor] CMake not found.\n' +
'Make sure you have:\n' +
' - Standalone CMake installed and in PATH, or\n' +
' - Visual Studio 2026 with "Desktop development with C++" workload and "C++ CMake tools for Windows" component.'
);
process.exit(1);
}

mkdirSync(buildDir, { recursive: true });

console.log("[build-cursor-monitor] Configuring CMake...");
console.log('[build-cursor-monitor] Configuring CMake with Visual Studio 18 2026...');

try {
execSync(`${cmake} .. -G "Visual Studio 17 2022" -A x64`, {
cwd: buildDir,
stdio: "inherit",
timeout: 120000,
});
} catch {
console.log("[build-cursor-monitor] VS 2022 generator not found, trying VS 2019...");
try {
execSync(`${cmake} .. -G "Visual Studio 16 2019" -A x64`, {
cwd: buildDir,
stdio: "inherit",
timeout: 120000,
});
} catch (innerError) {
console.error("[build-cursor-monitor] CMake configure failed:", innerError.message);
process.exit(1);
}
execSync(`${cmake} .. -G "Visual Studio 18 2026" -A x64`, {
cwd: buildDir,
stdio: 'inherit',
timeout: 120000,
});
} catch (error) {
console.error('[build-cursor-monitor] CMake configure failed with VS 2026:');
console.error(error.message || error);
console.log(
'\nQuick fixes:\n' +
'1. Delete the build folder: electron\\native\\cursor-monitor\\build\n' +
'2. Make sure VS 2026 has "C++ CMake tools for Windows" installed\n' +
'3. Run manually: cmake .. -G "Visual Studio 18 2026" -A x64 (from inside build folder)'
);
process.exit(1);
}

console.log("[build-cursor-monitor] Building...");
console.log('[build-cursor-monitor] Building cursor-monitor (Release)...');

try {
execSync(`${cmake} --build . --config Release`, {
cwd: buildDir,
stdio: "inherit",
timeout: 300000,
});
execSync(`${cmake} --build . --config Release`, {
cwd: buildDir,
stdio: 'inherit',
timeout: 300000,
});
} catch (error) {
console.error("[build-cursor-monitor] Build failed:", error.message);
process.exit(1);
console.error('[build-cursor-monitor] Build failed:');
console.error(error.message || error);
process.exit(1);
}

const exePath = path.join(buildDir, "Release", "cursor-monitor.exe");
const exePath = path.join(buildDir, 'Release', 'cursor-monitor.exe');

if (existsSync(exePath)) {
console.log(`[build-cursor-monitor] Built successfully: ${exePath}`);
console.log(`[build-cursor-monitor] Built successfully: ${exePath}`);
} else {
console.error("[build-cursor-monitor] Expected exe not found at", exePath);
process.exit(1);
}
console.error('[build-cursor-monitor] Expected executable not found at', exePath);
process.exit(1);
}
69 changes: 41 additions & 28 deletions scripts/build-windows-capture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,74 +17,87 @@ if (!existsSync(path.join(sourceDir, 'CMakeLists.txt'))) {
}

function findCmake() {
// Check PATH first
// Check PATH first (most common when CMake is installed standalone)
try {
execSync('cmake --version', { stdio: 'pipe' });
return 'cmake';
} catch {
// not on PATH
}

// VS 2022 bundled CMake
// Look for bundled CMake in Visual Studio installations
const vsYears = ['2026', '2022']; // Prefer 2026, fallback to 2022 if needed
const vsEditions = ['Community', 'Professional', 'Enterprise', 'BuildTools'];
for (const edition of vsEditions) {
const cmakePath = path.join(
'C:', 'Program Files', 'Microsoft Visual Studio', '2022', edition,
'Common7', 'IDE', 'CommonExtensions', 'Microsoft', 'CMake', 'CMake', 'bin', 'cmake.exe'
);
if (existsSync(cmakePath)) {
return `"${cmakePath}"`;

for (const year of vsYears) {
for (const edition of vsEditions) {
const cmakePath = path.join(
'C:', 'Program Files', 'Microsoft Visual Studio', year, edition,
'Common7', 'IDE', 'CommonExtensions', 'Microsoft', 'CMake', 'CMake', 'bin', 'cmake.exe'
);
if (existsSync(cmakePath)) {
console.log(`[build-windows-capture] Found CMake at: ${cmakePath}`);
return `"${cmakePath}"`;
}
}
}

return null;
}

const cmake = findCmake();

if (!cmake) {
console.error('[build-windows-capture] CMake not found. Install Visual Studio with C++ CMake tools or standalone CMake.');
console.error(
'[build-windows-capture] CMake not found.\n' +
'Please install Visual Studio 2026 (with "Desktop development with C++" workload and "C++ CMake tools for Windows" component)\n' +
'or install standalone CMake and add it to PATH.'
);
process.exit(1);
}

mkdirSync(buildDir, { recursive: true });

console.log('[build-windows-capture] Configuring CMake...');
console.log('[build-windows-capture] Configuring CMake with Visual Studio 18 2026...');

try {
execSync(`${cmake} .. -G "Visual Studio 17 2022" -A x64`, {
execSync(`${cmake} .. -G "Visual Studio 18 2026" -A x64`, {
cwd: buildDir,
stdio: 'inherit',
timeout: 120000,
});
} catch {
console.log('[build-windows-capture] VS 2022 generator not found, trying VS 2019...');
try {
execSync(`${cmake} .. -G "Visual Studio 16 2019" -A x64`, {
cwd: buildDir,
stdio: 'inherit',
timeout: 120000,
});
} catch (innerError) {
console.error('[build-windows-capture] CMake configure failed:', innerError.message);
process.exit(1);
}
} catch (error) {
console.error('[build-windows-capture] CMake configure failed with VS 2026:');
console.error(error.message || error);
console.log(
'\nPossible fixes:\n' +
'1. Make sure Visual Studio 2026 has "Desktop development with C++" workload installed.\n' +
'2. Check "C++ CMake tools for Windows" component is installed.\n' +
'3. Delete the build folder and retry.\n' +
'4. Run "cmake .. -G \'Visual Studio 18 2026\' -A x64" manually in the native folder to debug.'
);
process.exit(1);
}

console.log('[build-windows-capture] Building native Windows capture helper...');
console.log('[build-windows-capture] Building native Windows capture helper (Release)...');

try {
execSync(`${cmake} --build . --config Release`, {
cwd: buildDir,
stdio: 'inherit',
timeout: 300000,
});
} catch (error) {
console.error('[build-windows-capture] Build failed:', error.message);
console.error('[build-windows-capture] Build failed:');
console.error(error.message || error);
process.exit(1);
}

const exePath = path.join(buildDir, 'Release', 'windows-capture.exe');

if (existsSync(exePath)) {
console.log(`[build-windows-capture] Built successfully: ${exePath}`);
} else {
console.error('[build-windows-capture] Expected exe not found at', exePath);
console.error('[build-windows-capture] Expected executable not found at', exePath);
process.exit(1);
}
}