From f7e92edab0f9171ee1b03649c6d92c08ceda93e2 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Fri, 12 Apr 2024 14:24:23 +0200 Subject: [PATCH] =?UTF-8?q?fix(=F0=9F=92=BB):=20use=20available=20cores=20?= =?UTF-8?q?to=20compile=20Skia=20(#2360)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/build-skia.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/build-skia.ts b/scripts/build-skia.ts index c985e0d893..c5d75905f5 100644 --- a/scripts/build-skia.ts +++ b/scripts/build-skia.ts @@ -1,8 +1,11 @@ import { executeCmd, executeCmdSync } from "./utils"; import { exit } from "process"; import { commonArgs, configurations, PlatformName } from "./skia-configuration"; -const fs = require("fs"); +import { cpus } from "os"; +import { existsSync, mkdirSync } from "fs"; + const typedKeys = (obj: T) => Object.keys(obj) as (keyof T)[]; +const cores = cpus().length; /** * This build script builds the Skia Binaries from the Skia repositories @@ -124,7 +127,7 @@ const buildPlatform = ( // We need to include the path to our custom python2 -> python3 mapping script // to make sure we can run all scripts that uses #!/usr/bin/env python as shebang // https://groups.google.com/g/skia-discuss/c/BYyB-TwA8ow - const command = `PATH=${process.cwd()}/../bin:$PATH ninja -C ${getOutDir( + const command = `PATH=${process.cwd()}/../bin:$PATH ninja -j ${cores} -C ${getOutDir( platform, targetName )}`; @@ -147,9 +150,9 @@ const processOutput = (platformName: PlatformName, targetName: string) => { targetDir = `${currentDir}/${configurations[platformName].outputRoot}/${target.output}`; } - if (!fs.existsSync(targetDir)) { + if (!existsSync(targetDir)) { console.log(`Creating directory '${targetDir}'...`); - fs.mkdirSync(targetDir + "/", { recursive: true }); + mkdirSync(targetDir + "/", { recursive: true }); } libNames.forEach((libName) => {