MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / runCompiler

Method runCompiler

lib/compilers/beebasm.ts:56–110  ·  view source on GitHub ↗
(
        compiler: string,
        options: string[],
        inputFilename: string,
        execOptions: ExecutionOptionsWithEnv,
    )

Source from the content-addressed store, hash-verified

54 }
55
56 override async runCompiler(
57 compiler: string,
58 options: string[],
59 inputFilename: string,
60 execOptions: ExecutionOptionsWithEnv,
61 ) {
62 if (!execOptions) {
63 execOptions = this.getDefaultExecOptions();
64 }
65
66 const dirPath = path.dirname(inputFilename);
67 if (!execOptions.customCwd) {
68 execOptions.customCwd = dirPath;
69 }
70
71 options.splice(-1, 0, '-i');
72
73 const hasBootOption = options.some(opt => opt.includes('-boot'));
74
75 const compilerExecResult = await this.exec(compiler, options, execOptions);
76
77 if (compilerExecResult.stdout.length > 0) {
78 const outputFilename = this.getOutputFilename(dirPath, this.outputFilebase);
79 await fs.writeFile(outputFilename, compilerExecResult.stdout);
80 compilerExecResult.stdout = '';
81 }
82
83 const result = this.transformToCompilationResult(compilerExecResult, inputFilename);
84
85 if (result.code === 0 && options.includes('-v')) {
86 const diskfile = path.join(dirPath, 'disk.ssd');
87 if (await utils.fileExists(diskfile)) {
88 await addArtifactToResult(result, diskfile, ArtifactType.bbcdiskimage);
89
90 if (!hasBootOption) {
91 if (!result.hints) result.hints = [];
92 result.hints.push(
93 'Try using the "-boot <filename>" option so you don\'t have to manually run your file',
94 );
95 }
96 }
97 }
98
99 const hasNoSaveError = result.stderr.some(opt => opt.text.includes('warning: no SAVE command in source file'));
100 if (hasNoSaveError) {
101 if (!result.hints) result.hints = [];
102 result.hints.push(
103 'You should SAVE your code to a file using\nSAVE "filename", start, end [, exec [, reload] ]',
104 );
105 }
106
107 result.forceBinaryView = true;
108
109 return result;
110 }
111
112 override async afterCmakeCompilation(
113 ...args: Parameters<BaseCompiler['afterCmakeCompilation']>

Callers

nothing calls this directly

Calls 7

addArtifactToResultFunction · 0.85
fileExistsMethod · 0.80
pushMethod · 0.80
getOutputFilenameMethod · 0.65
getDefaultExecOptionsMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected