(target)
| 299 | * @returns the GN args for the `target`. |
| 300 | */ |
| 301 | export async function prepareBuild(target) { |
| 302 | const outDir = path.join(rootPath(), 'out', target); |
| 303 | |
| 304 | // Prepare the build directory first. |
| 305 | const outDirStat = await fs.stat(outDir).catch(() => null); |
| 306 | if (!outDirStat?.isDirectory()) { |
| 307 | // Use GN to (optionally create and) initialize the |outDir|. |
| 308 | try { |
| 309 | const gnExe = vpython3ExecutablePath(); |
| 310 | const gnArgs = [gnPyPath(), '-q', 'gen', outDir]; |
| 311 | await spawn(gnExe, gnArgs); |
| 312 | } catch (cause) { |
| 313 | throw new BuildError(BuildStep.GN, { cause, outDir, target }); |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | return await gnArgsForTarget(target); |
| 318 | } |
| 319 | |
| 320 | /** @type Map<string, Promise<Map<string, string>>> */ |
| 321 | const gnArgsCache = new Map(); |
no test coverage detected