From 98ceebbfc4ac91a58fd231373507945d74a2c636 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Mon, 22 Nov 2021 18:28:00 +0100 Subject: [PATCH] add installer debug settings + improve installer --- README.md | 6 ++++++ src/extension.ts | 4 +++- src/installer.ts | 54 ++++++++++++++++++++++++------------------------ 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index f7b2db3..182174e 100644 --- a/README.md +++ b/README.md @@ -73,3 +73,9 @@ for their great package manager and library "dub" ## Issues Please submit issues to [github](https://github.com/Pure-D/code-d) + +## Special developer config + +use `"d.forceUpdateServeD": true` to force an outdated prompt on startup. + +use `"d.forceCompileServeD": true` to force compilation of serve-d instead of downloading pre-compiled releases. diff --git a/src/extension.ts b/src/extension.ts index b9aa3fb..c5b3446 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -629,8 +629,10 @@ async function preStartup(context: vscode.ExtensionContext) { outdated = true; } - function isServedOutdated(current: Release | undefined): (log: string) => (boolean | [boolean, string]) { + function isServedOutdated(current: Release | undefined): (log: string) => (false | [boolean, string]) { return (log: string) => { + if (config(null).get("forceUpdateServeD", false)) + return [true, "(forced by d.forceUpdateServeD)"]; if (!current || !current.asset) return false; // network failure or frozen release channel, let's not bother the user else if (current.name == "nightly") { diff --git a/src/installer.ts b/src/installer.ts index e55af18..e4d3856 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -138,7 +138,7 @@ export function findLatestServeD(force: boolean = false, channel?: string): Then if (channel == "frozen" && force) channel = "stable"; - if (channel == "frozen") + if (channel == "frozen" || config(null).get("forceCompileServeD", false)) return Promise.resolve(undefined); if (servedVersionCache.channel == channel) @@ -340,7 +340,7 @@ export function updateAndInstallServeD(env: any): Thenable vscode.commands.executeCommand("workbench.action.openGlobalSettings"); return Promise.resolve(undefined); }); - } else if (!version.asset) { + } else if (!version.asset || config(null).get("forceCompileServeD", false)) { return compileServeD("master")(env); } else { return installServeD([{ url: version.asset.browser_download_url, title: "Serve-D" }], version.name)(env); @@ -482,33 +482,33 @@ export function extractServedBuiltDate(log: string): Date | false { } export function compileServeD(ref?: string): (env: NodeJS.ProcessEnv) => Promise { - return (env: any) => new Promise((resolve) => { + return (env: any) => new Promise(async() => { var outputFolder = determineOutputFolder(); mkdirp.sync(outputFolder); - fs.exists(outputFolder, async function (exists) { - const dubPath = config(null).get("dubPath", "dub"); - const dmdPath = config(null).get("dmdPath", undefined); - if (!exists) - fs.mkdirSync(outputFolder); - env["DFLAGS"] = "-O -release"; - let buildArgs = ["build"]; - if (process.platform == "win32") { - env["DFLAGS"] = "-release"; - buildArgs.push("--arch=x86_mscoff"); - } - if (dubPath != "dub" && dmdPath) { - // explicit dub path specified, it won't automatically find dmd if it's not in the same folder so we just pass the path if we have it - buildArgs.push("--compiler=" + dmdPath); - } - await compileDependency(outputFolder, "serve-d", "https://github.com/Pure-D/serve-d.git", [ - [dubPath, ["upgrade"]], - [dubPath, buildArgs] - ], env, ref); - var finalDestination = path.join(outputFolder, "serve-d", "serve-d" + (process.platform == "win32" ? ".exe" : "")); - - await config(null).update("servedPath", finalDestination, true); - resolve(true); - }); + const dubPath = config(null).get("dubPath", "dub"); + const dmdPath = config(null).get("dmdPath", undefined); + const dubCompiler = config(null).get("dubCompiler", undefined); + env["DFLAGS"] = "-O -release"; + let buildArgs = ["build"]; + if (process.platform == "win32") { + env["DFLAGS"] = "-release"; + buildArgs.push("--arch=x86_mscoff"); + } + if (dubCompiler) { + buildArgs.push("--compiler=" + dubCompiler); + } + else if (dubPath != "dub" && dmdPath) { + // explicit dub path specified, it won't automatically find dmd if it's not in the same folder so we just pass the path if we have it + buildArgs.push("--compiler=" + dmdPath); + } + await compileDependency(outputFolder, "serve-d", "https://github.com/Pure-D/serve-d.git", [ + [dubPath, ["upgrade"]], + [dubPath, buildArgs] + ], env, ref); + var finalDestination = path.join(outputFolder, "serve-d", "serve-d" + (process.platform == "win32" ? ".exe" : "")); + + await config(null).update("servedPath", finalDestination, true); + return true; }); }