(
compiler: string,
options: string[],
inputFilename: string,
execOptions: ExecutionOptionsWithEnv,
filters?: ParseFiltersAndOutputOptions,
)
| 167 | } |
| 168 | |
| 169 | override async runCompiler( |
| 170 | compiler: string, |
| 171 | options: string[], |
| 172 | inputFilename: string, |
| 173 | execOptions: ExecutionOptionsWithEnv, |
| 174 | filters?: ParseFiltersAndOutputOptions, |
| 175 | ): Promise<CompilationResult> { |
| 176 | // Make sure --full-output from previous invocations doesn't persist. |
| 177 | this.fullOutput = false; |
| 178 | |
| 179 | // Instantiate D8 compiler, which will in turn instantiate a Java or |
| 180 | // Kotlin compiler based on the current language. |
| 181 | const d8Compiler = this.env.findCompiler(this.lang.id, this.d8Id) as D8Compiler | undefined; |
| 182 | if (!d8Compiler) { |
| 183 | return { |
| 184 | ...this.handleUserError( |
| 185 | {message: `Compiler ${this.lang.id} ${this.d8Id} not configured correctly`}, |
| 186 | '', |
| 187 | ), |
| 188 | timedOut: false, |
| 189 | }; |
| 190 | } |
| 191 | const d8DirPath = path.dirname(inputFilename); |
| 192 | const d8OutputFilename = d8Compiler.getOutputFilename(d8DirPath); |
| 193 | |
| 194 | if (!execOptions) { |
| 195 | execOptions = this.getDefaultExecOptions(); |
| 196 | } |
| 197 | |
| 198 | let useDefaultInsnSet = true; |
| 199 | let useDefaultCompilerFilter = true; |
| 200 | let d8Flags: string | undefined; |
| 201 | |
| 202 | // The items in 'options' before the source file are user inputs. |
| 203 | const sourceFileOptionIndex = options.findIndex(option => { |
| 204 | return option.endsWith('.java') || option.endsWith('.kt'); |
| 205 | }); |
| 206 | const userOptions: string[] = []; |
| 207 | for (let i = 0; i < sourceFileOptionIndex; ++i) { |
| 208 | const option = options[i]; |
| 209 | if (this.insnSetArgRegex.test(option)) { |
| 210 | useDefaultInsnSet = false; |
| 211 | userOptions.push(option); |
| 212 | } else if (this.compilerFilterArgRegex.test(option)) { |
| 213 | useDefaultCompilerFilter = false; |
| 214 | userOptions.push(option); |
| 215 | } else if (option === this.fullOutputFlag) { |
| 216 | this.fullOutput = true; |
| 217 | } else if (option === '--d8-flags') { |
| 218 | d8Flags = options[++i]; |
| 219 | } else { |
| 220 | userOptions.push(option); |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | const d8Options = _.compact( |
| 225 | d8Compiler.prepareArguments( |
| 226 | d8Flags?.split(' ') ?? [], |
no test coverage detected