MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / compileFromTree

Method compileFromTree

static/panes/executor.ts:367–433  ·  view source on GitHub ↗
(options: CompilationRequestOptions, bypassCache?: BypassCache)

Source from the content-addressed store, hash-verified

365 }
366
367 compileFromTree(options: CompilationRequestOptions, bypassCache?: BypassCache): void {
368 const tree = this.hub.getTreeById(this.sourceTreeId ?? -1);
369 if (!tree) {
370 this.sourceTreeId = null;
371 this.compileFromEditorSource(options, bypassCache);
372 return;
373 }
374
375 const request: CompilationRequest = {
376 source: tree.multifileService.getMainSource(),
377 compiler: this.compiler ? this.compiler.id : '',
378 options: options,
379 lang: this.currentLangId,
380 files: tree.multifileService.getFiles(),
381 };
382
383 const fetches: Promise<void>[] = [];
384 fetches.push(
385 this.hub.compilerService.expandToFiles(request.source).then((sourceAndFiles: SourceAndFiles) => {
386 request.source = sourceAndFiles.source;
387 request.files.push(...sourceAndFiles.files);
388 }),
389 );
390
391 const moreFiles: FiledataPair[] = [];
392 for (let i = 0; i < request.files.length; i++) {
393 const file = request.files[i];
394 fetches.push(
395 this.hub.compilerService.expandToFiles(file.contents).then((sourceAndFiles: SourceAndFiles) => {
396 file.contents = sourceAndFiles.source;
397 moreFiles.push(...sourceAndFiles.files);
398 }),
399 );
400 }
401
402 Promise.all(fetches)
403 .then(() => {
404 const treeState = tree.currentState();
405 const cmakeProject = tree.multifileService.isACMakeProject();
406 request.files.push(...moreFiles);
407
408 if (bypassCache) request.bypassCache = bypassCache;
409 if (!this.compiler) {
410 this.onCompileResponse(request, this.errorResult('<Please select a compiler>'), false);
411 } else if (cmakeProject && request.source === '') {
412 this.onCompileResponse(request, this.errorResult('<Please supply a CMakeLists.txt>'), false);
413 } else {
414 if (cmakeProject) {
415 request.options.compilerOptions.cmakeArgs = treeState.cmakeArgs;
416 request.options.compilerOptions.customOutputFilename = treeState.customOutputFilename;
417 this.sendCMakeCompile(request);
418 } else {
419 this.sendCompile(request);
420 }
421 }
422 })
423 .catch(error => {
424 this.onCompileResponse(

Callers 1

compileMethod · 0.95

Calls 12

onCompileResponseMethod · 0.95
errorResultMethod · 0.95
sendCMakeCompileMethod · 0.95
sendCompileMethod · 0.95
getTreeByIdMethod · 0.80
getMainSourceMethod · 0.80
getFilesMethod · 0.80
pushMethod · 0.80
isACMakeProjectMethod · 0.80
expandToFilesMethod · 0.45
currentStateMethod · 0.45

Tested by

no test coverage detected