Skip to content

Commit 9b34906

Browse files
committed
Fixed: Bug where tryGetCompiler was wrong as a concept, causing not being able to use dynamically installed compilers
1 parent 4d0a74a commit 9b34906

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

source/app.d

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -388,25 +388,28 @@ int useMain(string[] args)
388388
if(args.length == 1)
389389
return errorMessage();
390390

391-
static string tryGetCompiler(AcceptedCompiler comp, string versionOrPath, out bool useInternalCompilers)
391+
static string tryGetCompiler(AcceptedCompiler comp, string compilerPath, out bool useInternalCompilers)
392392
{
393-
bool useDefaultBehavior = versionOrPath.length == 0;
393+
bool useDefaultBehavior = compilerPath.length == 0;
394394
string compiler = comp == AcceptedCompiler.dmd ? "dmd" : "ldc2";
395395
if(useDefaultBehavior)
396396
{
397397
import redub.tooling.compiler_identification;
398398
CompilerBinary bin = searchCompiler(compiler, false);
399399
if(bin.compiler == comp)
400+
{
401+
useInternalCompilers = true;
400402
return bin.bin;
403+
}
401404
}
402-
else if(exists(versionOrPath)) //Path
405+
else if(exists(compilerPath)) //Path
403406
{
404-
CompilerBinary bin = searchCompiler(versionOrPath, false);
407+
CompilerBinary bin = searchCompiler(compilerPath, false);
405408
if(bin.compiler != comp)
406-
throw new RedubException("Attempt to use path "~versionOrPath~" as a "~compiler~" compiler, but it is a "~bin.getCompilerString);
409+
throw new RedubException("Attempt to use path "~compilerPath~" as a "~compiler~" compiler, but it is a "~bin.getCompilerString);
410+
useInternalCompilers = true;
407411
return bin.bin;
408412
}
409-
useInternalCompilers = true;
410413
return null;
411414
}
412415

@@ -432,19 +435,21 @@ int useMain(string[] args)
432435
else if(compiler == "ldc" || compiler == "ldc2")
433436
{
434437
import redub.api;
435-
string ldcVer = args.length > 2 ? args[2] : null;
438+
string ldcVerOrPath = args.length > 2 ? args[2] : null;
436439
bool useInternal;
437-
string ldcBin = tryGetCompiler(AcceptedCompiler.ldc2, ldcVer, useInternal);
438-
if(useInternal)
440+
string ldcBin = tryGetCompiler(AcceptedCompiler.ldc2, ldcVerOrPath, useInternal);
441+
if(!useInternal)
439442
{
440443
import redub.misc.ldc_install;
441444
import redub.misc.github_tag_check;
442445
enum ldcRepo = "ldc-developers/ldc";
443446

444-
ldcVer = getLatestGitRepositoryTag(ldcRepo);
445-
string ldcFolder = getLdcFolder(ldcVer);
447+
if(!ldcVerOrPath)
448+
ldcVerOrPath = getLatestGitRepositoryTag(ldcRepo);
449+
string ldcFolder = getLdcFolder(ldcVerOrPath);
450+
446451
if(!exists(ldcFolder))
447-
installLdc(ldcVer);
452+
installLdc(ldcVerOrPath);
448453
version(Windows)
449454
ldcBin = buildNormalizedPath(ldcFolder, "ldc2.exe");
450455
else
@@ -455,13 +460,17 @@ int useMain(string[] args)
455460
else if(compiler == "dmd")
456461
{
457462
import redub.misc.dmd_install;
458-
string dmdVer = args.length > 2 ? args[2] : DefaultDMDVersion;
463+
string dmdVerOrPath = args.length > 2 ? args[2] : null;
459464
bool useInternal;
460-
string dmdBin = tryGetCompiler(AcceptedCompiler.dmd, dmdVer, useInternal);
461-
if(useInternal)
465+
string dmdBin = tryGetCompiler(AcceptedCompiler.dmd, dmdVerOrPath, useInternal);
466+
import std.stdio;
467+
writeln("DMD ", dmdBin);
468+
if(!useInternal)
462469
{
463-
string dmdFolder = getDmdFolder(dmdVer);
464-
if(!exists(dmdFolder) && !installDmd(dmdVer))
470+
if(!dmdVerOrPath)
471+
dmdVerOrPath = DefaultDMDVersion;
472+
string dmdFolder = getDmdFolder(dmdVerOrPath);
473+
if(!exists(dmdFolder) && !installDmd(dmdVerOrPath))
465474
{
466475
error("Could not install DMD for using it.");
467476
return 1;

source/redub/buildapi.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import redub.package_searching.api;
77

88

99
///vX.X.X
10-
enum RedubVersionOnly = "v1.31.0";
10+
enum RedubVersionOnly = "v1.31.1";
1111
///Redub vX.X.X
1212
enum RedubVersionShort = "Redub "~RedubVersionOnly;
1313
///Redub vX.X.X - Description

0 commit comments

Comments
 (0)