| 40 | import {KotlinCompiler} from './kotlin.js'; |
| 41 | |
| 42 | export class R8Compiler extends D8Compiler implements SimpleOutputFilenameCompiler { |
| 43 | static override get key() { |
| 44 | return 'android-r8'; |
| 45 | } |
| 46 | |
| 47 | kotlinLibPath: string; |
| 48 | |
| 49 | constructor(compilerInfo: PreliminaryCompilerInfo, env: CompilationEnvironment) { |
| 50 | super({...compilerInfo}, env); |
| 51 | this.kotlinLibPath = this.compilerProps<string>(`group.${this.compiler.group}.kotlinLibPath`); |
| 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 | ), |
nothing calls this directly
no outgoing calls
no test coverage detected