1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Partially allowing WSL compilation

This commit is contained in:
Brian Fiete 2020-06-23 07:33:43 -07:00
parent 1758520193
commit 01d52131df
2 changed files with 96 additions and 48 deletions

View file

@ -262,17 +262,48 @@ namespace IDE
return true;
}
void WSLPathFix(String str)
{
for (int i = 1; i < str.Length - 1; i++)
{
if (str[i] == ':')
{
if (str[i - 1].IsLetter)
{
int j = i;
for ( ; j < str.Length; j++)
{
char8 cj = str[j];
if (cj == '\\')
str[j] = '/';
if ((cj.IsWhiteSpace) || (cj == '"'))
break;
}
str.Remove(i);
str[i - 1] = str[i - 1].ToLower;
str.Insert(i - 1, "/mnt/");
}
}
}
}
bool QueueProjectGNULink(Project project, String targetPath, Workspace.Options workspaceOptions, Project.Options options, String objectsArg)
{
bool isDebug = gApp.mConfigName.IndexOf("Debug", true) != -1;
bool isMinGW = false;
#if BF_PLATFORM_WINDOWS
bool isWSL = mPlatformType == .Linux;
String llvmDir = scope String(IDEApp.sApp.mInstallDir);
IDEUtils.FixFilePath(llvmDir);
llvmDir.Append("llvm/");
#else
String llvmDir = "";
bool isWSL = false;
#endif
//String error = scope String();
@ -329,7 +360,8 @@ namespace IDE
}
else
{
#if BF_PLATFORM_WINDOWS
if (isMinGW)
{
String[] mingwFiles;
String fromDir;
@ -359,7 +391,7 @@ namespace IDE
}
}
}
#endif
}
}
List<Project> depProjectList = scope List<Project>();
@ -399,12 +431,17 @@ namespace IDE
}
}
#if BF_PLATFORM_WINDOWS
String gccExePath = "c:/mingw/bin/g++.exe";
String clangExePath = scope String(llvmDir, "bin/clang++.exe");
#else
String gccExePath = "/usr/bin/c++";
String clangExePath = scope String("/usr/bin/c++");
String gccExePath;
String clangExePath;
if (isMinGW)
{
gccExePath = "c:/mingw/bin/g++.exe";
clangExePath = scope String(llvmDir, "bin/clang++.exe");
}
else
{
gccExePath = "/usr/bin/c++";
clangExePath = scope String("/usr/bin/c++");
if (File.Exists("/usr/bin/clang++"))
{
@ -416,7 +453,7 @@ namespace IDE
gccExePath = "/usr/bin/c++";
clangExePath = scope String("/usr/bin/c++");
}
#endif
}
if (project.mNeedsTargetRebuild)
{
@ -480,6 +517,14 @@ namespace IDE
workingDir.Append(gApp.mInstallDir);
}
if (isWSL)
{
linkLine.Insert(0, " ");
linkLine.Insert(0, compilerExePath);
compilerExePath = "wsl.exe";
WSLPathFix(linkLine);
}
var runCmd = gApp.QueueRun(compilerExePath, linkLine, workingDir, .UTF8);
runCmd.mOnlyIfNotFailed = true;
var tagetCompletedCmd = new IDEApp.TargetCompletedCmd(project);

View file

@ -7606,7 +7606,8 @@ namespace IDE
{
OutputLine("Failed to execute \"{0}\"", inFileName);
delete process;
return executionInstance;
delete executionInstance;
return null;
}
if (runFlags.HasFlag(.NoWait))
@ -10015,7 +10016,7 @@ namespace IDE
canCompile = false;
}
canCompile = true;
canCompile = platform == hostPlatform;
switch (platform)
{
case .iOS:
@ -10024,8 +10025,10 @@ namespace IDE
canCompile = true;
case .Unknown:
canCompile = true;
case .Linux:
if (hostPlatform == .Windows)
canCompile = true; // Use WSL
default:
canCompile = platform == hostPlatform;
}
if (!canCompile)