/** * Resolves a space-free Cargo target directory. * * Why this exists: on Windows with the `x86_64-pc-windows-gnu` toolchain, * `tauri-winres` → `embed-resource` → GNU `windres` passes the output/include * directory to `cc1` without quoting. A project path containing a space * (e.g. "...\LD FDPI\...") therefore aborts the build with: * cc1.exe: fatal error: FDPI\src-tauri\target\...: No such file or directory * * We keep the target directory as a sibling of the project when that path is * space-free, and fall back to %LOCALAPPDATA% otherwise. Fully relative and * machine-independent. */ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { fileURLToPath } from "node:url"; export const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); export function resolveTargetDir() { let dir = path.resolve(ROOT, "..", ".ld-fdpi-target"); if (dir.includes(" ")) { dir = path.join(process.env.LOCALAPPDATA || os.tmpdir(), "ld-fdpi-build", "target"); } fs.mkdirSync(dir, { recursive: true }); return dir; }