From eaa5335e4fac445a75b1eed1e64c7af9bf00bc19 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Wed, 11 Sep 2024 14:13:46 -0700 Subject: [PATCH] don't run local builds in parallel (#10169) --- cli/cli.ts | 19 ++++++++++++++++--- cli/prepYotta.ts | 4 ++-- pxtlib/package.ts | 2 ++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cli/cli.ts b/cli/cli.ts index 98fc295b056c..5ba851aea3bf 100644 --- a/cli/cli.ts +++ b/cli/cli.ts @@ -3030,6 +3030,7 @@ class SnippetHost implements pxt.Host { class Host implements pxt.Host { fileOverrides: Map = {} + queue = new pxt.Util.PromiseQueue(); resolve(module: pxt.Package, filename: string) { //pxt.debug(`resolving ${module.level}:${module.id} -- ${filename} in ${path.resolve(".")}`) @@ -3165,10 +3166,22 @@ class Host if (useCompileServiceDocker) { return build.compileWithLocalCompileService(extInfo); } + return this.queue.enqueue("getHexInfoAsync", async () => { + const prevVariant = pxt.appTargetVariant; - setBuildEngine() - return build.buildHexAsync(build.thisBuild, mainPkg, extInfo, forceBuild) - .then(() => build.thisBuild.patchHexInfo(extInfo)) + if (extInfo.appVariant && extInfo.appVariant !== prevVariant) { + pxt.setAppTargetVariant(extInfo.appVariant, { temporary: true }); + } + setBuildEngine() + await build.buildHexAsync(build.thisBuild, mainPkg, extInfo, forceBuild) + const res = build.thisBuild.patchHexInfo(extInfo); + + if (extInfo.appVariant && extInfo.appVariant !== prevVariant) { + pxt.setAppTargetVariant(prevVariant); + } + + return res; + }); } cacheStoreAsync(id: string, val: string): Promise { diff --git a/cli/prepYotta.ts b/cli/prepYotta.ts index 43775ac04155..5309d10d9b52 100644 --- a/cli/prepYotta.ts +++ b/cli/prepYotta.ts @@ -7,8 +7,8 @@ const os = require("os"); const path = require("path"); const fs = require("fs"); -const token = process.env["GH_ACCESS_TOKEN"]; -if (process.env["GH_ACCESS_TOKEN"]) { +const token = process.env["GITHUB_ACCESS_TOKEN"]; +if (process.env["GITHUB_ACCESS_TOKEN"]) { console.log("Writing .netrc and .yotta/config.json") const home = os.homedir(); diff --git a/pxtlib/package.ts b/pxtlib/package.ts index 0c2b303b48df..6a0d2d0d85e5 100644 --- a/pxtlib/package.ts +++ b/pxtlib/package.ts @@ -1187,6 +1187,8 @@ namespace pxt { } } + einfo.appVariant = variant; + const inf = target.isNative ? await this.host().getHexInfoAsync(einfo) : null einfo = U.flatClone(einfo)