(
compiler: string,
options: string[],
inputFilename: string,
execOptions: ExecutionOptions & {env: Record<string, string>},
)
| 77 | } |
| 78 | |
| 79 | override async runCompiler( |
| 80 | compiler: string, |
| 81 | options: string[], |
| 82 | inputFilename: string, |
| 83 | execOptions: ExecutionOptions & {env: Record<string, string>}, |
| 84 | ) { |
| 85 | const sourceDir = path.dirname(inputFilename); |
| 86 | const target = this.getTarget(options); |
| 87 | const slangOutputFilename = this.getPrimaryOutputFilename(sourceDir, this.outputFilebase, target); |
| 88 | |
| 89 | if (!execOptions) { |
| 90 | execOptions = this.getDefaultExecOptions(); |
| 91 | } |
| 92 | execOptions.customCwd = path.dirname(inputFilename); |
| 93 | |
| 94 | const slangOutput = await this.exec(compiler, options, execOptions); |
| 95 | const result = this.transformToCompilationResult(slangOutput, inputFilename); |
| 96 | |
| 97 | if (slangOutput.code !== 0 || !(await utils.fileExists(slangOutputFilename))) { |
| 98 | return result; |
| 99 | } |
| 100 | |
| 101 | // While slang does have a way to dump spirv assembly, using spirv-dis will make the SPIR-V we |
| 102 | // display unified with other things that produce SPIR-V |
| 103 | if (target === 'spirv') { |
| 104 | const spvasmFilename = this.getOutputFilename(sourceDir, this.outputFilebase); |
| 105 | const disassemblerFlags = [slangOutputFilename, '-o', spvasmFilename, '--comment']; |
| 106 | |
| 107 | const spvasmOutput = await this.exec(this.disassemblerPath, disassemblerFlags, execOptions); |
| 108 | if (spvasmOutput.code !== 0) { |
| 109 | logger.error('SPIR-V binary to text failed', spvasmOutput); |
| 110 | } |
| 111 | |
| 112 | result.stdout = result.stdout.concat(utils.parseOutput(spvasmOutput.stdout)); |
| 113 | result.stderr = result.stderr.concat(utils.parseOutput(spvasmOutput.stderr)); |
| 114 | result.languageId = 'spirv'; |
| 115 | } |
| 116 | |
| 117 | return result; |
| 118 | } |
| 119 | |
| 120 | // slangc defaults to SPIR-V as a target, but has many target it can output |
| 121 | override async processAsm(result, filters: ParseFiltersAndOutputOptions, options: string[]) { |
nothing calls this directly
no test coverage detected