Skip to content

Commit 98ceebb

Browse files
committed
add installer debug settings + improve installer
1 parent b749210 commit 98ceebb

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,9 @@ for their great package manager and library "dub"
7373
## Issues
7474
7575
Please submit issues to [github](https://github.com/Pure-D/code-d)
76+
77+
## Special developer config
78+
79+
use `"d.forceUpdateServeD": true` to force an outdated prompt on startup.
80+
81+
use `"d.forceCompileServeD": true` to force compilation of serve-d instead of downloading pre-compiled releases.

src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,10 @@ async function preStartup(context: vscode.ExtensionContext) {
629629
outdated = true;
630630
}
631631

632-
function isServedOutdated(current: Release | undefined): (log: string) => (boolean | [boolean, string]) {
632+
function isServedOutdated(current: Release | undefined): (log: string) => (false | [boolean, string]) {
633633
return (log: string) => {
634+
if (config(null).get("forceUpdateServeD", false))
635+
return [true, "(forced by d.forceUpdateServeD)"];
634636
if (!current || !current.asset)
635637
return false; // network failure or frozen release channel, let's not bother the user
636638
else if (current.name == "nightly") {

src/installer.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export function findLatestServeD(force: boolean = false, channel?: string): Then
138138
if (channel == "frozen" && force)
139139
channel = "stable";
140140

141-
if (channel == "frozen")
141+
if (channel == "frozen" || config(null).get("forceCompileServeD", false))
142142
return Promise.resolve(undefined);
143143

144144
if (servedVersionCache.channel == channel)
@@ -340,7 +340,7 @@ export function updateAndInstallServeD(env: any): Thenable<boolean | undefined>
340340
vscode.commands.executeCommand("workbench.action.openGlobalSettings");
341341
return Promise.resolve(undefined);
342342
});
343-
} else if (!version.asset) {
343+
} else if (!version.asset || config(null).get("forceCompileServeD", false)) {
344344
return compileServeD("master")(env);
345345
} else {
346346
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 {
482482
}
483483

484484
export function compileServeD(ref?: string): (env: NodeJS.ProcessEnv) => Promise<boolean | undefined> {
485-
return (env: any) => new Promise<boolean | undefined>((resolve) => {
485+
return (env: any) => new Promise<boolean | undefined>(async() => {
486486
var outputFolder = determineOutputFolder();
487487
mkdirp.sync(outputFolder);
488-
fs.exists(outputFolder, async function (exists) {
489-
const dubPath = config(null).get("dubPath", "dub");
490-
const dmdPath = config(null).get("dmdPath", undefined);
491-
if (!exists)
492-
fs.mkdirSync(outputFolder);
493-
env["DFLAGS"] = "-O -release";
494-
let buildArgs = ["build"];
495-
if (process.platform == "win32") {
496-
env["DFLAGS"] = "-release";
497-
buildArgs.push("--arch=x86_mscoff");
498-
}
499-
if (dubPath != "dub" && dmdPath) {
500-
// 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
501-
buildArgs.push("--compiler=" + dmdPath);
502-
}
503-
await compileDependency(outputFolder, "serve-d", "https://github.com/Pure-D/serve-d.git", [
504-
[dubPath, ["upgrade"]],
505-
[dubPath, buildArgs]
506-
], env, ref);
507-
var finalDestination = path.join(outputFolder, "serve-d", "serve-d" + (process.platform == "win32" ? ".exe" : ""));
508-
509-
await config(null).update("servedPath", finalDestination, true);
510-
resolve(true);
511-
});
488+
const dubPath = config(null).get("dubPath", "dub");
489+
const dmdPath = config(null).get("dmdPath", undefined);
490+
const dubCompiler = config(null).get("dubCompiler", undefined);
491+
env["DFLAGS"] = "-O -release";
492+
let buildArgs = ["build"];
493+
if (process.platform == "win32") {
494+
env["DFLAGS"] = "-release";
495+
buildArgs.push("--arch=x86_mscoff");
496+
}
497+
if (dubCompiler) {
498+
buildArgs.push("--compiler=" + dubCompiler);
499+
}
500+
else if (dubPath != "dub" && dmdPath) {
501+
// 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
502+
buildArgs.push("--compiler=" + dmdPath);
503+
}
504+
await compileDependency(outputFolder, "serve-d", "https://github.com/Pure-D/serve-d.git", [
505+
[dubPath, ["upgrade"]],
506+
[dubPath, buildArgs]
507+
], env, ref);
508+
var finalDestination = path.join(outputFolder, "serve-d", "serve-d" + (process.platform == "win32" ? ".exe" : ""));
509+
510+
await config(null).update("servedPath", finalDestination, true);
511+
return true;
512512
});
513513
}
514514

0 commit comments

Comments
 (0)