forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetCoreRunProgram.cs
More file actions
76 lines (62 loc) · 2.34 KB
/
Copy pathNetCoreRunProgram.cs
File metadata and controls
76 lines (62 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Diagnostics;
using System.IO;
using UnityEditor.Scripting.Compilers;
using UnityEditor.Utils;
using UnityEngine;
namespace UnityEditor.Scripting
{
internal class NetCoreRunProgram : Program
{
static string netcoreRunPath;
static bool? isNetCoreRunSupported;
public static string NetCoreRunPath => netcoreRunPath;
static NetCoreRunProgram()
{
netcoreRunPath = Paths.Combine(EditorApplication.applicationContentsPath, "Tools", "netcorerun", "netcorerun");
if (Application.platform == RuntimePlatform.WindowsEditor)
{
netcoreRunPath += ".exe";
}
}
public NetCoreRunProgram(string executable, string arguments, Action<ProcessStartInfo> setupStartInfo)
{
if (!IsSupported())
{
throw new NotSupportedException("NetCoreRunProgram is not supported on this platform");
}
var startInfo = new ProcessStartInfo
{
FileName = netcoreRunPath,
Arguments = $"{CommandLineFormatter.PrepareFileName(executable)} {arguments}",
CreateNoWindow = true
};
if (setupStartInfo != null)
setupStartInfo(startInfo);
_process.StartInfo = startInfo;
}
public static bool IsSupported()
{
if (isNetCoreRunSupported.HasValue)
return isNetCoreRunSupported.Value;
if (!File.Exists(netcoreRunPath))
{
isNetCoreRunSupported = false;
}
// netcorerun.exe only works with macOS 10.13+
else if (SystemInfo.operatingSystem.StartsWith("Mac OS X 10.", StringComparison.CurrentCulture))
{
var versionText = SystemInfo.operatingSystem.Substring(9);
var version = new Version(versionText);
if (version < new Version(10, 13))
isNetCoreRunSupported = false;
}
if (!isNetCoreRunSupported.HasValue)
isNetCoreRunSupported = true;
return isNetCoreRunSupported.Value;
}
}
}