Skip to content

Commit 9bafdf5

Browse files
committed
Update: Fixing some bugs from compiler inference after optimization
1 parent 9c44998 commit 9bafdf5

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- uses: MrcSnm/setup-dlang@v2
3636
with:
3737
compiler: ldc-latest
38-
redub: master
38+
redub: latest
3939

4040
- name: Build
4141
if: runner.os != 'macOS'

source/redub/building/utils.d

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@ import redub.buildapi;
33
public import redub.misc.shell;
44
import core.sys.posix.sys.ioctl;
55

6-
string[] getHighPriorityCmd(string[] compileFlags)
6+
string[] getHighPriorityCmd(string[] compileFlags, string compilerBin)
77
{
88
version(Posix)
9-
{
10-
import std.array;
11-
string[] ret = new string[compileFlags.length + 3];
12-
ret[0..3] = ["nice", "-n", "0"].staticArray;
13-
ret[3..$] = compileFlags;
14-
return ret;
15-
}
16-
return compileFlags;
9+
return ["nice", "-n", "0", "--", compilerBin] ~ compileFlags;
10+
return [compilerBin] ~ compileFlags;
1711
}
1812

1913
ProcessExec2 execCompiler(const BuildConfiguration cfg, Compiler compiler, string[] compileFlags, out string compilationCommands, bool hasHighPriority, out string cmdFile, const string[string] env)
@@ -44,7 +38,7 @@ ProcessExec2 execCompiler(const BuildConfiguration cfg, Compiler compiler, strin
4438
return ret;
4539
}
4640
compilationCommands = escapeCompilationCommands(compilerBin, compileFlags);
47-
return executeProcess2(cast(const(char)[][])getHighPriorityCmd(compileFlags), env, Config.none, size_t.max, cfg.workingDir);
41+
return executeProcess2(cast(const(char)[][])getHighPriorityCmd(compileFlags, compilerBin), env, Config.none, size_t.max, cfg.workingDir);
4842
}
4943

5044

source/redub/misc/find_executable.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ string findExecutable(string executableName)
5353
}
5454

5555
}
56-
return "";
56+
return null;
5757
}

source/redub/tooling/compilers_inference.d

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,27 @@ private string getActualCompilerToUse(string preferredCompiler, ref string actua
123123
import std.typecons;
124124
import std.process;
125125
import redub.logging;
126-
import std.path: baseName, stripExtension;
126+
import std.path: baseName, stripExtension, isAbsolute;
127+
import redub.misc.find_executable;
127128
Tuple!(int, "status", string, "output") compVersionRes;
129+
compVersionRes.status = 1;
130+
compVersionRes.output = "No compiler found.";
128131

129132
bool preferredTested = false;
130133
foreach(string searchable; preferredCompiler~searchableCompilers)
131134
{
132-
if(preferredTested && searchable == preferredCompiler)
135+
if((preferredTested && searchable == preferredCompiler) || searchable.length == 0)
133136
continue;
134137
if(searchable != preferredCompiler)
135138
searchable = tryGetCompilerOnCwd(searchable);
136139
else
137140
preferredTested = true;
141+
if(!isAbsolute(searchable))
142+
{
143+
searchable = findExecutable(searchable);
144+
if(searchable.length == 0)
145+
continue;
146+
}
138147

139148
string[2] versionCommand = [searchable, "--version"];
140149
size_t args = searchable.baseName.stripExtension != "cl" ? 2 : 1;

0 commit comments

Comments
 (0)