Update dependencies for Switch

This commit is contained in:
Wojtek Figat
2025-07-22 22:58:57 +02:00
parent 892e2e0d1e
commit 8ac2385447
5 changed files with 43 additions and 31 deletions

View File

@@ -59,17 +59,11 @@ namespace FlaxEditor.Windows
GameCookerWin = win;
Selector = platformSelector;
PerPlatformOptions[PlatformType.Windows].Init("Output/Windows", "Windows");
PerPlatformOptions[PlatformType.XboxOne].Init("Output/XboxOne", "XboxOne");
PerPlatformOptions[PlatformType.UWP].Init("Output/UWP", "UWP");
PerPlatformOptions[PlatformType.Linux].Init("Output/Linux", "Linux");
PerPlatformOptions[PlatformType.PS4].Init("Output/PS4", "PS4");
PerPlatformOptions[PlatformType.XboxScarlett].Init("Output/XboxScarlett", "XboxScarlett");
PerPlatformOptions[PlatformType.Android].Init("Output/Android", "Android");
PerPlatformOptions[PlatformType.Switch].Init("Output/Switch", "Switch");
PerPlatformOptions[PlatformType.PS5].Init("Output/PS5", "PS5");
PerPlatformOptions[PlatformType.Mac].Init("Output/Mac", "Mac");
PerPlatformOptions[PlatformType.iOS].Init("Output/iOS", "iOS");
foreach (var e in PerPlatformOptions)
{
var str = e.Key.ToString();
e.Value.Init("Output/" + str, str);
}
}
[HideInEditor]
@@ -196,12 +190,14 @@ namespace FlaxEditor.Windows
var label = layout.Label(text, TextAlignment.Center);
label.Label.AutoHeight = true;
}
/// <summary>
/// Used to add platform specific tools if available.
/// </summary>
/// <param name="layout">The layout to start the tools at.</param>
public virtual void OnCustomToolsLayout(LayoutElementsContainer layout) { }
public virtual void OnCustomToolsLayout(LayoutElementsContainer layout)
{
}
public virtual void Build()
{
@@ -256,7 +252,7 @@ namespace FlaxEditor.Windows
if (string.IsNullOrEmpty(sdkPath))
sdkPath = Environment.GetEnvironmentVariable("ANDROID_SDK");
emulatorGroup.Label($"SDK path: {sdkPath}");
// AVD and starting emulator
var avdGroup = emulatorGroup.Group("AVD Emulator");
avdGroup.Label("Note: Create AVDs using Android Studio.");
@@ -273,7 +269,7 @@ namespace FlaxEditor.Windows
{
if (avdListTree.Children.Count > 0)
avdListTree.DisposeChildren();
var processStartInfo = new System.Diagnostics.ProcessStartInfo
{
FileName = Path.Combine(sdkPath, "emulator", "emulator.exe"),
@@ -299,7 +295,7 @@ namespace FlaxEditor.Windows
};
//processSettings.ShellExecute = true;
FlaxEngine.Platform.CreateProcess(ref processSettings);
var output = new string(processSettings.Output);*/
if (output.Length == 0)
{
@@ -345,9 +341,9 @@ namespace FlaxEditor.Windows
processSettings.ShellExecute = true;
FlaxEngine.Platform.CreateProcess(ref processSettings);
};
emulatorGroup.Space(2);
// Device
var installGroup = emulatorGroup.Group("Install");
installGroup.Panel.IsClosed = false;
@@ -391,10 +387,10 @@ namespace FlaxEditor.Windows
processSettings.SaveOutput = true;
processSettings.ShellExecute = false;
FlaxEngine.Platform.CreateProcess(ref processSettings);
var output = new string(processSettings.Output);
*/
if (output.Length > 0 && !output.Equals("List of devices attached", StringComparison.Ordinal))
{
noDevicesLabel.Visible = false;
@@ -403,7 +399,7 @@ namespace FlaxEditor.Windows
{
if (line.Trim().Equals("List of devices attached", StringComparison.Ordinal) || string.IsNullOrEmpty(line.Trim()))
continue;
var tab = line.Split("device ");
if (tab.Length < 2)
continue;
@@ -430,7 +426,7 @@ namespace FlaxEditor.Windows
{
if (deviceListTree.Selection.Count == 0)
return;
// Get built APK at output path
string output = StringUtils.ConvertRelativePathToAbsolute(Globals.ProjectFolder, StringUtils.NormalizePath(Output));
if (!Directory.Exists(output))
@@ -438,7 +434,7 @@ namespace FlaxEditor.Windows
FlaxEditor.Editor.LogWarning("Can not copy APK because output folder does not exist.");
return;
}
var apkFiles = Directory.GetFiles(output, "*.apk");
if (apkFiles.Length == 0)
{
@@ -457,7 +453,7 @@ namespace FlaxEditor.Windows
}
apkFilesString += $" \"{file}\"";
}
CreateProcessSettings processSettings = new CreateProcessSettings
{
FileName = Path.Combine(sdkPath, "platform-tools", "adb.exe"),

View File

@@ -18,6 +18,9 @@ namespace Flax.Deps.Dependencies
/// <seealso cref="Flax.Deps.Dependency" />
class mono : Dependency
{
/// <inheritdoc />
public override bool BuildByDefault => false; // Unused in favor of nethost
/// <inheritdoc />
public override TargetPlatform[] Platforms
{

View File

@@ -43,9 +43,6 @@ namespace Flax.Deps.Dependencies
}
}
/// <inheritdoc />
public override bool BuildByDefault => false;
private string root;
private bool cleanArtifacts;
@@ -296,9 +293,19 @@ namespace Flax.Deps.Dependencies
{
root = options.IntermediateFolder;
// On Windows MAX_PATH=260 might cause some build issues with CMake+Ninja, even when LongPathsEnabled=1
// To solve this, simply use a drive root folder instead of Deps directory
if (BuildPlatform == TargetPlatform.Windows && root.Length > 30)
{
root = Path.Combine(Path.GetPathRoot(root), "nethost");
Log.Info($"Using custom rooted build directory: {root} (due to path size limit)");
SetupDirectory(root, false);
}
// Ensure to have dependencies installed
Utilities.Run("ninja", "--version", null, null, Utilities.RunOptions.ThrowExceptionOnError);
Utilities.Run("cmake", "--version", null, null, Utilities.RunOptions.ThrowExceptionOnError);
Utilities.Run("python", "--version", null, null, Utilities.RunOptions.ThrowExceptionOnError);
// Get the source
if (!Directory.Exists(Path.Combine(root, ".git")))

View File

@@ -428,18 +428,19 @@ namespace Flax.Deps.Dependencies
var buildDir = Path.Combine(root, "build");
// Get the source
SetupDirectory(oggRoot, false);
CloneGitRepo(root, "https://github.com/xiph/vorbis.git");
GitCheckout(root, "master", "98eddc72d36e3421519d54b101c09b57e4d4d10d");
CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git");
GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5");
Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "ogg"), oggRoot, true, true);
Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "vorbis"), buildDir, true, true);
Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data/ogg"), oggRoot, true, true);
Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data/vorbis"), buildDir, true, true);
// Build for Switch
SetupDirectory(oggBuildDir, true);
RunCmake(oggBuildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=\"../install\"");
Utilities.Run("cmake", "--build . --target install", null, oggBuildDir, Utilities.RunOptions.ConsoleLogOutput);
Utilities.FileCopy(Path.Combine(GetBinariesFolder(options, platform), "ogg", "include", "ogg", "config_types.h"), Path.Combine(oggRoot, "install", "include", "ogg", "config_types.h"));
Utilities.FileCopy(Path.Combine(GetBinariesFolder(options, platform), "Data/ogg", "include", "ogg", "config_types.h"), Path.Combine(oggRoot, "install", "include", "ogg", "config_types.h"));
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, string.Format(".. -DCMAKE_BUILD_TYPE=Release -DOGG_INCLUDE_DIR=\"{0}/install/include\" -DOGG_LIBRARY=\"{0}/install/lib\"", oggRoot));
BuildCmake(buildDir);

View File

@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Flax.Build;
using Flax.Build.Platforms;
using Flax.Build.Projects.VisualStudio;
@@ -305,8 +306,12 @@ namespace Flax.Deps
cmdLine = "CMakeLists.txt";
break;
case TargetPlatform.Switch:
cmdLine = string.Format("-DCMAKE_TOOLCHAIN_FILE=\"{1}\\Source\\Platforms\\Switch\\Binaries\\Data\\Switch.cmake\" -G \"NMake Makefiles\" -DCMAKE_MAKE_PROGRAM=\"{0}..\\..\\VC\\bin\\nmake.exe\"", Environment.GetEnvironmentVariable("VS140COMNTOOLS"), Globals.EngineRoot);
{
var nmakeSubdir = "bin\\Hostx64\\x64\\nmake.exe";
var toolset = WindowsPlatform.GetToolsets().First(e => File.Exists(Path.Combine(e.Value, nmakeSubdir)));
cmdLine = string.Format("-DCMAKE_TOOLCHAIN_FILE=\"{1}\\Source\\Platforms\\Switch\\Binaries\\Data\\Switch.cmake\" -G \"NMake Makefiles\" -DCMAKE_MAKE_PROGRAM=\"{0}\"", Path.Combine(toolset.Value, nmakeSubdir), Globals.EngineRoot);
break;
}
case TargetPlatform.Android:
{
var ndk = AndroidNdk.Instance.RootPath;