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

Method runCompiler

lib/compilers/r8.ts:54–164  ·  view source on GitHub ↗
(
        compiler: string,
        options: string[],
        inputFilename: string,
        execOptions: ExecutionOptionsWithEnv,
        filters?: ParseFiltersAndOutputOptions,
    )

Source from the content-addressed store, hash-verified

52 }
53
54 override async runCompiler(
55 compiler: string,
56 options: string[],
57 inputFilename: string,
58 execOptions: ExecutionOptionsWithEnv,
59 filters?: ParseFiltersAndOutputOptions,
60 ): Promise<CompilationResult> {
61 const preliminaryCompilePath = path.dirname(inputFilename);
62 let outputFilename = '';
63 let initialResult: CompilationResult | null = null;
64
65 const javaCompiler = unwrap(this.env.findCompiler('java', this.javaId)) as JavaCompiler;
66
67 // Instantiate Java or Kotlin compiler based on the current language.
68 if (this.lang.id === 'android-java') {
69 outputFilename = javaCompiler.getOutputFilename(preliminaryCompilePath);
70 const javaOptions = _.compact(
71 javaCompiler.prepareArguments(
72 this.getClasspathArgument(),
73 javaCompiler.getDefaultFilters(),
74 {}, // backendOptions
75 inputFilename,
76 outputFilename,
77 [], // libraries
78 [], // overrides
79 ),
80 );
81 initialResult = await javaCompiler.runCompiler(
82 javaCompiler.getInfo().exe,
83 javaOptions,
84 this.filename(inputFilename),
85 javaCompiler.getDefaultExecOptions(),
86 );
87 } else if (this.lang.id === 'android-kotlin') {
88 const kotlinCompiler = unwrap(this.env.findCompiler('kotlin', this.kotlinId)) as KotlinCompiler;
89 outputFilename = kotlinCompiler.getOutputFilename(preliminaryCompilePath);
90 const kotlinOptions = _.compact(
91 kotlinCompiler.prepareArguments(
92 this.getClasspathArgument(),
93 kotlinCompiler.getDefaultFilters(),
94 {}, // backendOptions
95 inputFilename,
96 outputFilename,
97 [], // libraries
98 [], // overrides
99 ),
100 );
101 initialResult = await kotlinCompiler.runCompiler(
102 kotlinCompiler.getInfo().exe,
103 kotlinOptions,
104 this.filename(inputFilename),
105 kotlinCompiler.getDefaultExecOptions(),
106 );
107 } else {
108 logger.error('Language is neither android-java nor android-kotlin.');
109 }
110
111 // R8 should not run if initial compile stage failed, the JavaCompiler

Callers

nothing calls this directly

Calls 15

getR8LibArgumentsMethod · 0.95
errorMethod · 0.80
testMethod · 0.80
pushMethod · 0.80
getMinApiArgumentMethod · 0.80
getOutputFilenameMethod · 0.65
unwrapFunction · 0.50
findCompilerMethod · 0.45
prepareArgumentsMethod · 0.45
getClasspathArgumentMethod · 0.45

Tested by

no test coverage detected