Skip to content

Commit

Permalink
add installer debug settings + improve installer
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Nov 22, 2021
1 parent b749210 commit 98ceebb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
54 changes: 27 additions & 27 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -340,7 +340,7 @@ export function updateAndInstallServeD(env: any): Thenable<boolean | undefined>
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);
Expand Down Expand Up @@ -482,33 +482,33 @@ export function extractServedBuiltDate(log: string): Date | false {
}

export function compileServeD(ref?: string): (env: NodeJS.ProcessEnv) => Promise<boolean | undefined> {
return (env: any) => new Promise<boolean | undefined>((resolve) => {
return (env: any) => new Promise<boolean | undefined>(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;
});
}

Expand Down

0 comments on commit 98ceebb

Please sign in to comment.