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:
parent
1758520193
commit
01d52131df
2 changed files with 96 additions and 48 deletions
|
@ -262,17 +262,48 @@ namespace IDE
|
||||||
return true;
|
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 QueueProjectGNULink(Project project, String targetPath, Workspace.Options workspaceOptions, Project.Options options, String objectsArg)
|
||||||
{
|
{
|
||||||
bool isDebug = gApp.mConfigName.IndexOf("Debug", true) != -1;
|
bool isDebug = gApp.mConfigName.IndexOf("Debug", true) != -1;
|
||||||
|
|
||||||
|
bool isMinGW = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if BF_PLATFORM_WINDOWS
|
#if BF_PLATFORM_WINDOWS
|
||||||
|
bool isWSL = mPlatformType == .Linux;
|
||||||
String llvmDir = scope String(IDEApp.sApp.mInstallDir);
|
String llvmDir = scope String(IDEApp.sApp.mInstallDir);
|
||||||
IDEUtils.FixFilePath(llvmDir);
|
IDEUtils.FixFilePath(llvmDir);
|
||||||
llvmDir.Append("llvm/");
|
llvmDir.Append("llvm/");
|
||||||
#else
|
#else
|
||||||
String llvmDir = "";
|
String llvmDir = "";
|
||||||
|
bool isWSL = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//String error = scope String();
|
//String error = scope String();
|
||||||
|
@ -329,7 +360,8 @@ namespace IDE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if BF_PLATFORM_WINDOWS
|
if (isMinGW)
|
||||||
|
{
|
||||||
String[] mingwFiles;
|
String[] mingwFiles;
|
||||||
String fromDir;
|
String fromDir;
|
||||||
|
|
||||||
|
@ -359,7 +391,7 @@ namespace IDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Project> depProjectList = scope List<Project>();
|
List<Project> depProjectList = scope List<Project>();
|
||||||
|
@ -399,12 +431,17 @@ namespace IDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BF_PLATFORM_WINDOWS
|
String gccExePath;
|
||||||
String gccExePath = "c:/mingw/bin/g++.exe";
|
String clangExePath;
|
||||||
String clangExePath = scope String(llvmDir, "bin/clang++.exe");
|
if (isMinGW)
|
||||||
#else
|
{
|
||||||
String gccExePath = "/usr/bin/c++";
|
gccExePath = "c:/mingw/bin/g++.exe";
|
||||||
String clangExePath = scope String("/usr/bin/c++");
|
clangExePath = scope String(llvmDir, "bin/clang++.exe");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gccExePath = "/usr/bin/c++";
|
||||||
|
clangExePath = scope String("/usr/bin/c++");
|
||||||
|
|
||||||
if (File.Exists("/usr/bin/clang++"))
|
if (File.Exists("/usr/bin/clang++"))
|
||||||
{
|
{
|
||||||
|
@ -416,7 +453,7 @@ namespace IDE
|
||||||
gccExePath = "/usr/bin/c++";
|
gccExePath = "/usr/bin/c++";
|
||||||
clangExePath = scope String("/usr/bin/c++");
|
clangExePath = scope String("/usr/bin/c++");
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (project.mNeedsTargetRebuild)
|
if (project.mNeedsTargetRebuild)
|
||||||
{
|
{
|
||||||
|
@ -480,6 +517,14 @@ namespace IDE
|
||||||
workingDir.Append(gApp.mInstallDir);
|
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);
|
var runCmd = gApp.QueueRun(compilerExePath, linkLine, workingDir, .UTF8);
|
||||||
runCmd.mOnlyIfNotFailed = true;
|
runCmd.mOnlyIfNotFailed = true;
|
||||||
var tagetCompletedCmd = new IDEApp.TargetCompletedCmd(project);
|
var tagetCompletedCmd = new IDEApp.TargetCompletedCmd(project);
|
||||||
|
|
|
@ -7606,7 +7606,8 @@ namespace IDE
|
||||||
{
|
{
|
||||||
OutputLine("Failed to execute \"{0}\"", inFileName);
|
OutputLine("Failed to execute \"{0}\"", inFileName);
|
||||||
delete process;
|
delete process;
|
||||||
return executionInstance;
|
delete executionInstance;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runFlags.HasFlag(.NoWait))
|
if (runFlags.HasFlag(.NoWait))
|
||||||
|
@ -10015,7 +10016,7 @@ namespace IDE
|
||||||
canCompile = false;
|
canCompile = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
canCompile = true;
|
canCompile = platform == hostPlatform;
|
||||||
switch (platform)
|
switch (platform)
|
||||||
{
|
{
|
||||||
case .iOS:
|
case .iOS:
|
||||||
|
@ -10024,8 +10025,10 @@ namespace IDE
|
||||||
canCompile = true;
|
canCompile = true;
|
||||||
case .Unknown:
|
case .Unknown:
|
||||||
canCompile = true;
|
canCompile = true;
|
||||||
|
case .Linux:
|
||||||
|
if (hostPlatform == .Windows)
|
||||||
|
canCompile = true; // Use WSL
|
||||||
default:
|
default:
|
||||||
canCompile = platform == hostPlatform;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canCompile)
|
if (!canCompile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue