mirror of
https://github.com/yuzu-emu/discord-rpc
synced 2024-11-22 22:34:01 +00:00
Fix unity build for osx
This commit is contained in:
parent
82439911c6
commit
50ea4e61c6
1 changed files with 87 additions and 42 deletions
|
@ -15,28 +15,71 @@ public class ScriptBatch
|
||||||
return new FileInfo(filename).Exists;
|
return new FileInfo(filename).Exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnsureDLL()
|
public static bool RunRpcBuildScript()
|
||||||
{
|
|
||||||
UnityEngine.Debug.Log("Make sure Discord dll exists");
|
|
||||||
|
|
||||||
string dstDll32 = "Assets/Plugins/x86/discord-rpc.dll";
|
|
||||||
string dstDll64 = "Assets/Plugins/x86_64/discord-rpc.dll";
|
|
||||||
|
|
||||||
if (!FileExists(dstDll32) || !FileExists(dstDll64))
|
|
||||||
{
|
|
||||||
string srcDll32 = "../../builds/install/win64-dynamic/bin/discord-rpc.dll";
|
|
||||||
string srcDll64 = "../../builds/install/win64-dynamic/bin/discord-rpc.dll";
|
|
||||||
|
|
||||||
if (!FileExists(srcDll32) || !FileExists(srcDll64))
|
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log("Try to run build script");
|
UnityEngine.Debug.Log("Try to run build script");
|
||||||
|
|
||||||
Process proc = new Process();
|
Process proc = new Process();
|
||||||
|
#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
|
||||||
|
proc.StartInfo.UseShellExecute = false;
|
||||||
|
// brew installs cmake in /usr/local/bin, which Unity seems to strip from PATH?
|
||||||
|
string newPath = proc.StartInfo.EnvironmentVariables["PATH"] + ":/usr/local/bin";
|
||||||
|
proc.StartInfo.EnvironmentVariables["PATH"] = newPath;
|
||||||
|
#endif
|
||||||
proc.StartInfo.FileName = "python";
|
proc.StartInfo.FileName = "python";
|
||||||
proc.StartInfo.Arguments = "build.py";
|
proc.StartInfo.Arguments = "build.py";
|
||||||
proc.StartInfo.WorkingDirectory = "../..";
|
proc.StartInfo.WorkingDirectory = "../..";
|
||||||
proc.Start();
|
proc.Start();
|
||||||
proc.WaitForExit();
|
proc.WaitForExit();
|
||||||
if (proc.ExitCode != 0)
|
return proc.ExitCode == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EnsureDLL()
|
||||||
|
{
|
||||||
|
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||||
|
string[] dstDirs = { "Assets/Plugins", "Assets/Plugins/x86", "Assets/Plugins/x86_64" };
|
||||||
|
string[] dstDlls = { "Assets/Plugins/x86/discord-rpc.dll", "Assets/Plugins/x86_64/discord-rpc.dll" };
|
||||||
|
string[] srcDlls = { "../../builds/install/win64-dynamic/bin/discord-rpc.dll", "../../builds/install/win64-dynamic/bin/discord-rpc.dll" };
|
||||||
|
#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
|
||||||
|
string[] dstDirs = { "Assets/Plugins" };
|
||||||
|
string[] dstDlls = { "Assets/Plugins/discord-rpc.bundle" };
|
||||||
|
string[] srcDlls = { "../../builds/install/osx-dynamic/lib/libdiscord-rpc.dylib" };
|
||||||
|
#else
|
||||||
|
string[] dstDirs = { "Assets/Plugins", "Assets/Plugins/x86", "Assets/Plugins/x86_64" };
|
||||||
|
string[] dstDlls = { "Assets/Plugins/x86/discord-rpc.so", "Assets/Plugins/x86_64/discord-rpc.so" };
|
||||||
|
string[] srcDlls = { "../../builds/install/linux-dynamic/bin/discord-rpc.dll", "../../builds/install/win64-dynamic/bin/discord-rpc.dll" };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Debug.Assert(dstDlls.Length == srcDlls.Length);
|
||||||
|
|
||||||
|
bool exists = true;
|
||||||
|
foreach (string fname in dstDlls)
|
||||||
|
{
|
||||||
|
if (!FileExists(fname))
|
||||||
|
{
|
||||||
|
exists = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
exists = true;
|
||||||
|
foreach (string fname in srcDlls)
|
||||||
|
{
|
||||||
|
if (!FileExists(fname))
|
||||||
|
{
|
||||||
|
exists = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
if (!RunRpcBuildScript())
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError("Build failed");
|
UnityEngine.Debug.LogError("Build failed");
|
||||||
return;
|
return;
|
||||||
|
@ -44,13 +87,15 @@ public class ScriptBatch
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the dirs exist
|
// make sure the dirs exist
|
||||||
Directory.CreateDirectory("Assets/Plugins");
|
foreach (string dirname in dstDirs)
|
||||||
Directory.CreateDirectory("Assets/Plugins/x86");
|
{
|
||||||
Directory.CreateDirectory("Assets/Plugins/x86_64");
|
Directory.CreateDirectory(dirname);
|
||||||
|
}
|
||||||
|
|
||||||
// Copy dlls
|
// Copy dlls
|
||||||
FileUtil.CopyFileOrDirectory("../../builds/install/win64-dynamic/bin/discord-rpc.dll", dstDll64);
|
for (int i = 0; i < dstDlls.Length; ++i)
|
||||||
FileUtil.CopyFileOrDirectory("../../builds/install/win32-dynamic/bin/discord-rpc.dll", dstDll32);
|
{
|
||||||
|
FileUtil.CopyFileOrDirectory(srcDlls[i], dstDlls[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue