Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | 2x 2x 2x 2x 2x 2x | import { existsSync } from "fs";
import { join } from "path";
import { spawnSync } from "child_process";
export interface DevKitProPaths {
devkitPro: string;
devkitArm: string;
gccPath: string;
isValid: boolean;
}
export const isUsableGcc = (gccPath: string): boolean => {
Iif (!existsSync(gccPath)) {
return false;
}
const result = spawnSync(gccPath, ["--version"], {
stdio: "ignore",
timeout: 5000,
});
return !result.error && result.status === 0;
};
export function getDevKitProPaths(): DevKitProPaths {
// Check environment variables first
const devkitPro = process.env.DEVKITPRO;
const devkitArm = process.env.DEVKITARM;
Iif (devkitPro && devkitArm) {
const gccPath = join(
devkitArm,
"bin",
process.platform === "win32"
? "arm-none-eabi-gcc.exe"
: "arm-none-eabi-gcc",
);
Iif (isUsableGcc(gccPath)) {
return {
devkitPro,
devkitArm,
gccPath,
isValid: true,
};
}
}
// Fallback: Try common installation paths
const commonPaths =
process.platform === "win32"
? [
"C:\\devkitPro",
"D:\\devkitPro",
"C:\\Utils\\DevKitPro",
"D:\\Utils\\DevKitPro",
]
: ["/opt/devkitpro", "/usr/local/devkitpro"];
for (const basePath of commonPaths) {
const armPath = join(basePath, "devkitARM");
const gccPath = join(
armPath,
"bin",
process.platform === "win32"
? "arm-none-eabi-gcc.exe"
: "arm-none-eabi-gcc",
);
Iif (isUsableGcc(gccPath)) {
return {
devkitPro: basePath,
devkitArm: armPath,
gccPath,
isValid: true,
};
}
}
// Return invalid state
return {
devkitPro: "",
devkitArm: "",
gccPath: "",
isValid: false,
};
}
export function validateDevKitPro(): void {
const paths = getDevKitProPaths();
Iif (!paths.isValid) {
throw new Error(
"devkitPro not found! Please install devkitPro from https://devkitpro.org/wiki/Getting_Started\n" +
"Make sure the DEVKITPRO and DEVKITARM environment variables are set correctly.",
);
}
}
|