hermes-agent/apps/desktop/electron/hud-modifier-native.test.ts
Konrad Czarski-Bonanaty c940027ade fix(desktop): native helpers link against the SDK paired with the active toolchain
`xcrun --sdk macosx` resolves to the highest-versioned SDK installed, not the
one the active toolchain ships with. On a host whose SDKs outrank its Command
Line Tools (e.g. MacOSX27.0.sdk alongside CLT 26.6), the .tbd stubs declare
architectures the linker cannot parse, so every native helper fails to link
and the desktop build dies at the `desktop` stage.

The comment added for #113708 assumed `--sdk macosx` names the toolchain's own
default SDK; it does not. Resolve the MacOSX.sdk symlink under the active
developer dir instead, which is the SDK that toolchain actually pairs with, and
honour SDKROOT so CI and packagers can pin their own.

The two native tests that compile fixtures inline hit the same wall, so they
take the shared helper too.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-23 20:48:32 -05:00

37 lines
1.4 KiB
TypeScript

import assert from 'node:assert/strict'
import { execFileSync } from 'node:child_process'
import { mkdtempSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { resolve } from 'node:path'
import { test } from 'vitest'
import { macosSysroot, xcrunClangArgv } from '../scripts/macos-sysroot.mjs'
// hud-modifier-gesture.h is the clean-tap state machine the macOS (.m) and
// Linux XI2 (-x11.c) helpers both include. Compile its C contract and run it
// wherever a C toolchain ships with the runner: Linux (the JS CI lane) and
// macOS. Windows uses the separate C# port.
test.skipIf(process.platform === 'win32')(
'native modifier gesture state machine only summons on a clean, bounded two-modifier tap',
() => {
const dir = mkdtempSync(resolve(tmpdir(), 'hermes-hud-gesture-'))
try {
const binary = resolve(dir, 'gesture')
const source = resolve(import.meta.dirname, 'native', 'hud-modifier-gesture.test.c')
const flags = ['-std=c11', '-Wall', '-Wextra', '-Werror', source, '-o', binary]
if (process.platform === 'darwin') {
execFileSync('xcrun', [...xcrunClangArgv(macosSysroot()), ...flags])
} else {
execFileSync('cc', flags)
}
assert.match(execFileSync(binary, [], { encoding: 'utf8', timeout: 5_000 }), /assertions passed/)
} finally {
rmSync(dir, { force: true, recursive: true })
}
},
30_000
)