(
key: CacheKey,
bypassCache: BypassCache,
executablePackageHash: string,
)
| 2172 | } |
| 2173 | |
| 2174 | async getOrBuildExecutable( |
| 2175 | key: CacheKey, |
| 2176 | bypassCache: BypassCache, |
| 2177 | executablePackageHash: string, |
| 2178 | ): Promise<BuildResult> { |
| 2179 | const dirPath = await this.newTempDir(); |
| 2180 | |
| 2181 | if (!bypassCompilationCache(bypassCache)) { |
| 2182 | const buildResult = await this.loadPackageWithExecutable(key, executablePackageHash, dirPath); |
| 2183 | if (buildResult) return buildResult; |
| 2184 | } |
| 2185 | |
| 2186 | let buildResult: BuildResult; |
| 2187 | try { |
| 2188 | buildResult = await this.buildExecutableInFolder(key, dirPath); |
| 2189 | if (buildResult.code !== 0) { |
| 2190 | return buildResult; |
| 2191 | } |
| 2192 | } catch (e) { |
| 2193 | return this.handleUserBuildError(e, dirPath); |
| 2194 | } |
| 2195 | |
| 2196 | buildResult.preparedLdPaths = this.getSharedLibraryPathsAsLdLibraryPathsForExecution(key, dirPath); |
| 2197 | buildResult.defaultExecOptions = this.getDefaultExecOptions(); |
| 2198 | |
| 2199 | const packageStoreStart = process.hrtime.bigint(); |
| 2200 | await this.storePackageWithExecutable(executablePackageHash, dirPath, buildResult); |
| 2201 | const packageStoreEnd = process.hrtime.bigint(); |
| 2202 | buildResult.packageStoreTime = utils.deltaTimeNanoToMili(packageStoreStart, packageStoreEnd); |
| 2203 | |
| 2204 | if (!buildResult.dirPath) { |
| 2205 | buildResult.dirPath = dirPath; |
| 2206 | } |
| 2207 | |
| 2208 | return buildResult; |
| 2209 | } |
| 2210 | |
| 2211 | async loadPackageWithExecutable(key: CacheKey, executablePackageHash: string, dirPath: string) { |
| 2212 | const compilationResultFilename = 'compilation-result.json'; |
no test coverage detected