Add mono building for Switch

This commit is contained in:
Wojtek Figat
2021-05-28 09:12:15 +02:00
parent 91672b55d8
commit d5a129cb1b
3 changed files with 41 additions and 2 deletions

View File

@@ -87,7 +87,7 @@ public class mono : DepsModule
options.Libraries.Add(Path.Combine(depsRoot, "libmonosgen-2.0.so"));
break;
case TargetPlatform.Switch:
// TODO: mono for Switch
options.OutputFiles.Add(Path.Combine(depsRoot, "libmonosgen-2.0.a"));
break;
default: throw new InvalidPlatformException(options.Platform.Target);
}

View File

@@ -33,6 +33,7 @@ namespace Flax.Deps.Dependencies
TargetPlatform.XboxOne,
TargetPlatform.PS4,
TargetPlatform.XboxScarlett,
TargetPlatform.Switch,
};
case TargetPlatform.Linux:
return new[]
@@ -614,7 +615,7 @@ namespace Flax.Deps.Dependencies
{ "ANDROID_API", apiLevel },
{ "ANDROID_API_VERSION", apiLevel },
{ "ANDROID_NATIVE_API_LEVEL", apiLevel },
{ "CC", Path.Combine(ndkBin, archName + apiLevel + "-clang") },
{ "CXX", Path.Combine(ndkBin, archName + apiLevel + "-clang++") },
{ "AR", Path.Combine(ndkBin, archName + "-ar") },
@@ -705,6 +706,13 @@ namespace Flax.Deps.Dependencies
Utilities.DirectoryDelete(Path.Combine(bclLibMonoOutput, "2.1", "Facades"));
break;
}
case TargetPlatform.Switch:
{
var type = Type.GetType("Flax.Build.Platforms.Switch.mono");
var method = type.GetMethod("Build");
method.Invoke(null, new object[] { root, options });
break;
}
}
}
}

View File

@@ -263,5 +263,36 @@ namespace Flax.Deps
Utilities.Run("cmake", cmdLine, null, path, Utilities.RunOptions.None, envVars);
}
/// <summary>
/// Runs the bash script via Cygwin tool (native bash on platforms other than Windows).
/// </summary>
/// <param name="path">The path.</param>
/// <param name="workspace">The workspace folder.</param>
/// <param name="envVars">Custom environment variables to pass to the child process.</param>
public static void RunCygwin(string path, string workspace = null, Dictionary<string, string> envVars = null)
{
string app;
switch (BuildPlatform)
{
case TargetPlatform.Windows:
{
var cygwinFolder = Environment.GetEnvironmentVariable("CYGWIN");
if (string.IsNullOrEmpty(cygwinFolder) || !Directory.Exists(cygwinFolder))
{
cygwinFolder = "C:\\cygwin";
if (!Directory.Exists(cygwinFolder))
throw new Exception("Missing Cygwin. Install Cygwin64 to C:\\cygwin or set CYGWIN env variable to install location folder.");
}
app = Path.Combine(cygwinFolder, "bin\\bash.exe");
break;
}
case TargetPlatform.Linux:
app = "bash";
break;
default: throw new InvalidPlatformException(BuildPlatform);
}
Utilities.Run(app, path, null, workspace, Utilities.RunOptions.None, envVars);
}
}
}