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 | 1x 1x 1x 1x 1x 1x 1x 1x | import fs from "fs-extra";
import copy from "lib/helpers/fsCopy";
import { ProjectResources } from "shared/lib/resources/types";
import { buildRunner } from "./buildRunner";
import { EngineSchema } from "lib/project/loadEngineSchema";
import { exportWebBuild } from "./webBuild";
type BuildOptions = {
buildType: "rom" | "web" | "pocket";
projectRoot: string;
tmpPath: string;
engineSchema: EngineSchema;
romFilename: string;
outputRoot: string;
make?: boolean;
debugEnabled?: boolean;
useCustomWebTemplate?: boolean;
progress: (msg: string) => void;
warnings: (msg: string) => void;
};
let cancelling = false;
let cancelFunction: (() => void) | undefined;
const buildProject = async (
project: ProjectResources,
{
buildType = "rom",
projectRoot = "/tmp",
tmpPath = "/tmp",
engineSchema,
outputRoot = "/tmp/testing",
romFilename,
debugEnabled = false,
useCustomWebTemplate = true,
make = true,
progress = (_msg: string) => {},
warnings = (_msg: string) => {},
}: BuildOptions,
) => {
cancelling = false;
const { result, kill } = buildRunner({
project,
buildType,
projectRoot,
engineSchema,
tmpPath,
outputRoot,
romFilename,
debugEnabled,
make,
progress,
warnings,
});
cancelFunction = kill;
const compiledData = await result;
Iif (cancelling) {
throw new Error("BUILD_CANCELLED");
}
if (buildType === "web") {
await exportWebBuild({
project,
projectRoot,
destination: `${outputRoot}/build/web`,
romFilename,
romPath: `${outputRoot}/build/rom/${romFilename}`,
webTemplate: useCustomWebTemplate ? project.settings.webTemplate : "",
warnings,
});
} else Iif (buildType === "pocket") {
await fs.mkdir(`${outputRoot}/build/pocket`);
await copy(
`${outputRoot}/build/rom/${romFilename}`,
`${outputRoot}/build/pocket/${romFilename}`,
);
}
return compiledData;
};
export const cancelCompileStepsInProgress = () => {
cancelling = true;
Iif (cancelFunction) {
cancelFunction();
}
};
export default buildProject;
|