(
source: string,
options: string[],
backendOptions: Record<string, any>,
filters: ParseFiltersAndOutputOptions,
bypassCache: BypassCache,
tools: ActiveTool[],
executeParameters: ExecutionParams,
libraries: SelectedLibraryVersion[],
files: FiledataPair[],
)
| 3209 | } |
| 3210 | |
| 3211 | async compile( |
| 3212 | source: string, |
| 3213 | options: string[], |
| 3214 | backendOptions: Record<string, any>, |
| 3215 | filters: ParseFiltersAndOutputOptions, |
| 3216 | bypassCache: BypassCache, |
| 3217 | tools: ActiveTool[], |
| 3218 | executeParameters: ExecutionParams, |
| 3219 | libraries: SelectedLibraryVersion[], |
| 3220 | files: FiledataPair[], |
| 3221 | ) { |
| 3222 | const optionsError = this.checkOptions(options); |
| 3223 | if (optionsError) throw optionsError; |
| 3224 | |
| 3225 | const libsAndOptions = {libraries, options}; |
| 3226 | if (this.tryAutodetectLibraries(libsAndOptions)) { |
| 3227 | libraries = libsAndOptions.libraries; |
| 3228 | options = libsAndOptions.options; |
| 3229 | } |
| 3230 | |
| 3231 | this.fixFiltersBeforeCacheKey(filters, options, files); |
| 3232 | |
| 3233 | const executeOptions: ExecutableExecutionOptions = { |
| 3234 | args: executeParameters.args || [], |
| 3235 | stdin: executeParameters.stdin || '', |
| 3236 | ldPath: [], |
| 3237 | env: {}, |
| 3238 | runtimeTools: executeParameters.runtimeTools || [], |
| 3239 | }; |
| 3240 | |
| 3241 | const key = this.getCacheKey(source, options, backendOptions, filters, tools, libraries, files); |
| 3242 | |
| 3243 | const doExecute = filters.execute; |
| 3244 | filters = Object.assign({}, filters); |
| 3245 | filters.execute = false; |
| 3246 | |
| 3247 | if (!bypassCompilationCache(bypassCache)) { |
| 3248 | const cacheRetrieveTimeStart = process.hrtime.bigint(); |
| 3249 | // TODO: We should be able to eliminate this any cast. `key` should be cacheable (if it's not that's a big |
| 3250 | // problem) Because key contains a CompilerInfo which contains a function member it can't be assigned to a |
| 3251 | // CacheableValue. |
| 3252 | const result = await this.env.cacheGet(key as any); |
| 3253 | if (result) { |
| 3254 | const cacheRetrieveTimeEnd = process.hrtime.bigint(); |
| 3255 | result.retreivedFromCacheTime = utils.deltaTimeNanoToMili(cacheRetrieveTimeStart, cacheRetrieveTimeEnd); |
| 3256 | result.retreivedFromCache = true; |
| 3257 | result.s3Key = BaseCache.hash(key); |
| 3258 | if (doExecute) { |
| 3259 | const queueTime = performance.now(); |
| 3260 | result.execResult = await this.env.enqueue( |
| 3261 | async () => { |
| 3262 | const start = performance.now(); |
| 3263 | executionQueueTimeHistogram.observe((start - queueTime) / 1000); |
| 3264 | const res = await this.handleExecution(key, executeOptions, bypassCache); |
| 3265 | executionTimeHistogram.observe((performance.now() - start) / 1000); |
| 3266 | return res; |
| 3267 | }, |
| 3268 | {abandonIfStale: true}, |
nothing calls this directly
no test coverage detected