Fixed toolchain install on windows
This commit is contained in:
@@ -29,7 +29,7 @@ public class InstallerWindow : EditorWindow
|
||||
private void RefreshToolStatus()
|
||||
{
|
||||
mipsToolStatus.Clear();
|
||||
foreach (var tool in ToolchainChecker.requiredTools)
|
||||
foreach (var tool in ToolchainChecker.GetRequiredTools())
|
||||
{
|
||||
mipsToolStatus[tool] = ToolchainChecker.IsToolAvailable(tool);
|
||||
}
|
||||
@@ -148,9 +148,12 @@ public class InstallerWindow : EditorWindow
|
||||
isInstalling = true;
|
||||
EditorUtility.DisplayProgressBar("Installing MIPS Toolchain",
|
||||
"Please wait while the MIPS toolchain is being installed...", 0f);
|
||||
await ToolchainInstaller.InstallToolchain();
|
||||
bool success = await ToolchainInstaller.InstallToolchain();
|
||||
EditorUtility.ClearProgressBar();
|
||||
if (success)
|
||||
{
|
||||
EditorUtility.DisplayDialog("Installation Complete", "MIPS toolchain installed successfully.", "OK");
|
||||
}
|
||||
RefreshToolStatus(); // Update cached statuses after installation
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
|
||||
@@ -1,36 +1,32 @@
|
||||
using UnityEngine;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System;
|
||||
|
||||
public static class ToolchainChecker
|
||||
{
|
||||
public static readonly string[] requiredTools = new[]
|
||||
public static readonly string[] mipsToolSuffixes = new[]
|
||||
{
|
||||
"mipsel-linux-gnu-addr2line",
|
||||
"mipsel-linux-gnu-ar",
|
||||
"mipsel-linux-gnu-as",
|
||||
"mipsel-linux-gnu-cpp",
|
||||
"mipsel-linux-gnu-elfedit",
|
||||
"mipsel-linux-gnu-g++",
|
||||
"mipsel-linux-gnu-gcc",
|
||||
"mipsel-linux-gnu-gcc-ar",
|
||||
"mipsel-linux-gnu-gcc-nm",
|
||||
"mipsel-linux-gnu-gcc-ranlib",
|
||||
"mipsel-linux-gnu-gcov",
|
||||
"mipsel-linux-gnu-ld",
|
||||
"mipsel-linux-gnu-nm",
|
||||
"mipsel-linux-gnu-objcopy",
|
||||
"mipsel-linux-gnu-objdump",
|
||||
"mipsel-linux-gnu-ranlib",
|
||||
"mipsel-linux-gnu-readelf",
|
||||
"mipsel-linux-gnu-size",
|
||||
"mipsel-linux-gnu-strings",
|
||||
"mipsel-linux-gnu-strip"
|
||||
"addr2line", "ar", "as", "cpp", "elfedit", "g++", "gcc", "gcc-ar", "gcc-nm",
|
||||
"gcc-ranlib", "gcov", "ld", "nm", "objcopy", "objdump", "ranlib", "readelf",
|
||||
"size", "strings", "strip"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks for the availability of a given tool by using a system command.
|
||||
/// "where" is used on Windows and "which" on other platforms.
|
||||
/// Returns the full tool names to be checked, based on platform.
|
||||
/// </summary>
|
||||
public static string[] GetRequiredTools()
|
||||
{
|
||||
string prefix = Application.platform == RuntimePlatform.WindowsEditor
|
||||
? "mipsel-none-elf-"
|
||||
: "mipsel-linux-gnu-";
|
||||
|
||||
return mipsToolSuffixes.Select(s => prefix + s).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks for availability of any tool (either full name like "make" or "mipsel-*").
|
||||
/// </summary>
|
||||
public static bool IsToolAvailable(string toolName)
|
||||
{
|
||||
@@ -55,7 +51,22 @@ public static class ToolchainChecker
|
||||
string output = process.StandardOutput.ReadToEnd().Trim();
|
||||
process.WaitForExit();
|
||||
|
||||
return !string.IsNullOrEmpty(output);
|
||||
if (!string.IsNullOrEmpty(output))
|
||||
return true;
|
||||
|
||||
// Additional fallback for MIPS tools on Windows in local MIPS path
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor &&
|
||||
toolName.StartsWith("mipsel-none-elf-"))
|
||||
{
|
||||
string localMipsBin = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"mips", "mips", "bin");
|
||||
|
||||
string fullPath = Path.Combine(localMipsBin, toolName + ".exe");
|
||||
return File.Exists(fullPath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public static class ToolchainInstaller
|
||||
{
|
||||
@@ -21,11 +22,25 @@ public static class ToolchainInstaller
|
||||
{
|
||||
var tcs = new TaskCompletionSource<int>();
|
||||
|
||||
if (fileName.Equals("mips", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
fileName = "powershell";
|
||||
|
||||
// Get the AppData\Roaming path for the user
|
||||
string roamingPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
|
||||
string scriptPath = Path.Combine(roamingPath, "mips\\mips.ps1");
|
||||
|
||||
// Pass the arguments to the PowerShell script
|
||||
arguments = $"-ExecutionPolicy Bypass -File \"{scriptPath}\" {arguments}";
|
||||
}
|
||||
|
||||
|
||||
Process process = new Process();
|
||||
process.StartInfo.FileName = fileName;
|
||||
process.StartInfo.Arguments = arguments;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.CreateNoWindow = false;
|
||||
process.StartInfo.UseShellExecute = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(workingDirectory))
|
||||
process.StartInfo.WorkingDirectory = workingDirectory;
|
||||
|
||||
@@ -50,6 +65,7 @@ public static class ToolchainInstaller
|
||||
throw new Exception($"Process '{fileName} {arguments}' exited with code {exitCode}");
|
||||
}
|
||||
|
||||
|
||||
#region MIPS Toolchain Installation
|
||||
|
||||
/// <summary>
|
||||
@@ -66,7 +82,7 @@ public static class ToolchainInstaller
|
||||
await RunCommandAsync("powershell",
|
||||
"-c \"& { iwr -UseBasicParsing https://raw.githubusercontent.com/grumpycoders/pcsx-redux/main/mips.ps1 | iex }\"");
|
||||
EditorUtility.DisplayDialog("Reboot Required",
|
||||
"Installing the MIPS toolchain requires a reboot. Please reboot your computer before proceeding further.",
|
||||
"Installing the MIPS toolchain requires a reboot. Please reboot your computer and click the button again.",
|
||||
"OK");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -81,7 +97,7 @@ public static class ToolchainInstaller
|
||||
/// Installs the MIPS toolchain based on the current platform.
|
||||
/// Uses pkexec on Linux to request graphical elevation.
|
||||
/// </summary>
|
||||
public static async Task InstallToolchain()
|
||||
public static async Task<bool> InstallToolchain()
|
||||
{
|
||||
switch (Application.platform)
|
||||
{
|
||||
@@ -91,10 +107,11 @@ public static class ToolchainInstaller
|
||||
if (!ToolchainChecker.IsToolAvailable("mips"))
|
||||
{
|
||||
await InstallMips();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (win32MipsToolsInstalling) return;
|
||||
if (win32MipsToolsInstalling) return false;
|
||||
win32MipsToolsInstalling = true;
|
||||
await RunCommandAsync("mips", $"install {mipsVersion}");
|
||||
}
|
||||
@@ -168,6 +185,7 @@ public static class ToolchainInstaller
|
||||
"Your platform is not supported by this extension. Please install the MIPS toolchain manually.", "OK");
|
||||
throw new Exception("Unsupported platform");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user