| 41 | import {KotlinCompiler} from './kotlin.js'; |
| 42 | |
| 43 | export class D8Compiler extends BaseCompiler implements SimpleOutputFilenameCompiler { |
| 44 | static get key() { |
| 45 | return 'android-d8'; |
| 46 | } |
| 47 | |
| 48 | lineNumberRegex: RegExp; |
| 49 | methodEndRegex: RegExp; |
| 50 | |
| 51 | minApiArgRegex: RegExp; |
| 52 | |
| 53 | jvmSyspropArgRegex: RegExp; |
| 54 | syspropArgRegex: RegExp; |
| 55 | |
| 56 | javaId: string; |
| 57 | kotlinId: string; |
| 58 | |
| 59 | versionFromPropsRegex: RegExp; |
| 60 | versionFromJarRegex: RegExp; |
| 61 | |
| 62 | libPaths: string[]; |
| 63 | |
| 64 | constructor(compilerInfo: PreliminaryCompilerInfo, env: CompilationEnvironment) { |
| 65 | super({...compilerInfo}, env); |
| 66 | |
| 67 | this.lineNumberRegex = /^\s+\.line\s+(\d+).*$/; |
| 68 | this.methodEndRegex = /^\s*\.end\smethod.*$/; |
| 69 | |
| 70 | this.minApiArgRegex = /^--min-api$/; |
| 71 | |
| 72 | this.jvmSyspropArgRegex = /^-J.*$/; |
| 73 | this.syspropArgRegex = /^-D.*$/; |
| 74 | |
| 75 | // TODO(#7150) this can be rephrased once 7150 is done... |
| 76 | this.javaId = this.compilerProps<string>(`compiler.${this.compiler.id}.javaId`); |
| 77 | if (!this.javaId) { |
| 78 | this.javaId = this.compilerProps<string>(`group.${this.compiler.group}.javaId`); |
| 79 | } |
| 80 | |
| 81 | this.versionFromPropsRegex = /^version\.version=(.*)$/; |
| 82 | this.versionFromJarRegex = /^.*r8-(.*)\.jar$/; |
| 83 | |
| 84 | this.kotlinId = this.compilerProps<string>(`group.${this.compiler.group}.kotlinId`); |
| 85 | |
| 86 | this.libPaths = []; |
| 87 | } |
| 88 | |
| 89 | override getOutputFilename(dirPath: string) { |
| 90 | return path.join(dirPath, `${path.basename(this.compileFilename, this.lang.extensions[0])}.dex`); |
| 91 | } |
| 92 | |
| 93 | override async runCompiler( |
| 94 | compiler: string, |
| 95 | options: string[], |
| 96 | inputFilename: string, |
| 97 | execOptions: ExecutionOptionsWithEnv, |
| 98 | filters?: ParseFiltersAndOutputOptions, |
| 99 | ): Promise<CompilationResult> { |
| 100 | const preliminaryCompilePath = path.dirname(inputFilename); |
nothing calls this directly
no outgoing calls
no test coverage detected