From 403d2cedc0a8665328a7efeb3817f6544b642978 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 26 Nov 2025 06:28:54 -0800 Subject: [PATCH] Updates to engine for porting to blue platform --- Source/Engine/Scripting/Scripting.cs | 4 +- Source/Tools/Flax.Build/Build/EngineTarget.cs | 2 +- .../Platforms/Unix/UnixToolchain.cs | 46 +++++++------------ 3 files changed, 19 insertions(+), 33 deletions(-) diff --git a/Source/Engine/Scripting/Scripting.cs b/Source/Engine/Scripting/Scripting.cs index b308f5dae..7f9f2980c 100644 --- a/Source/Engine/Scripting/Scripting.cs +++ b/Source/Engine/Scripting/Scripting.cs @@ -198,7 +198,7 @@ namespace FlaxEngine private static void OnLocalizationChanged() { // Invariant-globalization only (see InitHostfxr with Mono) -#if !(PLATFORM_IOS || PLATFORM_SWITCH) +#if !(PLATFORM_IOS || PLATFORM_SWITCH || PLATFORM_PS4 || PLATFORM_PS5) var currentThread = Thread.CurrentThread; var language = Localization.CurrentLanguage; if (language != null) @@ -261,7 +261,7 @@ namespace FlaxEngine internal static ManagedHandle CultureInfoToManaged(int lcid) { -#if PLATFORM_IOS || PLATFORM_SWITCH +#if PLATFORM_IOS || PLATFORM_SWITCH || PLATFORM_PS4 || PLATFORM_PS5 // Invariant-globalization only (see InitHostfxr with Mono) lcid = 0; #endif diff --git a/Source/Tools/Flax.Build/Build/EngineTarget.cs b/Source/Tools/Flax.Build/Build/EngineTarget.cs index 827205e91..039f9fb16 100644 --- a/Source/Tools/Flax.Build/Build/EngineTarget.cs +++ b/Source/Tools/Flax.Build/Build/EngineTarget.cs @@ -142,7 +142,7 @@ namespace Flax.Build } /// - /// Returns true if this build target should use separate (aka main-only) executable file and separate runtime (in shared library). Used on platforms that don't support linking again executable file but only shared library (see HasExecutableFileReferenceSupport). + /// Returns true if this build target should use separate (aka main-only) executable file and separate runtime (in shared library). Used on platforms that don't support linking (or symbol lookup) against executable file but only shared library (see HasExecutableFileReferenceSupport). /// public virtual bool UseSeparateMainExecutable(BuildOptions buildOptions) { diff --git a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs index 6d5aacdde..fcb4397a1 100644 --- a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs @@ -320,6 +320,17 @@ namespace Flax.Build.Platforms { } + /// + /// Gets linker argument to reference a specific shared library file. + /// + /// The graph. + /// The options. + /// The shared library file path. + protected virtual string GetSharedLibraryLinkArg(TaskGraph graph, BuildOptions options, string library) + { + return string.Format("\"-l{0}\"", GetLibName(library)); + } + /// public override CompileOutput CompileCppFiles(TaskGraph graph, BuildOptions options, List sourceFiles, string outputPath) { @@ -527,7 +538,8 @@ namespace Flax.Build.Platforms // Input libraries var libraryPaths = new HashSet(); - foreach (var library in linkEnvironment.InputLibraries) + var dynamicLibExt = Platform.SharedLibraryFileExtension; + foreach (var library in linkEnvironment.InputLibraries.Concat(options.Libraries)) { var dir = Path.GetDirectoryName(library); var ext = Path.GetExtension(library); @@ -539,37 +551,12 @@ namespace Flax.Build.Platforms { // Skip executable } - else if (ext == ".so") + else if (ext == dynamicLibExt) { // Link against dynamic library task.PrerequisiteFiles.Add(library); libraryPaths.Add(dir); - args.Add(string.Format("\"-l{0}\"", GetLibName(library))); - } - else - { - task.PrerequisiteFiles.Add(library); - args.Add(string.Format("\"{0}\"", GetLibName(library))); - } - } - foreach (var library in options.Libraries) - { - var dir = Path.GetDirectoryName(library); - var ext = Path.GetExtension(library); - if (string.IsNullOrEmpty(dir)) - { - args.Add(string.Format("\"-l{0}\"", library)); - } - else if (string.IsNullOrEmpty(ext)) - { - // Skip executable - } - else if (ext == ".so") - { - // Link against dynamic library - task.PrerequisiteFiles.Add(library); - libraryPaths.Add(dir); - args.Add(string.Format("\"-l{0}\"", GetLibName(library))); + args.Add(GetSharedLibraryLinkArg(graph, options, library)); } else { @@ -580,8 +567,7 @@ namespace Flax.Build.Platforms // Input files (link static libraries last) task.PrerequisiteFiles.AddRange(linkEnvironment.InputFiles); - foreach (var file in linkEnvironment.InputFiles.Where(x => !x.EndsWith(".a")) - .Concat(linkEnvironment.InputFiles.Where(x => x.EndsWith(".a")))) + foreach (var file in linkEnvironment.InputFiles.Where(x => !x.EndsWith(".a")).Concat(linkEnvironment.InputFiles.Where(x => x.EndsWith(".a")))) { args.Add(string.Format("\"{0}\"", file.Replace('\\', '/'))); }