Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Wine Location For Resampler Script #1367

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion OpenUtau.Core/Classic/ExeInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks;
using OpenUtau;
using OpenUtau.Core;
Expand All @@ -18,7 +19,34 @@ public static void Install(string filePath, ExeType exeType) {

if (OS.IsMacOS()) {
//reference: https://github.com/stakira/OpenUtau/wiki/Resamplers-and-Wavtools#macos
string MacWrapper = $"#!/bin/sh\r\nRELPATH=\"{fileName}\"\r\n\r\nABSPATH=$(cd \"$(dirname \"$0\")\"; pwd -P)\r\nABSPATH=\"$ABSPATH/$RELPATH\"\r\nif [[ ! -x \"$ABSPATH\" ]]\r\nthen\r\n chmod +x \"$ABSPATH\"\r\nfi\r\nexec /usr/local/bin/wine32on64 \"$ABSPATH\" \"$@\"";

string WineLocation = "/usr/local/bin/wine32on64";

try {
using (var proc = new Process()) {
proc.StartInfo = new ProcessStartInfo{
FileName = "/bin/bash",
Arguments = "-c which wine",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
};

proc.Start();

using (var r = proc.StandardOutput){
string output = r.ReadToEnd().Trim();
proc.WaitForExit();

if (!string.IsNullOrEmpty(output)) {
WineLocation = output;
}
}
}
}
catch {}

string MacWrapper = $"#!/bin/sh\r\nRELPATH=\"{fileName}\"\r\n\r\nABSPATH=$(cd \"$(dirname \"$0\")\"; pwd -P)\r\nABSPATH=\"$ABSPATH/$RELPATH\"\r\nif [[ ! -x \"$ABSPATH\" ]]\r\nthen\r\n chmod +x \"$ABSPATH\"\r\nfi\r\nexec {WineLocation} \"$ABSPATH\" \"$@\"";
File.WriteAllText(Path.ChangeExtension(destName, ".sh"), MacWrapper, new UTF8Encoding(false));
} else if (OS.IsLinux()) {
//reference: https://github.com/stakira/OpenUtau/wiki/Resamplers-and-Wavtools#linux
Expand Down
Loading