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 | 1x 1x 1x 1x 1x 1x 1x 1x | import fs from "fs-extra";
import Path from "path";
import ensureBuildTools from "lib/compiler/ensureBuildTools";
import spawn from "lib/helpers/cli/spawn";
import l10n from "shared/lib/lang/l10n";
import { envWith } from "lib/helpers/cli/env";
type RomUsageOptions = {
buildRoot: string;
romStem: string;
tmpPath: string;
progress: (msg: string) => void;
warnings: (msg: string) => void;
};
export type UsageData = {
banks: Array<{
name: string;
type: string;
baseBankNum: string;
isBanked: string;
isMergedBank: string;
rangeStart: string;
rangeEnd: string;
size: string;
used: string;
free: string;
usedPercent: string;
freePercent: string;
miniGraph: string;
}>;
};
const romUsage = async ({
buildRoot = "/tmp",
tmpPath = "/tmp",
romStem = "game",
warnings = (_msg) => {},
progress = (_msg) => {},
}: RomUsageOptions) => {
const env = { ...process.env };
const buildToolsPath = await ensureBuildTools(tmpPath);
const buildToolsVersion = await fs.readFile(
`${buildToolsPath}/tools_version`,
"utf8",
);
env.PATH = envWith([Path.join(buildToolsPath, "gbdk", "bin")]);
env.GBDKDIR = `${buildToolsPath}/gbdk/`;
env.GBS_TOOLS_VERSION = buildToolsVersion;
const options = {
cwd: buildRoot,
env,
shell: true,
};
const romusageCommand =
process.platform === "win32"
? `"${buildToolsPath}\\gbdk\\bin\\romusage.exe"`
: "romusage";
const romusageArgs = [
`"${buildRoot}/build/rom/${romStem}.map"`,
`-g`,
`-sH`,
`-sJ`,
];
let output = "";
progress(`${l10n("COMPILER_ROMUSAGE")}...`);
const { completed: romusageCompleted } = spawn(
romusageCommand,
romusageArgs,
options,
{
onLog: (msg) => {
output += msg;
},
onError: (msg) => {
Iif (msg.indexOf("Romusage") > -1) {
return;
}
warnings(msg);
},
},
);
await romusageCompleted;
return JSON.parse(output) as UsageData;
};
export default romUsage;
|