From 578287f3bf5f499ce96851e53a3cd8eb46b01adb Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Mon, 16 Feb 2026 21:25:28 +0200 Subject: [PATCH] _baseline emscripten build --- .lfsconfig | 2 +- Source/ThirdParty/SDL/SDL.Build.cs | 2 +- .../Tools/Flax.Build/Deps/Dependencies/SDL.cs | 1 + Source/Tools/Flax.Build/Deps/Dependency.cs | 2 + Source/Tools/Flax.Build/Deps/DepsBuilder.cs | 79 +++++++++++-------- .../Platforms/Windows/WindowsPlatform.cs | 4 +- 6 files changed, 54 insertions(+), 36 deletions(-) diff --git a/.lfsconfig b/.lfsconfig index b5a7e69fc..43cafc9f0 100644 --- a/.lfsconfig +++ b/.lfsconfig @@ -1,4 +1,4 @@ # Redirect to our own Git LFS server [lfs] -url="https://gitlab.flaxengine.com/flax/flaxengine.git/info/lfs" +#url="https://gitlab.flaxengine.com/flax/flaxengine.git/info/lfs" locksverify = false diff --git a/Source/ThirdParty/SDL/SDL.Build.cs b/Source/ThirdParty/SDL/SDL.Build.cs index 8b55f56c3..a810555bb 100644 --- a/Source/ThirdParty/SDL/SDL.Build.cs +++ b/Source/ThirdParty/SDL/SDL.Build.cs @@ -50,7 +50,7 @@ public class SDL : DepsModule break; case TargetPlatform.Web: options.OutputFiles.Add("--use-port=sdl3"); - return; + break; default: throw new InvalidPlatformException(options.Platform.Target); } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/SDL.cs b/Source/Tools/Flax.Build/Deps/Dependencies/SDL.cs index 7a16e7322..830b43500 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/SDL.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/SDL.cs @@ -24,6 +24,7 @@ namespace Flax.Deps.Dependencies return new[] { TargetPlatform.Windows, + TargetPlatform.Web, }; case TargetPlatform.Linux: return new[] diff --git a/Source/Tools/Flax.Build/Deps/Dependency.cs b/Source/Tools/Flax.Build/Deps/Dependency.cs index 842a57b20..2b1de06ff 100644 --- a/Source/Tools/Flax.Build/Deps/Dependency.cs +++ b/Source/Tools/Flax.Build/Deps/Dependency.cs @@ -97,6 +97,7 @@ namespace Flax.Deps TargetPlatform.PS5, TargetPlatform.Android, TargetPlatform.Switch, + TargetPlatform.Web, }; case TargetPlatform.Linux: return new[] @@ -129,6 +130,7 @@ namespace Flax.Deps { TargetArchitecture.x64, TargetArchitecture.ARM64, + TargetArchitecture.x86, }; case TargetPlatform.Linux: return new[] diff --git a/Source/Tools/Flax.Build/Deps/DepsBuilder.cs b/Source/Tools/Flax.Build/Deps/DepsBuilder.cs index 1b8389080..62432d0d9 100644 --- a/Source/Tools/Flax.Build/Deps/DepsBuilder.cs +++ b/Source/Tools/Flax.Build/Deps/DepsBuilder.cs @@ -1,6 +1,7 @@ // Copyright (c) Wojciech Figat. All rights reserved. using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; @@ -43,7 +44,7 @@ namespace Flax.Deps if (Configuration.BuildArchitectures != null && Configuration.BuildArchitectures.Length != 0) architectures = Configuration.BuildArchitectures; architectures = architectures.Where(buildPlatform.CanBuildArchitecture).ToArray(); - Log.Verbose($"Building deps for platforms {string.Join(',', platforms)}, {string.Join(',', architectures)}:"); + Log.Verbose($"Building deps for platforms [{string.Join(", ", platforms)}] with architectures [{string.Join(", ", architectures)}]:"); foreach (var platform in platforms) { foreach (var architecture in architectures) @@ -59,49 +60,63 @@ namespace Flax.Deps var dependencies = Builder.BuildTypes.Where(x => x.IsSubclassOf(typeof(Dependency))).Select(Activator.CreateInstance).Cast().ToArray(); if (dependencies.Length == 0) Log.Warning("No dependencies found!"); + List failedDependencies = new(); for (var i = 0; i < dependencies.Length; i++) { var dependency = dependencies[i]; - var name = dependency.GetType().Name; - if (depsToBuild.Length > 0 || !dependency.BuildByDefault) + try { - if (!depsToBuild.Contains(name.ToLower())) + var name = dependency.GetType().Name; + if (depsToBuild.Length > 0 || !dependency.BuildByDefault) + { + if (!depsToBuild.Contains(name.ToLower())) + { + Log.Info(string.Format("Skipping {0} ({1}/{2})", name, i + 1, dependencies.Length)); + Log.Verbose("Not selected for build."); + continue; + } + } + + options.Platforms = platforms.Intersect(dependency.Platforms).ToArray(); + if (options.Platforms.Length == 0) { Log.Info(string.Format("Skipping {0} ({1}/{2})", name, i + 1, dependencies.Length)); - Log.Verbose("Not selected for build."); + Log.Verbose("Not used on any of the build platforms."); continue; } - } - options.Platforms = platforms.Intersect(dependency.Platforms).ToArray(); - if (options.Platforms.Length == 0) + options.Architectures = architectures.Intersect(dependency.Architectures).ToArray(); + if (options.Architectures.Length == 0) + { + Log.Info(string.Format("Skipping {0} ({1}/{2})", name, i + 1, dependencies.Length)); + Log.Verbose("Architecture not used on any of the build platforms."); + continue; + } + + Log.Info(string.Format("Building {0} ({1}/{2})", name, i + 1, dependencies.Length)); + + options.IntermediateFolder = Path.Combine(Environment.CurrentDirectory, "Cache", "Intermediate", "Deps", name).Replace('\\', '/'); + if (!Configuration.ReBuildDeps && Directory.Exists(options.IntermediateFolder)) + { + Log.Verbose(string.Format("{0} is up-to-date. Skipping build.", name)); + continue; + } + + var forceEmpty = false; //Configuration.ReBuildDeps; + Dependency.SetupDirectory(options.IntermediateFolder, forceEmpty); + + dependency.Build(options); + } + catch (Exception e) { - Log.Info(string.Format("Skipping {0} ({1}/{2})", name, i + 1, dependencies.Length)); - Log.Verbose("Not used on any of the build platforms."); - continue; + failedDependencies.Add(dependency); + Log.Error(e.ToString()); } + } - options.Architectures = architectures.Intersect(dependency.Architectures).ToArray(); - if (options.Architectures.Length == 0) - { - Log.Info(string.Format("Skipping {0} ({1}/{2})", name, i + 1, dependencies.Length)); - Log.Verbose("Architecture not used on any of the build platforms."); - continue; - } - - Log.Info(string.Format("Building {0} ({1}/{2})", name, i + 1, dependencies.Length)); - - options.IntermediateFolder = Path.Combine(Environment.CurrentDirectory, "Cache", "Intermediate", "Deps", name).Replace('\\', '/'); - if (!Configuration.ReBuildDeps && Directory.Exists(options.IntermediateFolder)) - { - Log.Verbose(string.Format("{0} is up-to-date. Skipping build.", name)); - continue; - } - - var forceEmpty = false; //Configuration.ReBuildDeps; - Dependency.SetupDirectory(options.IntermediateFolder, forceEmpty); - - dependency.Build(options); + if (failedDependencies.Count > 0) + { + Log.Error("Failed to build the following dependencies: " + string.Join(", ", failedDependencies.Select(x => x.GetType().Name))); } Log.Info("Done!"); diff --git a/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatform.cs b/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatform.cs index fb4b55bf9..75ad6a084 100644 --- a/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatform.cs +++ b/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatform.cs @@ -76,8 +76,8 @@ namespace Flax.Build.Platforms public override bool CanBuildArchitecture(TargetArchitecture targetArchitecture) { // Prevent generating configuration data for Windows x86 (deprecated) - if (targetArchitecture == TargetArchitecture.x86) - return false; + //if (targetArchitecture == TargetArchitecture.x86) + // return false; // Check if we have a compiler for this architecture var toolsets = GetToolsets();