From bc3cddc774c0b2f9e234296a71dde9dab59b34f5 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 12 Mar 2026 17:23:29 +0100 Subject: [PATCH] Build `msdfgen` for Windows and Android with a minor cleanup for a build script #3944 --- .../ThirdParty/ARM64/libmsdfgen-core.a | 3 + .../Binaries/ThirdParty/x64/msdfgen-core.lib | 3 + .../Flax.Build/Deps/Dependencies/msdfgen.cs | 84 ++++++------------- 3 files changed, 31 insertions(+), 59 deletions(-) create mode 100644 Source/Platforms/Android/Binaries/ThirdParty/ARM64/libmsdfgen-core.a create mode 100644 Source/Platforms/Windows/Binaries/ThirdParty/x64/msdfgen-core.lib diff --git a/Source/Platforms/Android/Binaries/ThirdParty/ARM64/libmsdfgen-core.a b/Source/Platforms/Android/Binaries/ThirdParty/ARM64/libmsdfgen-core.a new file mode 100644 index 000000000..274ba3a52 --- /dev/null +++ b/Source/Platforms/Android/Binaries/ThirdParty/ARM64/libmsdfgen-core.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c34b3e22db047130c0f0a425197f4e27f345c458fbadb73104c7af69d0f9f2cd +size 4560474 diff --git a/Source/Platforms/Windows/Binaries/ThirdParty/x64/msdfgen-core.lib b/Source/Platforms/Windows/Binaries/ThirdParty/x64/msdfgen-core.lib new file mode 100644 index 000000000..3b2aeffc3 --- /dev/null +++ b/Source/Platforms/Windows/Binaries/ThirdParty/x64/msdfgen-core.lib @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1bb19678e7b094a07f035bf9438fde6ec56bc0d68a192a2e719a41aee4089e03 +size 1097914 diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/msdfgen.cs b/Source/Tools/Flax.Build/Deps/Dependencies/msdfgen.cs index 1829f9ff0..5f1e4280c 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/msdfgen.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/msdfgen.cs @@ -7,7 +7,7 @@ using Flax.Build; namespace Flax.Deps.Dependencies { /// - /// Official Open Asset Import Library Repository. Loads 40+ 3D file formats into one unified and clean data structure. http://www.assimp.org + /// Multi-channel signed distance field generator. https://github.com/Chlumsky/msdfgen /// /// class msdfgen : Dependency @@ -23,6 +23,7 @@ namespace Flax.Deps.Dependencies return new[] { TargetPlatform.Windows, + TargetPlatform.Android, }; case TargetPlatform.Linux: return new[] @@ -73,6 +74,7 @@ namespace Flax.Deps.Dependencies public override void Build(BuildOptions options) { var root = options.IntermediateFolder; + var configuration = "Release"; string includeDir = null; var filesToKeep = new[] { @@ -87,86 +89,50 @@ namespace Flax.Deps.Dependencies "-DBUILD_SHARED_LIBS=OFF", "-DMSDFGEN_INSTALL=ON" }; - var cmakeArgs = string.Join(" ", args); // Get the source - CloneGitRepoSingleBranch(root, "https://github.com/Chlumsky/msdfgen.git", "master", "1874bcf7d9624ccc85b4bc9a85d78116f690f35b"); + var commit = "1874bcf7d9624ccc85b4bc9a85d78116f690f35b"; // Version 1.13 + CloneGitRepoSingleBranch(root, "https://github.com/Chlumsky/msdfgen.git", "master", commit); foreach (var platform in options.Platforms) { foreach (var architecture in options.Architectures) { BuildStarted(platform, architecture); + + var buildDir = Path.Combine(root, "build-" + architecture); + var installDir = Path.Combine(root, "install-" + architecture); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + includeDir = Path.Combine(installDir, "include"); + SetupDirectory(buildDir, true); + File.Delete(Path.Combine(root, "CMakeCache.txt")); + + Dictionary envVars = null; + var libName = "libmsdfgen-core.a"; + var cmakeArgs = string.Join(" ", args); switch (platform) { case TargetPlatform.Windows: - { - var configuration = "Release"; - - // Build for Windows - File.Delete(Path.Combine(root, "CMakeCache.txt")); - - var buildDir = Path.Combine(root, "build-" + architecture); - var installDir = Path.Combine(root, "install-" + architecture); - SetupDirectory(buildDir, true); - RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + cmakeArgs); - BuildCmake(buildDir); - Utilities.Run("cmake", $"--install {buildDir} --prefix {installDir} --config {configuration}", null, root, Utilities.RunOptions.DefaultTool); - var depsFolder = GetThirdPartyFolder(options, platform, architecture); - Utilities.FileCopy(Path.Combine(installDir, "lib", "msdfgen-core.lib"), Path.Combine(depsFolder, "msdfgen-core.lib")); - // This will be set multiple times, but the headers are the same anyway. - includeDir = Path.Combine(installDir, "include"); - + case TargetPlatform.XboxOne: + case TargetPlatform.XboxScarlett: + libName = "msdfgen-core.lib"; break; - } case TargetPlatform.Linux: - { - var configuration = "Release"; - var envVars = new Dictionary + envVars = new Dictionary { { "CC", "clang-" + Configuration.LinuxClangMinVer }, { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, { "CXX", "clang++-" + Configuration.LinuxClangMinVer }, { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, }; - - // Build for Linux - File.Delete(Path.Combine(root, "CMakeCache.txt")); - - var buildDir = Path.Combine(root, "build-" + architecture); - var installDir = Path.Combine(root, "install-" + architecture); - SetupDirectory(buildDir, true); - RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + cmakeArgs + " -DCMAKE_POSITION_INDEPENDENT_CODE=ON", envVars); - BuildCmake(buildDir); - Utilities.Run("cmake", $"--install {buildDir} --prefix {installDir} --config {configuration}", null, root, Utilities.RunOptions.DefaultTool); - var depsFolder = GetThirdPartyFolder(options, platform, architecture); - Utilities.FileCopy(Path.Combine(installDir, "lib", "libmsdfgen-core.a"), Path.Combine(depsFolder, "libmsdfgen-core.a")); - // This will be set multiple times, but the headers are the same anyway. - includeDir = Path.Combine(installDir, "include"); - + cmakeArgs += " -DCMAKE_POSITION_INDEPENDENT_CODE=ON"; break; } - case TargetPlatform.Mac: - { - var configuration = "Release"; - // Build for Mac - File.Delete(Path.Combine(root, "CMakeCache.txt")); - - var buildDir = Path.Combine(root, "build-" + architecture); - var installDir = Path.Combine(root, "install-" + architecture); - SetupDirectory(buildDir, true); - RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + cmakeArgs); - BuildCmake(buildDir); - Utilities.Run("cmake", $"--install {buildDir} --prefix {installDir} --config {configuration}", null, root, Utilities.RunOptions.DefaultTool); - var depsFolder = GetThirdPartyFolder(options, platform, architecture); - Utilities.FileCopy(Path.Combine(installDir, "lib", "libmsdfgen-core.a"), Path.Combine(depsFolder, "libmsdfgen-core.a")); - // This will be set multiple times, but the headers are the same anyway. - includeDir = Path.Combine(installDir, "include"); - - break; - } - } + RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + cmakeArgs, envVars); + BuildCmake(buildDir); + Utilities.Run("cmake", $"--install {buildDir} --prefix {installDir} --config {configuration}", null, root, Utilities.RunOptions.DefaultTool); + Utilities.FileCopy(Path.Combine(installDir, "lib", libName), Path.Combine(depsFolder, libName)); } }