From 26261a209096a6df824e1ceaa5577a8356a44a9c Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 12 Oct 2025 14:42:22 +0300 Subject: [PATCH 01/17] Support Visual Studio 2026 as a generator for CMake dependencies --- .../Tools/Flax.Build/Deploy/VCEnvironment.cs | 6 ++++- .../Flax.Build/Deps/Dependencies/PhysX.cs | 26 +++++++++---------- Source/Tools/Flax.Build/Deps/Dependency.cs | 26 ++++++++++++++++++- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs b/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs index cfcbf9866..afe5c8e3c 100644 --- a/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs +++ b/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs @@ -241,7 +241,11 @@ namespace Flax.Deploy if (!File.Exists(solutionFile)) { - throw new Exception(string.Format("Unable to build solution {0}. Solution file not found.", solutionFile)); + // CMake VS2026 generator prefers .slnx solution files, just swap the extension for CMake dependencies + if (File.Exists(Path.ChangeExtension(solutionFile, "slnx"))) + solutionFile = Path.ChangeExtension(solutionFile, "slnx"); + else + throw new Exception(string.Format("Unable to build solution {0}. Solution file not found.", solutionFile)); } string cmdLine = string.Format("\"{0}\" /m /t:Restore,Build /p:Configuration=\"{1}\" /p:Platform=\"{2}\" {3} /nologo", solutionFile, buildConfig, buildPlatform, Verbosity); diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs index 39f7ad975..fe7dd39f7 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs @@ -94,7 +94,7 @@ namespace Flax.Deps.Dependencies case TargetPlatform.Windows: if (architecture == TargetArchitecture.ARM64) { - // Windows ARM64 doesn't have GPU support, so avoid copying those DLLs around + // Windows ARM64 doesn't have precompiled files for GPU support, so avoid copying those DLLs around ConfigureCmakeSwitch(cmakeSwitches, "PX_COPY_EXTERNAL_DLL", "OFF"); ConfigureCmakeSwitch(cmakeParams, "PX_COPY_EXTERNAL_DLL", "OFF"); } @@ -122,7 +122,7 @@ namespace Flax.Deps.Dependencies string bits; string arch; string binariesSubDir; - string buildPlatform; + string buildPlatform = architecture == TargetArchitecture.x86 ? "Win32" : architecture.ToString(); bool suppressBitsPostfix = false; string binariesPrefix = string.Empty; var envVars = new Dictionary(); @@ -146,15 +146,6 @@ namespace Flax.Deps.Dependencies break; default: throw new InvalidArchitectureException(architecture); } - switch (architecture) - { - case TargetArchitecture.x86: - buildPlatform = "Win32"; - break; - default: - buildPlatform = architecture.ToString(); - break; - } var msBuildProps = new Dictionary(); switch (targetPlatform) { @@ -390,8 +381,17 @@ namespace Flax.Deps.Dependencies { case TargetPlatform.Windows: { - Build(options, "vc17win64", platform, TargetArchitecture.x64); - Build(options, "vc17win-arm64", platform, TargetArchitecture.ARM64); + try + { + Build(options, "vc18win64", platform, architecture); + Build(options, "vc18win-arm64", platform, architecture); + } + catch + { + Log.Verbose("Failed to generate VS2026 solution for PhysX, fallback to VS2022"); + Build(options, "vc17win64", platform, architecture); + Build(options, "vc17win-arm64", platform, architecture); + } break; } case TargetPlatform.Linux: diff --git a/Source/Tools/Flax.Build/Deps/Dependency.cs b/Source/Tools/Flax.Build/Deps/Dependency.cs index 43cdcc146..010a45175 100644 --- a/Source/Tools/Flax.Build/Deps/Dependency.cs +++ b/Source/Tools/Flax.Build/Deps/Dependency.cs @@ -47,6 +47,24 @@ namespace Flax.Deps /// protected static TargetPlatform BuildPlatform => Platform.BuildPlatform.Target; + + private static Version? _cmakeVersion; + protected static Version CMakeVersion + { + get + { + if (_cmakeVersion == null) + { + var versionOutput = Utilities.ReadProcessOutput("cmake", "--version"); + var versionStart = versionOutput.IndexOf("cmake version ") + "cmake version ".Length; + var versionEnd = versionOutput.IndexOfAny(['-', '\n', '\r'], versionStart); // End of line or dash before Git hash + var versionString = versionOutput.Substring(versionStart, versionEnd - versionStart); + _cmakeVersion = new Version(versionString); + } + return _cmakeVersion; + } + } + /// /// Gets the platforms list supported by this dependency to build on the current build platform (based on ). /// @@ -309,7 +327,13 @@ namespace Flax.Deps break; default: throw new InvalidArchitectureException(architecture); } - cmdLine = string.Format("CMakeLists.txt -G \"Visual Studio 17 2022\" -A {0}", arch); + if (CMakeVersion.Major > 4 || (CMakeVersion.Major == 4 && CMakeVersion.Minor >= 2)) + { + // This generates both .sln and .slnx solution files + cmdLine = string.Format("CMakeLists.txt -G \"Visual Studio 17 2022\" -G \"Visual Studio 18 2026\" -A {0}", arch); + } + else + cmdLine = string.Format("CMakeLists.txt -G \"Visual Studio 17 2022\" -A {0}", arch); break; } case TargetPlatform.PS4: From 0c462315f080c0fbe0d93367772c2d25d400d792 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 12 Oct 2025 17:00:58 +0300 Subject: [PATCH 02/17] Fix CMake compatibility errors with dependencies --- Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs | 2 +- Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs | 12 +++++++----- .../Tools/Flax.Build/Deps/Dependencies/freetype.cs | 10 +++++----- Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs index 1120a94f8..f296bc9b9 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs @@ -110,7 +110,7 @@ namespace Flax.Deps.Dependencies // Peek options var binariesPrefix = string.Empty; var binariesPostfix = string.Empty; - var cmakeArgs = "-DNV_CLOTH_ENABLE_DX11=0 -DNV_CLOTH_ENABLE_CUDA=0 -DPX_GENERATE_GPU_PROJECTS=0"; + var cmakeArgs = "-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DNV_CLOTH_ENABLE_DX11=0 -DNV_CLOTH_ENABLE_CUDA=0 -DPX_GENERATE_GPU_PROJECTS=0"; var cmakeName = string.Empty; var buildFolder = Path.Combine(nvCloth, "compiler", platform.ToString() + '_' + architecture.ToString()); var envVars = new Dictionary(); diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs b/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs index 319ad70b3..79be778ef 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs @@ -51,6 +51,7 @@ namespace Flax.Deps.Dependencies var root = options.IntermediateFolder; var version = "1.24.3"; var configuration = "Release"; + var cmakeArgs = "-DCMAKE_POLICY_VERSION_MINIMUM=3.5"; var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "OpenAL"); var noSSL = true; // OpenAL Soft website has broken certs @@ -77,7 +78,7 @@ namespace Flax.Deps.Dependencies var buildDir = Path.Combine(root, "build-" + architecture.ToString()); var solutionPath = Path.Combine(buildDir, "OpenAL.sln"); - RunCmake(root, platform, architecture, $"-B\"{buildDir}\" -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=\"/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR /EHsc\" -DCMAKE_CXX_FLAGS=\"/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR /EHsc\""); + RunCmake(root, platform, architecture, $"-B\"{buildDir}\" -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=\"/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR /EHsc\" -DCMAKE_CXX_FLAGS=\"/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR /EHsc\" " + cmakeArgs); Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, architecture.ToString()); var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesToCopy) @@ -132,7 +133,8 @@ namespace Flax.Deps.Dependencies $"-DALSOFT_REQUIRE_PULSEAUDIO=ON " + $"-DALSOFT_REQUIRE_JACK=ON " + $"-DALSOFT_REQUIRE_PIPEWIRE=ON " + - $"-DALSOFT_EMBED_HRTF_DATA=YES "; + $"-DALSOFT_EMBED_HRTF_DATA=YES " + + cmakeArgs; // Get the source var packagePath = Path.Combine(root, "package.zip"); @@ -163,7 +165,7 @@ namespace Flax.Deps.Dependencies { { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, }; - var config = " -DALSOFT_REQUIRE_OBOE=OFF -DALSOFT_REQUIRE_OPENSL=ON -DALSOFT_EMBED_HRTF_DATA=YES"; + var config = " -DALSOFT_REQUIRE_OBOE=OFF -DALSOFT_REQUIRE_OPENSL=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; // Get the source var packagePath = Path.Combine(root, "package.zip"); @@ -203,7 +205,7 @@ namespace Flax.Deps.Dependencies { { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, }; - var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES"; + var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; // Get the source var packagePath = Path.Combine(root, "package.zip"); @@ -237,7 +239,7 @@ namespace Flax.Deps.Dependencies { { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, }; - var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES"; + var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; // Get the source var packagePath = Path.Combine(root, "package.zip"); diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs index 89ed09a72..0692ad8e9 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs @@ -143,7 +143,7 @@ namespace Flax.Deps.Dependencies // Build for Linux SetupDirectory(buildDir, true); var toolchain = UnixToolchain.GetToolchainName(platform, TargetArchitecture.x64); - Utilities.Run("cmake", string.Format("-G \"Unix Makefiles\" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_TARGET={0} ..", toolchain), null, buildDir, Utilities.RunOptions.DefaultTool, envVars); + Utilities.Run("cmake", string.Format("-G \"Unix Makefiles\" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_TARGET={0} ..", toolchain), null, buildDir, Utilities.RunOptions.DefaultTool, envVars); Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.DefaultTool, envVars); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); @@ -214,7 +214,7 @@ namespace Flax.Deps.Dependencies // Build for Android SetupDirectory(buildDir, true); - RunCmake(buildDir, TargetPlatform.Android, TargetArchitecture.ARM64, ".. -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF -DCMAKE_BUILD_TYPE=Release"); + RunCmake(buildDir, TargetPlatform.Android, TargetArchitecture.ARM64, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF -DCMAKE_BUILD_TYPE=Release"); BuildCmake(buildDir); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); @@ -224,7 +224,7 @@ namespace Flax.Deps.Dependencies { // Build for Switch SetupDirectory(buildDir, true); - RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release"); + RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release"); BuildCmake(buildDir); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); @@ -236,7 +236,7 @@ namespace Flax.Deps.Dependencies foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) { SetupDirectory(buildDir, true); - RunCmake(buildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release"); + RunCmake(buildDir, platform, architecture, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release"); BuildCmake(buildDir); var depsFolder = GetThirdPartyFolder(options, platform, architecture); Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); @@ -253,7 +253,7 @@ namespace Flax.Deps.Dependencies // Build for iOS SetupDirectory(buildDir, true); - RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DIOS_PLATFORM=OS -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_BUILD_TYPE=Release -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF"); + RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DIOS_PLATFORM=OS -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_BUILD_TYPE=Release -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF"); BuildCmake(buildDir); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs index d22f8696f..f2dc8af3b 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs @@ -297,7 +297,7 @@ namespace Flax.Deps.Dependencies { var solutionPath = Path.Combine(oggBuildDir, "ogg.sln"); - RunCmake(oggRoot, platform, architecture, $"-B\"{oggBuildDir}\" -DBUILD_SHARED_LIBS=OFF"); + RunCmake(oggRoot, platform, architecture, $"-B\"{oggBuildDir}\" -DBUILD_SHARED_LIBS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5"); Deploy.VCEnvironment.BuildSolution(solutionPath, configurationMsvc, architecture.ToString()); foreach (var file in oggBinariesToCopyWindowsCmake) binariesToCopy.Add((Path.Combine(oggBuildDir, configurationMsvc, file.Item1), file.Item2)); @@ -308,7 +308,7 @@ namespace Flax.Deps.Dependencies var oggLibraryPath = Path.Combine(oggBuildDir, configurationMsvc, "ogg" + ext); var solutionPath = Path.Combine(vorbisBuildDir, "vorbis.sln"); - RunCmake(vorbisRoot, platform, architecture, $"-B\"{vorbisBuildDir}\" -DOGG_INCLUDE_DIR=\"{Path.Combine(oggRoot, "include")}\" -DOGG_LIBRARY=\"{oggLibraryPath}\" -DBUILD_SHARED_LIBS=OFF"); + RunCmake(vorbisRoot, platform, architecture, $"-B\"{vorbisBuildDir}\" -DOGG_INCLUDE_DIR=\"{Path.Combine(oggRoot, "include")}\" -DOGG_LIBRARY=\"{oggLibraryPath}\" -DBUILD_SHARED_LIBS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5"); Deploy.VCEnvironment.BuildSolution(solutionPath, configurationMsvc, architecture.ToString()); foreach (var file in vorbisBinariesToCopyWindowsCmake) binariesToCopy.Add((Path.Combine(vorbisBuildDir, "lib", configurationMsvc, file.Item1), file.Item2)); From 028f3a7871aecdff3cc46df707f16643c1e4328b Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 02:33:22 +0300 Subject: [PATCH 03/17] Add support for building dependencies with specific architecture --- .../Tools/Flax.Build/Deps/Dependencies/AGS.cs | 20 +- .../Flax.Build/Deps/Dependencies/Assimp.cs | 103 +++-- .../Deps/Dependencies/DirectXMesh.cs | 30 +- .../Dependencies/DirectXShaderCompiler.cs | 40 +- .../Deps/Dependencies/DirectXTex.cs | 80 ++-- .../Deps/Dependencies/NewtonsoftJson.cs | 18 + .../Flax.Build/Deps/Dependencies/NvCloth.cs | 95 +++-- .../Flax.Build/Deps/Dependencies/OpenAL.cs | 365 +++++++++--------- .../Flax.Build/Deps/Dependencies/PhysX.cs | 158 +++++--- .../Flax.Build/Deps/Dependencies/UVAtlas.cs | 46 ++- .../Flax.Build/Deps/Dependencies/astc.cs | 38 +- .../Flax.Build/Deps/Dependencies/curl.cs | 140 ++++--- .../Flax.Build/Deps/Dependencies/dbghelp.cs | 34 +- .../Flax.Build/Deps/Dependencies/freetype.cs | 314 ++++++++------- .../Flax.Build/Deps/Dependencies/glslang.cs | 171 ++++---- .../Flax.Build/Deps/Dependencies/mono.cs | 30 ++ .../Flax.Build/Deps/Dependencies/nethost.cs | 64 ++- .../Flax.Build/Deps/Dependencies/nvapi.cs | 19 +- .../Flax.Build/Deps/Dependencies/vorbis.cs | 259 +++++++------ Source/Tools/Flax.Build/Deps/Dependency.cs | 14 +- Source/Tools/Flax.Build/Deps/DepsBuilder.cs | 31 +- 21 files changed, 1280 insertions(+), 789 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/AGS.cs b/Source/Tools/Flax.Build/Deps/Dependencies/AGS.cs index 60be17f0b..c756bb28b 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/AGS.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/AGS.cs @@ -18,6 +18,24 @@ namespace Flax.Deps.Dependencies get => new[] { TargetPlatform.Windows }; } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -30,7 +48,7 @@ namespace Flax.Deps.Dependencies // Copy files foreach (var platform in options.Platforms) { - BuildStarted(platform); + BuildStarted(platform, TargetArchitecture.x64); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); Utilities.FileCopy(Path.Combine(root, "ags_lib/lib/amd_ags_x64.lib"), Path.Combine(depsFolder, "amd_ags_x64.lib")); Utilities.FileCopy(Path.Combine(root, "ags_lib/lib/amd_ags_x64.dll"), Path.Combine(depsFolder, "amd_ags_x64.dll")); diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs b/Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs index bb1c4fa3c..e31a3a059 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; +using System.Linq; using Flax.Build; namespace Flax.Deps.Dependencies @@ -39,6 +40,36 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -91,22 +122,22 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - var configuration = "Release"; - var binariesWin = new[] + BuildStarted(platform, architecture); + switch (platform) { - Path.Combine("bin", configuration, "assimp-vc140-md.dll"), - Path.Combine("lib", configuration, "assimp-vc140-md.lib"), - }; + case TargetPlatform.Windows: + { + var configuration = "Release"; + var binariesWin = new[] + { + Path.Combine("bin", configuration, "assimp-vc140-md.dll"), + Path.Combine("lib", configuration, "assimp-vc140-md.lib"), + }; - // Build for Windows - File.Delete(Path.Combine(root, "CMakeCache.txt")); - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) - { + // Build for Windows + File.Delete(Path.Combine(root, "CMakeCache.txt")); var buildDir = Path.Combine(root, "build-" + architecture); var solutionPath = Path.Combine(buildDir, "Assimp.sln"); SetupDirectory(buildDir, true); @@ -116,42 +147,38 @@ namespace Flax.Deps.Dependencies var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesWin) Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, Path.GetFileName(file))); + break; } - - break; - } - case TargetPlatform.Linux: - { - var envVars = new Dictionary + case TargetPlatform.Linux: { - { "CC", "clang-" + Configuration.LinuxClangMinVer }, - { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, - { "CXX", "clang++-" + Configuration.LinuxClangMinVer }, - { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, - }; + var 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 - RunCmake(root, platform, TargetArchitecture.x64, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig, envVars); - Utilities.Run("make", null, null, root, Utilities.RunOptions.DefaultTool, envVars); - configHeaderFilePath = Path.Combine(root, "include", "assimp", "config.h"); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - Utilities.FileCopy(Path.Combine(root, "lib", "libassimp.a"), Path.Combine(depsFolder, "libassimp.a")); - break; - } - case TargetPlatform.Mac: - { - // Build for Mac - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + // Build for Linux + RunCmake(root, platform, architecture, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig, envVars); + Utilities.Run("make", null, null, root, Utilities.RunOptions.DefaultTool, envVars); + configHeaderFilePath = Path.Combine(root, "include", "assimp", "config.h"); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + Utilities.FileCopy(Path.Combine(root, "lib", "libassimp.a"), Path.Combine(depsFolder, "libassimp.a")); + break; + } + case TargetPlatform.Mac: { + // Build for Mac RunCmake(root, platform, architecture, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig); Utilities.Run("make", null, null, root, Utilities.RunOptions.DefaultTool); configHeaderFilePath = Path.Combine(root, "include", "assimp", "config.h"); var depsFolder = GetThirdPartyFolder(options, platform, architecture); Utilities.FileCopy(Path.Combine(root, "lib", "libassimp.a"), Path.Combine(depsFolder, "libassimp.a")); Utilities.Run("make", "clean", null, root, Utilities.RunOptions.DefaultTool); + break; + } } - break; - } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXMesh.cs b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXMesh.cs index e631b280b..0da78e580 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXMesh.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXMesh.cs @@ -28,6 +28,24 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -46,12 +64,12 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + BuildStarted(platform, architecture); + switch (platform) + { + case TargetPlatform.Windows: { Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, architecture.ToString()); var depsFolder = GetThirdPartyFolder(options, TargetPlatform.Windows, architecture); @@ -61,7 +79,7 @@ namespace Flax.Deps.Dependencies } } break; - } + } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs index 894af3840..3c48290ee 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs @@ -31,22 +31,40 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - var sdk = WindowsPlatformBase.GetSDKs().Last(); - var sdkLibLocation = Path.Combine(sdk.Value, "Lib", WindowsPlatformBase.GetSDKVersion(sdk.Key).ToString(), "um"); - string binLocation = Path.Combine(sdk.Value, "bin", WindowsPlatformBase.GetSDKVersion(sdk.Key).ToString()); - - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + BuildStarted(platform, architecture); + switch (platform) { + case TargetPlatform.Windows: + { + var sdk = WindowsPlatformBase.GetSDKs().Last(); + var sdkLibLocation = Path.Combine(sdk.Value, "Lib", WindowsPlatformBase.GetSDKVersion(sdk.Key).ToString(), "um"); + string binLocation = Path.Combine(sdk.Value, "bin", WindowsPlatformBase.GetSDKVersion(sdk.Key).ToString()); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); string dxilLocation = @$"{binLocation}\{architecture}\dxil.dll"; @@ -60,9 +78,9 @@ namespace Flax.Deps.Dependencies string d3dcompilerLibLocation = @$"{sdkLibLocation}\{architecture}\d3dcompiler.lib"; Utilities.FileCopy(dxcompilerLibLocation, Path.Combine(depsFolder, Path.GetFileName(dxcompilerLibLocation))); Utilities.FileCopy(d3dcompilerLibLocation, Path.Combine(depsFolder, "d3dcompiler_47.lib")); + break; + } } - break; - } } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs index c0d1a461f..3a842b48c 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs @@ -30,6 +30,24 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -47,44 +65,44 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - var solutionPath = Path.Combine(root, "DirectXTex_Desktop_2022_Win10.sln"); - var binFolder = Path.Combine(root, "DirectXTex", "Bin", "Desktop_2022_Win10"); - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + BuildStarted(platform, architecture); + switch (platform) { + case TargetPlatform.Windows: + { + var solutionPath = Path.Combine(root, "DirectXTex_Desktop_2022_Win10.sln"); + var binFolder = Path.Combine(root, "DirectXTex", "Bin", "Desktop_2022_Win10"); Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, architecture.ToString()); var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in outputFileNames) Utilities.FileCopy(Path.Combine(binFolder, architecture.ToString(), configuration, file), Path.Combine(depsFolder, file)); + break; + } + case TargetPlatform.UWP: + { + var solutionPath = Path.Combine(root, "DirectXTex_Windows10_2019.sln"); + var binFolder = Path.Combine(root, "DirectXTex", "Bin", "Windows10_2019"); + Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, "x64"); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + foreach (var file in outputFileNames) + Utilities.FileCopy(Path.Combine(binFolder, "x64", configuration, file), Path.Combine(depsFolder, file)); + break; + } + case TargetPlatform.XboxOne: + case TargetPlatform.XboxScarlett: + { + var solutionPath = Path.Combine(root, "DirectXTex_GDK_2022.sln"); + var binFolder = Path.Combine(root, "DirectXTex", "Bin", "GDK_2022"); + var xboxName = platform == TargetPlatform.XboxOne ? "Gaming.Xbox.XboxOne.x64" : "Gaming.Xbox.Scarlett.x64"; + Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, xboxName); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + foreach (var file in outputFileNames) + Utilities.FileCopy(Path.Combine(binFolder, xboxName, configuration, file), Path.Combine(depsFolder, file)); + break; + } } - break; - } - case TargetPlatform.UWP: - { - var solutionPath = Path.Combine(root, "DirectXTex_Windows10_2019.sln"); - var binFolder = Path.Combine(root, "DirectXTex", "Bin", "Windows10_2019"); - Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, "x64"); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - foreach (var file in outputFileNames) - Utilities.FileCopy(Path.Combine(binFolder, "x64", configuration, file), Path.Combine(depsFolder, file)); - break; - } - case TargetPlatform.XboxOne: - case TargetPlatform.XboxScarlett: - { - var solutionPath = Path.Combine(root, "DirectXTex_GDK_2022.sln"); - var binFolder = Path.Combine(root, "DirectXTex", "Bin", "GDK_2022"); - var xboxName = platform == TargetPlatform.XboxOne ? "Gaming.Xbox.XboxOne.x64" : "Gaming.Xbox.Scarlett.x64"; - Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, xboxName); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - foreach (var file in outputFileNames) - Utilities.FileCopy(Path.Combine(binFolder, xboxName, configuration, file), Path.Combine(depsFolder, file)); - break; - } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/NewtonsoftJson.cs b/Source/Tools/Flax.Build/Deps/Dependencies/NewtonsoftJson.cs index 495de4734..58fb21b25 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/NewtonsoftJson.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/NewtonsoftJson.cs @@ -36,6 +36,24 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs index f296bc9b9..25557cb70 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs @@ -50,6 +50,36 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -61,39 +91,40 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - Build(options, platform, TargetArchitecture.x64); - Build(options, platform, TargetArchitecture.ARM64); - break; - case TargetPlatform.XboxOne: - case TargetPlatform.XboxScarlett: - Build(options, platform, TargetArchitecture.x64); - break; - case TargetPlatform.PS4: - case TargetPlatform.PS5: - Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "NvCloth"), root, true, true); - Build(options, platform, TargetArchitecture.x64); - break; - case TargetPlatform.Switch: - Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "NvCloth"), root, true, true); - Build(options, platform, TargetArchitecture.ARM64); - break; - case TargetPlatform.Android: - Build(options, platform, TargetArchitecture.ARM64); - break; - case TargetPlatform.Mac: - Build(options, platform, TargetArchitecture.x64); - Build(options, platform, TargetArchitecture.ARM64); - break; - case TargetPlatform.iOS: - Build(options, platform, TargetArchitecture.ARM64); - break; - case TargetPlatform.Linux: - Build(options, platform, TargetArchitecture.x64); - break; + BuildStarted(platform, architecture); + switch (platform) + { + case TargetPlatform.Windows: + Build(options, platform, architecture); + break; + case TargetPlatform.XboxOne: + case TargetPlatform.XboxScarlett: + Build(options, platform, TargetArchitecture.x64); + break; + case TargetPlatform.PS4: + case TargetPlatform.PS5: + Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "NvCloth"), root, true, true); + Build(options, platform, TargetArchitecture.x64); + break; + case TargetPlatform.Switch: + Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "NvCloth"), root, true, true); + Build(options, platform, TargetArchitecture.ARM64); + break; + case TargetPlatform.Android: + Build(options, platform, TargetArchitecture.ARM64); + break; + case TargetPlatform.Mac: + Build(options, platform, architecture); + break; + case TargetPlatform.iOS: + Build(options, platform, TargetArchitecture.ARM64); + break; + case TargetPlatform.Linux: + Build(options, platform, architecture); + break; + } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs b/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs index 79be778ef..c87931179 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs @@ -45,6 +45,36 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -55,26 +85,55 @@ namespace Flax.Deps.Dependencies var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "OpenAL"); var noSSL = true; // OpenAL Soft website has broken certs + if (options.Platforms.Contains(TargetPlatform.Windows)) + { + // Get the source + CloneGitRepo(root, "https://github.com/kcat/openal-soft.git"); + GitCheckout(root, "master", "d3875f333fb6abe2f39d82caca329414871ae53b"); // 1.23.1 + } + else + { + // Get the source + var packagePath = Path.Combine(root, $"package-{version}.zip"); + if (!File.Exists(packagePath)) + { + Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL); + using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read)) + { + if (!Directory.Exists(root)) + archive.ExtractToDirectory(root); + root = Path.Combine(root, archive.Entries.First().FullName); + } + } + /*if (Platform.BuildTargetPlatform == TargetPlatform.Windows) + { + // TODO: Maybe use PowerShell Expand-Archive instead? + var sevenZip = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "7-Zip", "7z.exe"); + Utilities.Run(sevenZip, "x package.zip", null, root); + Utilities.Run(sevenZip, "x package", null, root); + } + else + { + Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput); + }*/ + } + foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - var binariesToCopy = new[] + BuildStarted(platform, architecture); + switch (platform) { - "OpenAL32.lib", - "OpenAL32.dll", - }; - - // Get the source - CloneGitRepo(root, "https://github.com/kcat/openal-soft.git"); - GitCheckout(root, "master", "dc7d7054a5b4f3bec1dc23a42fd616a0847af948"); // 1.24.3 - - // Build for Win64 and ARM64 - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + case TargetPlatform.Windows: { + var binariesToCopy = new[] + { + "OpenAL32.lib", + "OpenAL32.dll", + }; + + // Build for Windows var buildDir = Path.Combine(root, "build-" + architecture.ToString()); var solutionPath = Path.Combine(buildDir, "OpenAL.sln"); @@ -83,185 +142,147 @@ namespace Flax.Deps.Dependencies var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesToCopy) Utilities.FileCopy(Path.Combine(buildDir, configuration, file), Path.Combine(depsFolder, Path.GetFileName(file))); - } - + #if false - // Get the binaries - var packagePath = Path.Combine(root, "package.zip"); - if (!File.Exists(packagePath)) - Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-binaries/openal-soft-" + version + "-bin.zip", packagePath, noSSL); - using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read)) - { - if (!Directory.Exists(root)) - archive.ExtractToDirectory(root); - root = Path.Combine(root, archive.Entries.First().FullName); - } + // Get the binaries + var packagePath = Path.Combine(root, "package.zip"); + if (!File.Exists(packagePath)) + Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-binaries/openal-soft-" + version + "-bin.zip", packagePath, noSSL); + using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read)) + { + if (!Directory.Exists(root)) + archive.ExtractToDirectory(root); + root = Path.Combine(root, archive.Entries.First().FullName); + } - // Deploy Win64 binaries - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - Utilities.FileCopy(Path.Combine(root, "bin", "Win64", "soft_oal.dll"), Path.Combine(depsFolder, "OpenAL32.dll")); - Utilities.FileCopy(Path.Combine(root, "libs", "Win64", "OpenAL32.lib"), Path.Combine(depsFolder, "OpenAL32.lib")); + // Deploy Win64 binaries + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + Utilities.FileCopy(Path.Combine(root, "bin", "Win64", "soft_oal.dll"), Path.Combine(depsFolder, "OpenAL32.dll")); + Utilities.FileCopy(Path.Combine(root, "libs", "Win64", "OpenAL32.lib"), Path.Combine(depsFolder, "OpenAL32.lib")); - // Deploy license - Utilities.FileCopy(Path.Combine(root, "COPYING"), Path.Combine(dstIncludePath, "COPYING"), true); + // Deploy license + Utilities.FileCopy(Path.Combine(root, "COPYING"), Path.Combine(dstIncludePath, "COPYING"), true); - // Deploy header files - var files = Directory.GetFiles(Path.Combine(root, "include", "AL")); - foreach (var file in files) - { - Utilities.FileCopy(file, Path.Combine(dstIncludePath, Path.GetFileName(file))); - } + // Deploy header files + var files = Directory.GetFiles(Path.Combine(root, "include", "AL")); + foreach (var file in files) + { + Utilities.FileCopy(file, Path.Combine(dstIncludePath, Path.GetFileName(file))); + } #endif - break; - } - case TargetPlatform.Linux: - { - var binariesToCopy = new[] - { - "libopenal.a", - }; - var envVars = new Dictionary - { - { "CC", "clang-" + Configuration.LinuxClangMinVer }, - { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, - { "CXX", "clang++-" + Configuration.LinuxClangMinVer }, - { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, - }; - var config = $"-DALSOFT_REQUIRE_ALSA=ON " + - $"-DALSOFT_REQUIRE_OSS=ON " + - $"-DALSOFT_REQUIRE_PORTAUDIO=ON " + - $"-DALSOFT_REQUIRE_PULSEAUDIO=ON " + - $"-DALSOFT_REQUIRE_JACK=ON " + - $"-DALSOFT_REQUIRE_PIPEWIRE=ON " + - $"-DALSOFT_EMBED_HRTF_DATA=YES " - + cmakeArgs; - - // Get the source - var packagePath = Path.Combine(root, "package.zip"); - File.Delete(packagePath); - Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL); - Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput); - - // Use separate build directory - root = Path.Combine(root, "openal-soft-" + version); - var buildDir = Path.Combine(root, "build"); - SetupDirectory(buildDir, true); - - // Build for Linux - Utilities.Run("cmake", $"-G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE={configuration} -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLIBTYPE=STATIC {config} ..", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars); - BuildCmake(buildDir, configuration, envVars); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - foreach (var file in binariesToCopy) - Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); - break; - } - case TargetPlatform.Android: - { - var binariesToCopy = new[] - { - "libopenal.a", - }; - var envVars = new Dictionary - { - { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, - }; - var config = " -DALSOFT_REQUIRE_OBOE=OFF -DALSOFT_REQUIRE_OPENSL=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; - - // Get the source - var packagePath = Path.Combine(root, "package.zip"); - File.Delete(packagePath); - Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL); - if (Platform.BuildTargetPlatform == TargetPlatform.Windows) - { - var sevenZip = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "7-Zip", "7z.exe"); - Utilities.Run(sevenZip, "x package.zip", null, root); - Utilities.Run(sevenZip, "x package", null, root); + break; } - else + case TargetPlatform.Linux: { - Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput); + var binariesToCopy = new[] + { + "libopenal.a", + }; + var envVars = new Dictionary + { + { "CC", "clang-" + Configuration.LinuxClangMinVer }, + { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, + { "CXX", "clang++-" + Configuration.LinuxClangMinVer }, + { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, + }; + var config = $"-DALSOFT_REQUIRE_ALSA=ON " + + $"-DALSOFT_REQUIRE_OSS=ON " + + $"-DALSOFT_REQUIRE_PORTAUDIO=ON " + + $"-DALSOFT_REQUIRE_PULSEAUDIO=ON " + + $"-DALSOFT_REQUIRE_JACK=ON " + + $"-DALSOFT_REQUIRE_PIPEWIRE=ON " + + $"-DALSOFT_EMBED_HRTF_DATA=YES " + + cmakeArgs; + + // Use separate build directory + root = Path.Combine(root, "openal-soft-" + version); + var buildDir = Path.Combine(root, "build"); + SetupDirectory(buildDir, true); + + // Build for Linux + Utilities.Run("cmake", $"-G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE={configuration} -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLIBTYPE=STATIC {config} ..", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars); + BuildCmake(buildDir, configuration, envVars); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + foreach (var file in binariesToCopy) + Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); + break; } - - // Use separate build directory - root = Path.Combine(root, "openal-soft-" + version); - var buildDir = Path.Combine(root, "build"); - SetupDirectory(buildDir, true); - - // Build - RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); - BuildCmake(buildDir, envVars); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); - foreach (var file in binariesToCopy) - Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); - break; - } - case TargetPlatform.Mac: - { - var binariesToCopy = new[] + case TargetPlatform.Android: { - "libopenal.a", - }; - var envVars = new Dictionary + var binariesToCopy = new[] + { + "libopenal.a", + }; + var envVars = new Dictionary + { + { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, + }; + var config = "-DALSOFT_REQUIRE_OBOE=OFF -DALSOFT_REQUIRE_OPENSL=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; + + // Use separate build directory + root = Path.Combine(root, "openal-soft-" + version); + var buildDir = Path.Combine(root, "build"); + SetupDirectory(buildDir, true); + + // Build + RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); + BuildCmake(buildDir, envVars); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); + foreach (var file in binariesToCopy) + Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); + break; + } + case TargetPlatform.Mac: { - { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, - }; - var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; + var binariesToCopy = new[] + { + "libopenal.a", + }; + var envVars = new Dictionary + { + { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, + }; + var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; - // Get the source - var packagePath = Path.Combine(root, "package.zip"); - File.Delete(packagePath); - Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL); - Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput); + // Use separate build directory + root = Path.Combine(root, "openal-soft-" + version); + var buildDir = Path.Combine(root, "build"); - // Use separate build directory - root = Path.Combine(root, "openal-soft-" + version); - var buildDir = Path.Combine(root, "build"); - - // Build for Mac - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) - { + // Build for Mac SetupDirectory(buildDir, true); RunCmake(buildDir, platform, architecture, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); BuildCmake(buildDir, envVars); var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesToCopy) Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); + break; } - break; - } - case TargetPlatform.iOS: - { - var binariesToCopy = new[] + case TargetPlatform.iOS: { - "libopenal.a", - }; - var envVars = new Dictionary - { - { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, - }; - var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; + var binariesToCopy = new[] + { + "libopenal.a", + }; + var envVars = new Dictionary + { + { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, + }; + var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; - // Get the source - var packagePath = Path.Combine(root, "package.zip"); - if (!File.Exists(packagePath)) - { - Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL); - Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput); + // Use separate build directory + root = Path.Combine(root, "openal-soft-" + version); + var buildDir = Path.Combine(root, "build"); + + // Build for iOS + SetupDirectory(buildDir, true); + RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); + BuildCmake(buildDir, envVars); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); + foreach (var file in binariesToCopy) + Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); + break; + } } - - // Use separate build directory - root = Path.Combine(root, "openal-soft-" + version); - var buildDir = Path.Combine(root, "build"); - - // Build for iOS - SetupDirectory(buildDir, true); - RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); - BuildCmake(buildDir, envVars); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); - foreach (var file in binariesToCopy) - Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); - break; - } } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs index fe7dd39f7..c5016c3e9 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs @@ -51,6 +51,36 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + private string root; private string projectGenDir; private string projectGenPath; @@ -376,69 +406,79 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - try + BuildStarted(platform, architecture); + switch (platform) { - Build(options, "vc18win64", platform, architecture); - Build(options, "vc18win-arm64", platform, architecture); - } - catch + case TargetPlatform.Windows: { - Log.Verbose("Failed to generate VS2026 solution for PhysX, fallback to VS2022"); - Build(options, "vc17win64", platform, architecture); - Build(options, "vc17win-arm64", platform, architecture); + if (architecture == TargetArchitecture.x64 || architecture == TargetArchitecture.ARM64) + { + try + { + Build(options, architecture == TargetArchitecture.x64 ? "vc18win64" : "vc18win-arm64", platform, architecture); + } + catch + { + Log.Verbose("Failed to generate VS2026 solution for PhysX, fallback to VS2022"); + Build(options, architecture == TargetArchitecture.x64 ? "vc17win64" : "vc17win-arm64", platform, architecture); + } + } + else + throw new InvalidArchitectureException(architecture); + break; + } + case TargetPlatform.Linux: + { + Build(options, "linux", platform, architecture); + break; + } + case TargetPlatform.PS4: + { + Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "PhysX"), root, true, true); + Build(options, "ps4", platform, TargetArchitecture.x64); + break; + } + case TargetPlatform.PS5: + { + Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "PhysX"), root, true, true); + Build(options, "ps5", platform, TargetArchitecture.x64); + break; + } + case TargetPlatform.XboxScarlett: + case TargetPlatform.XboxOne: + { + Build(options, "vc16win64", platform, TargetArchitecture.x64); + break; + } + case TargetPlatform.Android: + { + Build(options, "android", platform, TargetArchitecture.ARM64); + break; + } + case TargetPlatform.Switch: + { + Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "PhysX"), root, true, true); + Build(options, "switch64", platform, TargetArchitecture.ARM64); + break; + } + case TargetPlatform.Mac: + { + if (architecture == TargetArchitecture.x64) + Build(options, "mac64", platform, architecture); + else if (architecture == TargetArchitecture.ARM64) + Build(options, "mac-arm64", platform, architecture); + else + throw new InvalidArchitectureException(architecture); + break; + } + case TargetPlatform.iOS: + { + Build(options, "ios64", platform, TargetArchitecture.ARM64); + break; + } } - break; - } - case TargetPlatform.Linux: - { - Build(options, "linux", platform, TargetArchitecture.x64); - break; - } - case TargetPlatform.PS4: - { - Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "PhysX"), root, true, true); - Build(options, "ps4", platform, TargetArchitecture.x64); - break; - } - case TargetPlatform.PS5: - { - Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "PhysX"), root, true, true); - Build(options, "ps5", platform, TargetArchitecture.x64); - break; - } - case TargetPlatform.XboxScarlett: - case TargetPlatform.XboxOne: - { - Build(options, "vc16win64", platform, TargetArchitecture.x64); - break; - } - case TargetPlatform.Android: - { - Build(options, "android", platform, TargetArchitecture.ARM64); - break; - } - case TargetPlatform.Switch: - { - Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "PhysX"), root, true, true); - Build(options, "switch64", platform, TargetArchitecture.ARM64); - break; - } - case TargetPlatform.Mac: - { - Build(options, "mac64", platform, TargetArchitecture.x64); - Build(options, "mac-arm64", platform, TargetArchitecture.ARM64); - break; - } - case TargetPlatform.iOS: - { - Build(options, "ios64", platform, TargetArchitecture.ARM64); - break; - } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/UVAtlas.cs b/Source/Tools/Flax.Build/Deps/Dependencies/UVAtlas.cs index 617b82af0..f0d29dba9 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/UVAtlas.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/UVAtlas.cs @@ -29,6 +29,36 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -47,23 +77,23 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - // Build for Win64 - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + BuildStarted(platform, architecture); + switch (platform) { + case TargetPlatform.Windows: + { + // Build for Windows Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, architecture.ToString(), new Dictionary() { { "RestorePackagesConfig", "true" } }); var depsFolder = GetThirdPartyFolder(options, TargetPlatform.Windows, architecture); foreach (var file in outputFileNames) { Utilities.FileCopy(Path.Combine(binFolder, architecture.ToString(), "Release", file), Path.Combine(depsFolder, file)); } + break; + } } - break; - } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs b/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs index d5886810d..40ae9d1e0 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs @@ -34,6 +34,30 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -45,12 +69,12 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - - foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 }) + BuildStarted(platform, architecture); + switch (platform) + { + case TargetPlatform.Windows: { string buildDir = Path.Combine(root, "build-" + architecture.ToString()); var isa = architecture == TargetArchitecture.ARM64 ? "-DASTCENC_ISA_NEON=ON" : "-DASTCENC_ISA_SSE2=ON"; @@ -62,8 +86,7 @@ namespace Flax.Deps.Dependencies Utilities.FileCopy(Path.Combine(buildDir, "Source/Release", lib), Path.Combine(depsFolder, "astcenc.lib")); } break; - case TargetPlatform.Mac: - foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 }) + case TargetPlatform.Mac: { string buildDir = Path.Combine(root, "build-" + architecture.ToString()); var isa = architecture == TargetArchitecture.ARM64 ? "-DASTCENC_ISA_NEON=ON" : "-DASTCENC_ISA_SSE2=ON"; @@ -75,6 +98,7 @@ namespace Flax.Deps.Dependencies Utilities.FileCopy(Path.Combine(buildDir, "Source", lib), Path.Combine(depsFolder, "libastcenc.a")); } break; + } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs b/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs index 447f573a7..a559f1c7f 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs @@ -41,6 +41,36 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -69,14 +99,14 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - // Build for Win64 and ARM64 - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + BuildStarted(platform, architecture); + switch (platform) { + case TargetPlatform.Windows: + { + // Build for Windows var buildDir = Path.Combine(root, "build-" + architecture.ToString()); var solutionPath = Path.Combine(buildDir, "CURL.sln"); @@ -85,57 +115,55 @@ namespace Flax.Deps.Dependencies var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesToCopyWin) Utilities.FileCopy(Path.Combine(buildDir, "lib", configuration, file), Path.Combine(depsFolder, Path.GetFileName(file))); + break; } - break; - } - case TargetPlatform.Linux: - { - // Build for Linux - var settings = new[] + case TargetPlatform.Linux: { - "--without-librtmp", - "--without-ssl", - "--with-gnutls", - "--disable-ipv6", - "--disable-manual", - "--disable-verbose", - "--disable-shared", - "--enable-static", - "-disable-ldap --disable-sspi --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb", - }; - var envVars = new Dictionary - { - { "CC", "clang-" + Configuration.LinuxClangMinVer }, - { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, - { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, - }; - var buildDir = Path.Combine(root, "build"); - SetupDirectory(buildDir, true); - Utilities.Run("chmod", "+x configure", null, root, Utilities.RunOptions.DefaultTool); - Utilities.Run(Path.Combine(root, "configure"), string.Join(" ", settings) + " --prefix=\"" + buildDir + "\"", null, root, Utilities.RunOptions.DefaultTool, envVars); - Utilities.Run("make", null, null, root, Utilities.RunOptions.DefaultTool); - Utilities.Run("make", "install", null, root, Utilities.RunOptions.DefaultTool); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - var filename = "libcurl.a"; - Utilities.FileCopy(Path.Combine(buildDir, "lib", filename), Path.Combine(depsFolder, filename)); - break; - } - case TargetPlatform.Mac: - { - // Build for Mac - var settings = new[] - { - "--with-secure-transport", - "--without-librtmp", - "--disable-ipv6", - "--disable-manual", - "--disable-verbose", - "--disable-shared", - "--enable-static", - "-disable-ldap --disable-sspi --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb", - }; - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + // Build for Linux + var settings = new[] + { + "--without-librtmp", + "--without-ssl", + "--with-gnutls", + "--disable-ipv6", + "--disable-manual", + "--disable-verbose", + "--disable-shared", + "--enable-static", + "-disable-ldap --disable-sspi --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb", + }; + var envVars = new Dictionary + { + { "CC", "clang-" + Configuration.LinuxClangMinVer }, + { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, + { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, + }; + var buildDir = Path.Combine(root, "build"); + SetupDirectory(buildDir, true); + Utilities.Run("chmod", "+x configure", null, root, Utilities.RunOptions.DefaultTool); + Utilities.Run(Path.Combine(root, "configure"), string.Join(" ", settings) + " --prefix=\"" + buildDir + "\"", null, root, Utilities.RunOptions.DefaultTool, envVars); + Utilities.Run("make", null, null, root, Utilities.RunOptions.DefaultTool); + Utilities.Run("make", "install", null, root, Utilities.RunOptions.DefaultTool); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + var filename = "libcurl.a"; + Utilities.FileCopy(Path.Combine(buildDir, "lib", filename), Path.Combine(depsFolder, filename)); + break; + } + case TargetPlatform.Mac: { + // Build for Mac + var settings = new[] + { + "--with-secure-transport", + "--without-librtmp", + "--disable-ipv6", + "--disable-manual", + "--disable-verbose", + "--disable-shared", + "--enable-static", + "-disable-ldap --disable-sspi --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb", + }; + var arch = GetAppleArchName(architecture); var archName = arch + "-apple-darwin19"; if (architecture == TargetArchitecture.ARM64) @@ -162,9 +190,9 @@ namespace Flax.Deps.Dependencies var depsFolder = GetThirdPartyFolder(options, platform, architecture); var filename = "libcurl.a"; Utilities.FileCopy(Path.Combine(buildDir, "lib", filename), Path.Combine(depsFolder, filename)); + break; + } } - break; - } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/dbghelp.cs b/Source/Tools/Flax.Build/Deps/Dependencies/dbghelp.cs index 7017560fb..34fac56e0 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/dbghelp.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/dbghelp.cs @@ -30,27 +30,45 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - var sdk = WindowsPlatformBase.GetSDKs().Last(); - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + BuildStarted(platform, architecture); + switch (platform) { + case TargetPlatform.Windows: + { + var sdk = WindowsPlatformBase.GetSDKs().Last(); var depsFolder = GetThirdPartyFolder(options, platform, architecture); var libLocation = @$"{sdk.Value}Debuggers\lib\{architecture}\dbghelp.lib"; var dllLocation = @$"{sdk.Value}Debuggers\{architecture}\dbghelp.dll"; Utilities.FileCopy(libLocation, Path.Combine(depsFolder, Path.GetFileName(libLocation))); Utilities.FileCopy(dllLocation, Path.Combine(depsFolder, Path.GetFileName(dllLocation))); + break; + } } - break; - } } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs index 0692ad8e9..ec3ab5e18 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs @@ -49,6 +49,36 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -94,171 +124,167 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - // Patch the RuntimeLibrary value - File.WriteAllText(vcxprojPath, vcxprojContents); - - // Build for Windows - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + BuildStarted(platform, architecture); + switch (platform) { + case TargetPlatform.Windows: + { + // Patch the RuntimeLibrary value + File.WriteAllText(vcxprojPath, vcxprojContents); + + // Build for Windows Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configurationMsvc, architecture.ToString(), msvcProps); var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var filename in binariesToCopyMsvc) Utilities.FileCopy(Path.Combine(root, "objs", architecture.ToString(), configurationMsvc, filename), Path.Combine(depsFolder, filename)); + break; } - break; - } - case TargetPlatform.Linux: - { - var envVars = new Dictionary + case TargetPlatform.Linux: { - { "CC", "clang-" + Configuration.LinuxClangMinVer }, - { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, - { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, - }; + var envVars = new Dictionary + { + { "CC", "clang-" + Configuration.LinuxClangMinVer }, + { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, + { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, + }; - // Fix scripts - Utilities.Run("dos2unix", "autogen.sh", null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); - Utilities.Run("dos2unix", "configure", null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); - //Utilities.Run("sed", "-i -e \'s/\r$//\' autogen.sh", null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); - //Utilities.Run("sed", "-i -e \'s/\r$//\' configure", null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); - Utilities.Run("chmod", "+x autogen.sh", null, root, Utilities.RunOptions.ThrowExceptionOnError); - Utilities.Run("chmod", "+x configure", null, root, Utilities.RunOptions.ThrowExceptionOnError); + // Fix scripts + Utilities.Run("dos2unix", "autogen.sh", null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); + Utilities.Run("dos2unix", "configure", null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); + //Utilities.Run("sed", "-i -e \'s/\r$//\' autogen.sh", null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); + //Utilities.Run("sed", "-i -e \'s/\r$//\' configure", null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); + Utilities.Run("chmod", "+x autogen.sh", null, root, Utilities.RunOptions.ThrowExceptionOnError); + Utilities.Run("chmod", "+x configure", null, root, Utilities.RunOptions.ThrowExceptionOnError); - Utilities.Run(Path.Combine(root, "autogen.sh"), null, null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); + Utilities.Run(Path.Combine(root, "autogen.sh"), null, null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); - // Disable using libpng even if it's found on the system - var cmakeFile = Path.Combine(root, "CMakeLists.txt"); - File.WriteAllText(cmakeFile, - File.ReadAllText(cmakeFile) - .Replace("find_package(PNG)", "") - .Replace("find_package(ZLIB)", "") - .Replace("find_package(BZip2)", "") - ); + // Disable using libpng even if it's found on the system + var cmakeFile = Path.Combine(root, "CMakeLists.txt"); + File.WriteAllText(cmakeFile, + File.ReadAllText(cmakeFile) + .Replace("find_package(PNG)", "") + .Replace("find_package(ZLIB)", "") + .Replace("find_package(BZip2)", "") + ); - // Build for Linux - SetupDirectory(buildDir, true); - var toolchain = UnixToolchain.GetToolchainName(platform, TargetArchitecture.x64); - Utilities.Run("cmake", string.Format("-G \"Unix Makefiles\" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_TARGET={0} ..", toolchain), null, buildDir, Utilities.RunOptions.DefaultTool, envVars); - Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.DefaultTool, envVars); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); - - break; - } - case TargetPlatform.PS4: - { - // Get the build data files - Utilities.DirectoryCopy( - Path.Combine(GetBinariesFolder(options, platform), "Data", "freetype"), - Path.Combine(root, "builds", "PS4"), false, true); - - // Build for PS4 - var solutionPath = Path.Combine(root, "builds", "PS4", "freetype.sln"); - Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "ORBIS"); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - Utilities.FileCopy(Path.Combine(root, "lib", "PS4", libraryFileName), Path.Combine(depsFolder, libraryFileName)); - - break; - } - case TargetPlatform.PS5: - { - // Get the build data files - Utilities.DirectoryCopy( - Path.Combine(GetBinariesFolder(options, platform), "Data", "freetype"), - Path.Combine(root, "builds", "PS5"), false, true); - Utilities.ReplaceInFile(Path.Combine(root, "include\\freetype\\config\\ftstdlib.h"), "#define ft_getenv getenv", "char* ft_getenv(const char* n);"); - - // Build for PS5 - var solutionPath = Path.Combine(root, "builds", "PS5", "freetype.sln"); - Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "PROSPERO"); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - Utilities.FileCopy(Path.Combine(root, "lib", "PS5", libraryFileName), Path.Combine(depsFolder, libraryFileName)); - - break; - } - case TargetPlatform.XboxOne: - { - // Build for Xbox One x64 - Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configurationMsvc, "x64", msvcProps); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - foreach (var filename in binariesToCopyMsvc) - Utilities.FileCopy(Path.Combine(root, "objs", "x64", configurationMsvc, filename), Path.Combine(depsFolder, filename)); - - break; - } - case TargetPlatform.XboxScarlett: - { - // Build for Xbox Scarlett - Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configurationMsvc, "x64", msvcProps); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - foreach (var filename in binariesToCopyMsvc) - Utilities.FileCopy(Path.Combine(root, "objs", "x64", configurationMsvc, filename), Path.Combine(depsFolder, filename)); - - break; - } - case TargetPlatform.Android: - { - // Disable using libpng even if it's found on the system - var cmakeFile = Path.Combine(root, "CMakeLists.txt"); - File.WriteAllText(cmakeFile, - File.ReadAllText(cmakeFile) - .Replace("find_package(PNG)", "") - .Replace("find_package(ZLIB)", "") - .Replace("find_package(BZip2)", "") - ); - - // Build for Android - SetupDirectory(buildDir, true); - RunCmake(buildDir, TargetPlatform.Android, TargetArchitecture.ARM64, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF -DCMAKE_BUILD_TYPE=Release"); - BuildCmake(buildDir); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); - Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); - break; - } - case TargetPlatform.Switch: - { - // Build for Switch - SetupDirectory(buildDir, true); - RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release"); - BuildCmake(buildDir); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); - Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); - break; - } - case TargetPlatform.Mac: - { - // Build for Mac - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + // Build for Linux + SetupDirectory(buildDir, true); + var toolchain = UnixToolchain.GetToolchainName(platform, architecture); + Utilities.Run("cmake", string.Format("-G \"Unix Makefiles\" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_TARGET={0} ..", toolchain), null, buildDir, Utilities.RunOptions.DefaultTool, envVars); + Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.DefaultTool, envVars); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); + break; + } + case TargetPlatform.PS4: { + // Get the build data files + Utilities.DirectoryCopy( + Path.Combine(GetBinariesFolder(options, platform), "Data", "freetype"), + Path.Combine(root, "builds", "PS4"), false, true); + + // Build for PS4 + var solutionPath = Path.Combine(root, "builds", "PS4", "freetype.sln"); + Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "ORBIS"); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + Utilities.FileCopy(Path.Combine(root, "lib", "PS4", libraryFileName), Path.Combine(depsFolder, libraryFileName)); + + break; + } + case TargetPlatform.PS5: + { + // Get the build data files + Utilities.DirectoryCopy( + Path.Combine(GetBinariesFolder(options, platform), "Data", "freetype"), + Path.Combine(root, "builds", "PS5"), false, true); + Utilities.ReplaceInFile(Path.Combine(root, "include\\freetype\\config\\ftstdlib.h"), "#define ft_getenv getenv", "char* ft_getenv(const char* n);"); + + // Build for PS5 + var solutionPath = Path.Combine(root, "builds", "PS5", "freetype.sln"); + Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "PROSPERO"); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + Utilities.FileCopy(Path.Combine(root, "lib", "PS5", libraryFileName), Path.Combine(depsFolder, libraryFileName)); + + break; + } + case TargetPlatform.XboxOne: + { + // Build for Xbox One x64 + Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configurationMsvc, "x64", msvcProps); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + foreach (var filename in binariesToCopyMsvc) + Utilities.FileCopy(Path.Combine(root, "objs", "x64", configurationMsvc, filename), Path.Combine(depsFolder, filename)); + + break; + } + case TargetPlatform.XboxScarlett: + { + // Build for Xbox Scarlett + Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configurationMsvc, "x64", msvcProps); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + foreach (var filename in binariesToCopyMsvc) + Utilities.FileCopy(Path.Combine(root, "objs", "x64", configurationMsvc, filename), Path.Combine(depsFolder, filename)); + + break; + } + case TargetPlatform.Android: + { + // Disable using libpng even if it's found on the system + var cmakeFile = Path.Combine(root, "CMakeLists.txt"); + File.WriteAllText(cmakeFile, + File.ReadAllText(cmakeFile) + .Replace("find_package(PNG)", "") + .Replace("find_package(ZLIB)", "") + .Replace("find_package(BZip2)", "") + ); + + // Build for Android + SetupDirectory(buildDir, true); + RunCmake(buildDir, TargetPlatform.Android, TargetArchitecture.ARM64, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF -DCMAKE_BUILD_TYPE=Release"); + BuildCmake(buildDir); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); + Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); + break; + } + case TargetPlatform.Switch: + { + // Build for Switch + SetupDirectory(buildDir, true); + RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release"); + BuildCmake(buildDir); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); + Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); + break; + } + case TargetPlatform.Mac: + { + // Build for Mac SetupDirectory(buildDir, true); RunCmake(buildDir, platform, architecture, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release"); BuildCmake(buildDir); var depsFolder = GetThirdPartyFolder(options, platform, architecture); Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); + break; } - break; - } - case TargetPlatform.iOS: - { - // Fix archive creation issue due to missing ar tool - Utilities.ReplaceInFile(Path.Combine(root, "builds/cmake/iOS.cmake"), "set(CMAKE_SYSTEM_NAME Darwin)", "set(CMAKE_SYSTEM_NAME Darwin)\nset(CMAKE_AR ar CACHE FILEPATH \"\" FORCE)"); + case TargetPlatform.iOS: + { + // Fix archive creation issue due to missing ar tool + Utilities.ReplaceInFile(Path.Combine(root, "builds/cmake/iOS.cmake"), "set(CMAKE_SYSTEM_NAME Darwin)", "set(CMAKE_SYSTEM_NAME Darwin)\nset(CMAKE_AR ar CACHE FILEPATH \"\" FORCE)"); - // Fix freetype toolchain rejecting min iPhone version - Utilities.ReplaceInFile(Path.Combine(root, "builds/cmake/iOS.cmake"), "set(CMAKE_OSX_DEPLOYMENT_TARGET \"\"", "set(CMAKE_OSX_DEPLOYMENT_TARGET \"${CMAKE_OSX_DEPLOYMENT_TARGET}\""); + // Fix freetype toolchain rejecting min iPhone version + Utilities.ReplaceInFile(Path.Combine(root, "builds/cmake/iOS.cmake"), "set(CMAKE_OSX_DEPLOYMENT_TARGET \"\"", "set(CMAKE_OSX_DEPLOYMENT_TARGET \"${CMAKE_OSX_DEPLOYMENT_TARGET}\""); - // Build for iOS - SetupDirectory(buildDir, true); - RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DIOS_PLATFORM=OS -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_BUILD_TYPE=Release -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF"); - BuildCmake(buildDir); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); - Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); - break; - } + // Build for iOS + SetupDirectory(buildDir, true); + RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DIOS_PLATFORM=OS -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_BUILD_TYPE=Release -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF"); + BuildCmake(buildDir); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); + Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName)); + break; + } + } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/glslang.cs b/Source/Tools/Flax.Build/Deps/Dependencies/glslang.cs index a876083f8..e5f5e4dfe 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/glslang.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/glslang.cs @@ -38,13 +38,43 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { var root = options.IntermediateFolder; var installDir = Path.Combine(root, "install"); var configuration = "Release"; - var cmakeArgs = string.Format("-DCMAKE_INSTALL_PREFIX=\"{0}\" -DCMAKE_BUILD_TYPE={1} -DENABLE_RTTI=ON -DENABLE_CTEST=OFF -DENABLE_HLSL=ON -DENABLE_SPVREMAPPER=ON -DENABLE_GLSLANG_BINARIES=OFF", installDir, configuration); + var cmakeArgs = $"-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX=\"{installDir}\" -DCMAKE_BUILD_TYPE={configuration} -DENABLE_RTTI=ON -DENABLE_CTEST=OFF -DENABLE_HLSL=ON -DENABLE_SPVREMAPPER=ON -DENABLE_GLSLANG_BINARIES=OFF"; var libsRoot = Path.Combine(installDir, "lib"); // Get the source @@ -56,93 +86,88 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - var outputFiles = new[] - { - Path.Combine(libsRoot, "GenericCodeGen.lib"), - Path.Combine(libsRoot, "MachineIndependent.lib"), - Path.Combine(libsRoot, "HLSL.lib"), - Path.Combine(libsRoot, "OSDependent.lib"), - Path.Combine(libsRoot, "OGLCompiler.lib"), - Path.Combine(libsRoot, "SPIRV-Tools-opt.lib"), - Path.Combine(libsRoot, "SPIRV-Tools.lib"), - Path.Combine(libsRoot, "SPIRV.lib"), - Path.Combine(libsRoot, "glslang.lib"), - }; + BuildStarted(platform, architecture); - // Build for Windows - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + var buildDir = Path.Combine(root, "build-" + architecture.ToString()); + switch (platform) { - var buildDir = Path.Combine(root, "build-" + architecture.ToString()); + case TargetPlatform.Windows: + { + var outputFiles = new[] + { + Path.Combine(libsRoot, "GenericCodeGen.lib"), + Path.Combine(libsRoot, "MachineIndependent.lib"), + Path.Combine(libsRoot, "HLSL.lib"), + Path.Combine(libsRoot, "OSDependent.lib"), + Path.Combine(libsRoot, "OGLCompiler.lib"), + Path.Combine(libsRoot, "SPIRV-Tools-opt.lib"), + Path.Combine(libsRoot, "SPIRV-Tools.lib"), + Path.Combine(libsRoot, "SPIRV.lib"), + Path.Combine(libsRoot, "glslang.lib"), + }; + + // Build for Windows var solutionPath = Path.Combine(buildDir, "glslang.sln"); - SetupDirectory(buildDir, false); - RunCmake(root, platform, architecture, cmakeArgs + $" -B\"{buildDir}\""); - Utilities.Run("cmake", string.Format("--build . --config {0} --target install", configuration), null, buildDir, Utilities.RunOptions.ConsoleLogOutput); + RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + cmakeArgs); Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, architecture.ToString()); + Utilities.Run("cmake", $"--build \"{buildDir}\" --config {configuration} --target install", null, buildDir, Utilities.RunOptions.ConsoleLogOutput); var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in outputFiles) { Utilities.FileCopy(file, Path.Combine(depsFolder, Path.GetFileName(file))); } + break; } - break; - } - case TargetPlatform.Linux: - { - var outputFiles = new[] + case TargetPlatform.Linux: { - Path.Combine(libsRoot, "libGenericCodeGen.a"), - Path.Combine(libsRoot, "libMachineIndependent.a"), - Path.Combine(libsRoot, "libHLSL.a"), - Path.Combine(libsRoot, "libOSDependent.a"), - Path.Combine(libsRoot, "libOGLCompiler.a"), - Path.Combine(libsRoot, "libSPIRV-Tools-opt.a"), - Path.Combine(libsRoot, "libSPIRV-Tools.a"), - Path.Combine(libsRoot, "libSPIRV.a"), - Path.Combine(libsRoot, "libglslang.a"), - }; - var buildDir = root; + var outputFiles = new[] + { + Path.Combine(libsRoot, "libGenericCodeGen.a"), + Path.Combine(libsRoot, "libMachineIndependent.a"), + Path.Combine(libsRoot, "libHLSL.a"), + Path.Combine(libsRoot, "libOSDependent.a"), + Path.Combine(libsRoot, "libOGLCompiler.a"), + Path.Combine(libsRoot, "libSPIRV-Tools-opt.a"), + Path.Combine(libsRoot, "libSPIRV-Tools.a"), + Path.Combine(libsRoot, "libSPIRV.a"), + Path.Combine(libsRoot, "libglslang.a"), + }; - // Build for Linux - RunCmake(root, platform, TargetArchitecture.x64, cmakeArgs); - Utilities.Run("cmake", string.Format("--build . --config {0} --target install", configuration), null, buildDir, Utilities.RunOptions.ConsoleLogOutput); - Utilities.Run("make", null, null, root, Utilities.RunOptions.ConsoleLogOutput); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - foreach (var file in outputFiles) - { - var dst = Path.Combine(depsFolder, Path.GetFileName(file)); - Utilities.FileCopy(file, dst); - //Utilities.Run("strip", string.Format("-s \"{0}\"", dst), null, null, Utilities.RunOptions.ConsoleLogOutput); + // Build for Linux + RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + cmakeArgs); + Utilities.Run("make", null, null, buildDir, Utilities.RunOptions.ConsoleLogOutput); + Utilities.Run("cmake", $"--build \"{buildDir}\" --config {configuration} --target install", null, buildDir, Utilities.RunOptions.ConsoleLogOutput); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + foreach (var file in outputFiles) + { + var dst = Path.Combine(depsFolder, Path.GetFileName(file)); + Utilities.FileCopy(file, dst); + //Utilities.Run("strip", string.Format("-s \"{0}\"", dst), null, null, Utilities.RunOptions.ConsoleLogOutput); + } + break; } - break; - } - case TargetPlatform.Mac: - { - var outputFiles = new[] + case TargetPlatform.Mac: { - Path.Combine(libsRoot, "libGenericCodeGen.a"), - Path.Combine(libsRoot, "libMachineIndependent.a"), - Path.Combine(libsRoot, "libHLSL.a"), - Path.Combine(libsRoot, "libOSDependent.a"), - Path.Combine(libsRoot, "libOGLCompiler.a"), - Path.Combine(libsRoot, "libSPIRV-Tools-opt.a"), - Path.Combine(libsRoot, "libSPIRV-Tools.a"), - Path.Combine(libsRoot, "libSPIRV.a"), - Path.Combine(libsRoot, "libglslang.a"), - }; - var buildDir = root; + var outputFiles = new[] + { + Path.Combine(libsRoot, "libGenericCodeGen.a"), + Path.Combine(libsRoot, "libMachineIndependent.a"), + Path.Combine(libsRoot, "libHLSL.a"), + Path.Combine(libsRoot, "libOSDependent.a"), + Path.Combine(libsRoot, "libOGLCompiler.a"), + Path.Combine(libsRoot, "libSPIRV-Tools-opt.a"), + Path.Combine(libsRoot, "libSPIRV-Tools.a"), + Path.Combine(libsRoot, "libSPIRV.a"), + Path.Combine(libsRoot, "libglslang.a"), + }; - // Build for Mac - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) - { - RunCmake(root, platform, architecture, cmakeArgs); - Utilities.Run("cmake", string.Format("--build . --config {0} --target install", configuration), null, buildDir, Utilities.RunOptions.ConsoleLogOutput); - Utilities.Run("make", null, null, root, Utilities.RunOptions.ConsoleLogOutput); + // Build for Mac + RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + cmakeArgs); + Utilities.Run("make", null, null, buildDir, Utilities.RunOptions.ConsoleLogOutput); + Utilities.Run("cmake", $"--build \"{buildDir}\" --config {configuration} --target install", null, buildDir, Utilities.RunOptions.ConsoleLogOutput); var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in outputFiles) { @@ -150,9 +175,9 @@ namespace Flax.Deps.Dependencies Utilities.FileCopy(file, dst); Utilities.Run("strip", string.Format("\"{0}\"", dst), null, null, Utilities.RunOptions.ConsoleLogOutput); } + break; + } } - break; - } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/mono.cs b/Source/Tools/Flax.Build/Deps/Dependencies/mono.cs index 57d2f74fe..ad402d3d4 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/mono.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/mono.cs @@ -53,6 +53,36 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + private string root; private string monoPropsPath; private string monoPreprocesorDefines; diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/nethost.cs b/Source/Tools/Flax.Build/Deps/Dependencies/nethost.cs index 1991aa605..4e79718df 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/nethost.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/nethost.cs @@ -43,6 +43,39 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + + /// + public override bool BuildByDefault => false; + private string root; private bool cleanArtifacts; @@ -331,24 +364,27 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - var platformData = Path.Combine(GetBinariesFolder(options, platform), "Data", "nethost"); - if (Directory.Exists(platformData)) - Utilities.DirectoryCopy(platformData, root, true, true); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.PS4: - case TargetPlatform.PS5: - case TargetPlatform.XboxOne: - case TargetPlatform.XboxScarlett: - Build(options, platform, TargetArchitecture.x64); + BuildStarted(platform, architecture); + var platformData = Path.Combine(GetBinariesFolder(options, platform), "Data", "nethost"); + if (Directory.Exists(platformData)) + Utilities.DirectoryCopy(platformData, root, true, true); + switch (platform) + { + case TargetPlatform.PS4: + case TargetPlatform.PS5: + case TargetPlatform.XboxOne: + case TargetPlatform.XboxScarlett: + Build(options, platform, TargetArchitecture.x64); break; - case TargetPlatform.Android: - Build(options, platform, TargetArchitecture.ARM64); + case TargetPlatform.Android: + Build(options, platform, TargetArchitecture.ARM64); break; - case TargetPlatform.Switch: - Build(options, platform, TargetArchitecture.ARM64); + case TargetPlatform.Switch: + Build(options, platform, TargetArchitecture.ARM64); break; + } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/nvapi.cs b/Source/Tools/Flax.Build/Deps/Dependencies/nvapi.cs index d1d94b4c1..6f18a9190 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/nvapi.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/nvapi.cs @@ -18,6 +18,23 @@ namespace Flax.Deps.Dependencies get => new[] { TargetPlatform.Windows }; } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64 + }; + default: return new TargetArchitecture[0]; + } + } + } + /// public override void Build(BuildOptions options) { @@ -30,7 +47,7 @@ namespace Flax.Deps.Dependencies // Copy files foreach (var platform in options.Platforms) { - BuildStarted(platform); + BuildStarted(platform, TargetArchitecture.x64); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); Utilities.FileCopy(Path.Combine(root, "amd64/nvapi64.lib"), Path.Combine(depsFolder, "nvapi64.lib")); } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs index f2dc8af3b..402adbe4f 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs @@ -49,6 +49,36 @@ namespace Flax.Deps.Dependencies } } + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + private struct Binary { public string Filename; @@ -337,97 +367,98 @@ namespace Flax.Deps.Dependencies foreach (var platform in options.Platforms) { - BuildStarted(platform); - switch (platform) + foreach (var architecture in options.Architectures) { - case TargetPlatform.Windows: - { - BuildCmake(options, TargetPlatform.Windows, TargetArchitecture.x64); - BuildCmake(options, TargetPlatform.Windows, TargetArchitecture.ARM64); - break; - } - case TargetPlatform.UWP: - { - BuildMsbuild(options, TargetPlatform.UWP, TargetArchitecture.x64); - break; - } - case TargetPlatform.XboxOne: - { - BuildMsbuild(options, TargetPlatform.XboxOne, TargetArchitecture.x64); - break; - } - case TargetPlatform.Linux: - { - // Note: assumes the libogg-dev package is pre-installed on the system - - // Get the source - CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); - - var envVars = new Dictionary + BuildStarted(platform, architecture); + switch (platform) { - { "CC", "clang-" + Configuration.LinuxClangMinVer }, - { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, - { "CXX", "clang++-" + Configuration.LinuxClangMinVer }, - { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, - }; - var buildDir = Path.Combine(root, "build"); + case TargetPlatform.Windows: + { + BuildCmake(options, TargetPlatform.Windows, architecture); + break; + } + case TargetPlatform.UWP: + { + BuildMsbuild(options, TargetPlatform.UWP, architecture); + break; + } + case TargetPlatform.XboxOne: + { + BuildMsbuild(options, TargetPlatform.XboxOne, architecture); + break; + } + case TargetPlatform.Linux: + { + // Note: assumes the libogg-dev package is pre-installed on the system - Utilities.Run(Path.Combine(root, "autogen.sh"), null, null, root, Utilities.RunOptions.DefaultTool, envVars); + // Get the source + CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); - // Build for Linux - var toolchain = UnixToolchain.GetToolchainName(platform, TargetArchitecture.x64); - Utilities.Run(Path.Combine(root, "configure"), string.Format("--host={0}", toolchain), null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); - SetupDirectory(buildDir, true); - Utilities.Run("cmake", "-G \"Unix Makefiles\" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release ..", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars); - Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - foreach (var file in binariesToCopyUnix) - Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); - break; - } - case TargetPlatform.PS4: - { - BuildMsbuild(options, TargetPlatform.PS4, TargetArchitecture.x64); - break; - } - case TargetPlatform.PS5: - { - BuildMsbuild(options, TargetPlatform.PS5, TargetArchitecture.x64); - break; - } - case TargetPlatform.XboxScarlett: - { - BuildMsbuild(options, TargetPlatform.XboxScarlett, TargetArchitecture.x64); - break; - } - case TargetPlatform.Android: - { - var oggRoot = Path.Combine(root, "ogg"); - var oggBuildDir = Path.Combine(oggRoot, "build"); - var buildDir = Path.Combine(root, "build"); + var envVars = new Dictionary + { + { "CC", "clang-" + Configuration.LinuxClangMinVer }, + { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, + { "CXX", "clang++-" + Configuration.LinuxClangMinVer }, + { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, + }; + var buildDir = Path.Combine(root, "build"); - // Get the source - CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); - CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git"); - GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5"); + Utilities.Run(Path.Combine(root, "autogen.sh"), null, null, root, Utilities.RunOptions.DefaultTool, envVars); - // Build for Android - 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); - 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); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); - foreach (var file in binariesToCopyUnix) - Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); - break; - } - case TargetPlatform.Switch: - { - var oggRoot = Path.Combine(root, "ogg"); - var oggBuildDir = Path.Combine(oggRoot, "build"); - var buildDir = Path.Combine(root, "build"); + // Build for Linux + var toolchain = UnixToolchain.GetToolchainName(platform, architecture); + Utilities.Run(Path.Combine(root, "configure"), string.Format("--host={0}", toolchain), null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); + SetupDirectory(buildDir, true); + Utilities.Run("cmake", "-G \"Unix Makefiles\" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release ..", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars); + Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + foreach (var file in binariesToCopyUnix) + Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); + break; + } + case TargetPlatform.PS4: + { + BuildMsbuild(options, TargetPlatform.PS4, TargetArchitecture.x64); + break; + } + case TargetPlatform.PS5: + { + BuildMsbuild(options, TargetPlatform.PS5, TargetArchitecture.x64); + break; + } + case TargetPlatform.XboxScarlett: + { + BuildMsbuild(options, TargetPlatform.XboxScarlett, TargetArchitecture.x64); + break; + } + case TargetPlatform.Android: + { + var oggRoot = Path.Combine(root, "ogg"); + var oggBuildDir = Path.Combine(oggRoot, "build"); + var buildDir = Path.Combine(root, "build"); + + // Get the source + CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); + CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git"); + GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5"); + + // Build for Android + 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); + 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); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); + foreach (var file in binariesToCopyUnix) + Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); + break; + } + case TargetPlatform.Switch: + { + var oggRoot = Path.Combine(root, "ogg"); + var oggBuildDir = Path.Combine(oggRoot, "build"); + var buildDir = Path.Combine(root, "build"); // Get the source SetupDirectory(oggRoot, false); @@ -457,14 +488,12 @@ namespace Flax.Deps.Dependencies var oggBuildDir = Path.Combine(oggRoot, "build"); var buildDir = Path.Combine(root, "build"); - // Get the source - CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); - CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git"); - GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5"); + // Get the source + CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); + CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git"); + GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5"); - // Build for Mac - foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) - { + // Build for Mac SetupDirectory(oggBuildDir, true); RunCmake(oggBuildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=\"../install\""); Utilities.Run("cmake", "--build . --target install", null, oggBuildDir, Utilities.RunOptions.ConsoleLogOutput); @@ -474,32 +503,32 @@ namespace Flax.Deps.Dependencies var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesToCopyUnix) Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); + break; } - break; - } - case TargetPlatform.iOS: - { - var oggRoot = Path.Combine(root, "ogg"); - var oggBuildDir = Path.Combine(oggRoot, "build"); - var buildDir = Path.Combine(root, "build"); + case TargetPlatform.iOS: + { + var oggRoot = Path.Combine(root, "ogg"); + var oggBuildDir = Path.Combine(oggRoot, "build"); + var buildDir = Path.Combine(root, "build"); - // Get the source - CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); - CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git"); - GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5"); + // Get the source + CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); + CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git"); + GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5"); - // Build for Mac - 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); - 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); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); - foreach (var file in binariesToCopyUnix) - Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); - break; - } + // Build for Mac + 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); + 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); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); + foreach (var file in binariesToCopyUnix) + Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); + break; + } + } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependency.cs b/Source/Tools/Flax.Build/Deps/Dependency.cs index 010a45175..381783e29 100644 --- a/Source/Tools/Flax.Build/Deps/Dependency.cs +++ b/Source/Tools/Flax.Build/Deps/Dependency.cs @@ -40,6 +40,11 @@ namespace Flax.Deps /// The target platforms to build dependency for (contains only platforms supported by the dependency itself). /// public TargetPlatform[] Platforms; + + /// + /// The target architectures to build dependency for (contains only platforms supported by the dependency itself). + /// + public TargetArchitecture[] Architectures; } /// @@ -70,6 +75,11 @@ namespace Flax.Deps /// public abstract TargetPlatform[] Platforms { get; } + /// + /// Gets the architectures list supported by this dependency to build on the current build platform (based on ). + /// + public abstract TargetArchitecture[] Architectures { get; } + /// /// True if build dependency by default, otherwise only when explicitly specified via command line. /// @@ -85,9 +95,9 @@ namespace Flax.Deps /// Logs build process start. /// /// Target platform. - protected void BuildStarted(TargetPlatform platform) + protected void BuildStarted(TargetPlatform platform, TargetArchitecture architecture) { - Log.Info($"Building {GetType().Name} for {platform}"); + Log.Info($"Building {GetType().Name} for {platform}{(architecture != TargetArchitecture.AnyCPU ? $" ({architecture})" : "")}"); } /// diff --git a/Source/Tools/Flax.Build/Deps/DepsBuilder.cs b/Source/Tools/Flax.Build/Deps/DepsBuilder.cs index c43c39ea3..1b8389080 100644 --- a/Source/Tools/Flax.Build/Deps/DepsBuilder.cs +++ b/Source/Tools/Flax.Build/Deps/DepsBuilder.cs @@ -38,20 +38,21 @@ namespace Flax.Deps var platforms = Globals.AllPlatforms; if (Configuration.BuildPlatforms != null && Configuration.BuildPlatforms.Length != 0) platforms = Configuration.BuildPlatforms; - platforms = platforms.Where(x => buildPlatform.CanBuildPlatform(x)).ToArray(); - Log.Verbose("Building deps for platforms:"); + platforms = platforms.Where(buildPlatform.CanBuildPlatform).ToArray(); + var architectures = Globals.AllArchitectures; + 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)}:"); foreach (var platform in platforms) { - Log.Verbose(" - " + platform); + foreach (var architecture in architectures) + { + Log.Verbose($" - {platform} ({architecture})"); - if (Platform.IsPlatformSupported(platform, TargetArchitecture.x64)) - SetupDepsOutputFolder(options, platform, TargetArchitecture.x64); - if (Platform.IsPlatformSupported(platform, TargetArchitecture.x86)) - SetupDepsOutputFolder(options, platform, TargetArchitecture.x86); - if (Platform.IsPlatformSupported(platform, TargetArchitecture.ARM)) - SetupDepsOutputFolder(options, platform, TargetArchitecture.ARM); - if (Platform.IsPlatformSupported(platform, TargetArchitecture.ARM64)) - SetupDepsOutputFolder(options, platform, TargetArchitecture.ARM64); + if (Platform.IsPlatformSupported(platform, architecture)) + SetupDepsOutputFolder(options, platform, architecture); + } } // Get all deps @@ -80,6 +81,14 @@ namespace Flax.Deps continue; } + 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('\\', '/'); From 84c79d5192ac14abfdee0f48d36b7899e07f7bb6 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 02:33:44 +0300 Subject: [PATCH 04/17] Fix building Assimp on Linux Versioned clang++ symlinks are not available on Arch --- Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs b/Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs index e31a3a059..629a69070 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs @@ -155,11 +155,12 @@ namespace Flax.Deps.Dependencies { { "CC", "clang-" + Configuration.LinuxClangMinVer }, { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, - { "CXX", "clang++-" + Configuration.LinuxClangMinVer }, + { "CXX", "clang-" + Configuration.LinuxClangMinVer }, { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, }; // Build for Linux + File.Delete(Path.Combine(root, "CMakeCache.txt")); RunCmake(root, platform, architecture, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig, envVars); Utilities.Run("make", null, null, root, Utilities.RunOptions.DefaultTool, envVars); configHeaderFilePath = Path.Combine(root, "include", "assimp", "config.h"); @@ -170,6 +171,7 @@ namespace Flax.Deps.Dependencies case TargetPlatform.Mac: { // Build for Mac + File.Delete(Path.Combine(root, "CMakeCache.txt")); RunCmake(root, platform, architecture, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig); Utilities.Run("make", null, null, root, Utilities.RunOptions.DefaultTool); configHeaderFilePath = Path.Combine(root, "include", "assimp", "config.h"); From b8b9ba3069bb8d6c441007f9a2f0477413806d16 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 02:33:54 +0300 Subject: [PATCH 05/17] Fix building curl on Linux --- Source/Tools/Flax.Build/Deps/Dependencies/curl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs b/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs index a559f1c7f..ceca92798 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs @@ -123,7 +123,7 @@ namespace Flax.Deps.Dependencies var settings = new[] { "--without-librtmp", - "--without-ssl", + //"--without-ssl", "--with-gnutls", "--disable-ipv6", "--disable-manual", From d5bd857c45539838add2f5bebeff75e5cdeef51e Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 02:34:04 +0300 Subject: [PATCH 06/17] Support building OpenAL from Git repository in other platforms --- .../Flax.Build/Deps/Dependencies/OpenAL.cs | 102 ++++++++---------- 1 file changed, 45 insertions(+), 57 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs b/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs index c87931179..5e194edd4 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs @@ -1,5 +1,5 @@ // Copyright (c) Wojciech Figat. All rights reserved. - +//#define USE_GIT_REPOSITORY using System; using System.Collections.Generic; using System.IO; @@ -85,12 +85,15 @@ namespace Flax.Deps.Dependencies var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "OpenAL"); var noSSL = true; // OpenAL Soft website has broken certs +#if !USE_GIT_REPOSITORY if (options.Platforms.Contains(TargetPlatform.Windows)) +#endif { // Get the source CloneGitRepo(root, "https://github.com/kcat/openal-soft.git"); - GitCheckout(root, "master", "d3875f333fb6abe2f39d82caca329414871ae53b"); // 1.23.1 + GitCheckout(root, "master", "dc7d7054a5b4f3bec1dc23a42fd616a0847af948"); // 1.24.3 } +#if !USE_GIT_REPOSITORY else { // Get the source @@ -98,25 +101,20 @@ namespace Flax.Deps.Dependencies if (!File.Exists(packagePath)) { Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath, noSSL); - using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read)) + if (Platform.BuildTargetPlatform == TargetPlatform.Windows) { - if (!Directory.Exists(root)) - archive.ExtractToDirectory(root); - root = Path.Combine(root, archive.Entries.First().FullName); + // TODO: Maybe use PowerShell Expand-Archive instead? + var sevenZip = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "7-Zip", "7z.exe"); + Utilities.Run(sevenZip, "x package.zip", null, root); + Utilities.Run(sevenZip, "x package", null, root); + } + else + { + Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput); } } - /*if (Platform.BuildTargetPlatform == TargetPlatform.Windows) - { - // TODO: Maybe use PowerShell Expand-Archive instead? - var sevenZip = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "7-Zip", "7z.exe"); - Utilities.Run(sevenZip, "x package.zip", null, root); - Utilities.Run(sevenZip, "x package", null, root); - } - else - { - Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.ConsoleLogOutput); - }*/ } +#endif foreach (var platform in options.Platforms) { @@ -136,40 +134,12 @@ namespace Flax.Deps.Dependencies // Build for Windows var buildDir = Path.Combine(root, "build-" + architecture.ToString()); var solutionPath = Path.Combine(buildDir, "OpenAL.sln"); - + SetupDirectory(buildDir, true); RunCmake(root, platform, architecture, $"-B\"{buildDir}\" -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=\"/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR /EHsc\" -DCMAKE_CXX_FLAGS=\"/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR /EHsc\" " + cmakeArgs); Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, architecture.ToString()); var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesToCopy) Utilities.FileCopy(Path.Combine(buildDir, configuration, file), Path.Combine(depsFolder, Path.GetFileName(file))); - -#if false - // Get the binaries - var packagePath = Path.Combine(root, "package.zip"); - if (!File.Exists(packagePath)) - Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-binaries/openal-soft-" + version + "-bin.zip", packagePath, noSSL); - using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read)) - { - if (!Directory.Exists(root)) - archive.ExtractToDirectory(root); - root = Path.Combine(root, archive.Entries.First().FullName); - } - - // Deploy Win64 binaries - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); - Utilities.FileCopy(Path.Combine(root, "bin", "Win64", "soft_oal.dll"), Path.Combine(depsFolder, "OpenAL32.dll")); - Utilities.FileCopy(Path.Combine(root, "libs", "Win64", "OpenAL32.lib"), Path.Combine(depsFolder, "OpenAL32.lib")); - - // Deploy license - Utilities.FileCopy(Path.Combine(root, "COPYING"), Path.Combine(dstIncludePath, "COPYING"), true); - - // Deploy header files - var files = Directory.GetFiles(Path.Combine(root, "include", "AL")); - foreach (var file in files) - { - Utilities.FileCopy(file, Path.Combine(dstIncludePath, Path.GetFileName(file))); - } -#endif break; } case TargetPlatform.Linux: @@ -195,14 +165,16 @@ namespace Flax.Deps.Dependencies + cmakeArgs; // Use separate build directory +#if !USE_GIT_REPOSITORY root = Path.Combine(root, "openal-soft-" + version); - var buildDir = Path.Combine(root, "build"); +#endif + var buildDir = Path.Combine(root, "build-" + architecture.ToString()); SetupDirectory(buildDir, true); // Build for Linux - Utilities.Run("cmake", $"-G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE={configuration} -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLIBTYPE=STATIC {config} ..", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars); + RunCmake(root, platform, architecture, $"-B\"{buildDir}\" -DLIBTYPE=STATIC -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); BuildCmake(buildDir, configuration, envVars); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesToCopy) Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); break; @@ -220,12 +192,14 @@ namespace Flax.Deps.Dependencies var config = "-DALSOFT_REQUIRE_OBOE=OFF -DALSOFT_REQUIRE_OPENSL=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; // Use separate build directory +#if !USE_GIT_REPOSITORY root = Path.Combine(root, "openal-soft-" + version); - var buildDir = Path.Combine(root, "build"); +#endif + var buildDir = Path.Combine(root, "build-" + architecture.ToString()); SetupDirectory(buildDir, true); // Build - RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); + RunCmake(root, platform, TargetArchitecture.ARM64, $"-B\"{buildDir}\" -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); BuildCmake(buildDir, envVars); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); foreach (var file in binariesToCopy) @@ -245,12 +219,14 @@ namespace Flax.Deps.Dependencies var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; // Use separate build directory +#if !USE_GIT_REPOSITORY root = Path.Combine(root, "openal-soft-" + version); - var buildDir = Path.Combine(root, "build"); +#endif + var buildDir = Path.Combine(root, "build-" + architecture.ToString()); + SetupDirectory(buildDir, true); // Build for Mac - SetupDirectory(buildDir, true); - RunCmake(buildDir, platform, architecture, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); + RunCmake(root, platform, architecture, $"-B\"{buildDir}\" -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); BuildCmake(buildDir, envVars); var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesToCopy) @@ -270,12 +246,14 @@ namespace Flax.Deps.Dependencies var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs; // Use separate build directory +#if !USE_GIT_REPOSITORY root = Path.Combine(root, "openal-soft-" + version); - var buildDir = Path.Combine(root, "build"); +#endif + var buildDir = Path.Combine(root, "build-" + architecture.ToString()); + SetupDirectory(buildDir, true); // Build for iOS - SetupDirectory(buildDir, true); - RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); + RunCmake(root, platform, TargetArchitecture.ARM64, $"-B\"{buildDir}\" -DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars); BuildCmake(buildDir, envVars); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); foreach (var file in binariesToCopy) @@ -285,6 +263,16 @@ namespace Flax.Deps.Dependencies } } } + + // Deploy license + Utilities.FileCopy(Path.Combine(root, "COPYING"), Path.Combine(dstIncludePath, "COPYING"), true); + + // Deploy header files + var files = Directory.GetFiles(Path.Combine(root, "include", "AL")); + foreach (var file in files) + { + Utilities.FileCopy(file, Path.Combine(dstIncludePath, Path.GetFileName(file))); + } } } } From 430e685a7ccafaba6d753371f0d218f5ad404923 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 02:34:14 +0300 Subject: [PATCH 07/17] Fix building PhysX on Linux and macOS --- Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs index c5016c3e9..9122f6565 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs @@ -95,8 +95,13 @@ namespace Flax.Deps.Dependencies if (cmakeSwitch.HasAttribute("name") && cmakeSwitch.Attributes["name"].Value == name) { cmakeSwitch.Attributes["value"].Value = value; + return; } } + var child = cmakeSwitches.OwnerDocument.CreateElement(cmakeSwitches.ChildNodes[0].Name); + child.SetAttribute("name", name); + child.SetAttribute("value", value); + cmakeSwitches.AppendChild(child); } private void Build(BuildOptions options, string preset, TargetPlatform targetPlatform, TargetArchitecture architecture) @@ -129,6 +134,10 @@ namespace Flax.Deps.Dependencies ConfigureCmakeSwitch(cmakeParams, "PX_COPY_EXTERNAL_DLL", "OFF"); } break; + case TargetPlatform.Linux: + ConfigureCmakeSwitch(cmakeParams, "CMAKE_C_FLAGS", ""-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs""); + ConfigureCmakeSwitch(cmakeParams, "CMAKE_CXX_FLAGS", ""-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs""); + break; case TargetPlatform.Android: ConfigureCmakeSwitch(cmakeParams, "CMAKE_INSTALL_PREFIX", $"install/android-{Configuration.AndroidPlatformApi}/PhysX"); ConfigureCmakeSwitch(cmakeParams, "ANDROID_NATIVE_API_LEVEL", $"android-{Configuration.AndroidPlatformApi}"); @@ -136,6 +145,8 @@ namespace Flax.Deps.Dependencies break; case TargetPlatform.Mac: ConfigureCmakeSwitch(cmakeParams, "CMAKE_OSX_DEPLOYMENT_TARGET", Configuration.MacOSXMinVer); + ConfigureCmakeSwitch(cmakeParams, "CMAKE_C_FLAGS", ""-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs""); + ConfigureCmakeSwitch(cmakeParams, "CMAKE_CXX_FLAGS", ""-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs""); break; case TargetPlatform.iOS: ConfigureCmakeSwitch(cmakeParams, "CMAKE_OSX_DEPLOYMENT_TARGET", Configuration.iOSMinVer); @@ -156,6 +167,7 @@ namespace Flax.Deps.Dependencies bool suppressBitsPostfix = false; string binariesPrefix = string.Empty; var envVars = new Dictionary(); + envVars.Add("CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel); switch (architecture) { case TargetArchitecture.x86: From ebd929176cdd01c9c6edb0739ecfc6860e9fd7af Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 02:34:22 +0300 Subject: [PATCH 08/17] Fix python tool call on macOS for glslang --- Source/Tools/Flax.Build/Deps/Dependencies/glslang.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/glslang.cs b/Source/Tools/Flax.Build/Deps/Dependencies/glslang.cs index e5f5e4dfe..32c14a037 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/glslang.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/glslang.cs @@ -1,5 +1,6 @@ // Copyright (c) Wojciech Figat. All rights reserved. +using System; using System.IO; using Flax.Build; @@ -82,7 +83,8 @@ namespace Flax.Deps.Dependencies // Setup the external sources // Requires distutils (pip install setuptools) - Utilities.Run("python", "update_glslang_sources.py", null, root, Utilities.RunOptions.ConsoleLogOutput); + if (Utilities.Run(BuildPlatform != TargetPlatform.Mac ? "python" : "python3", "update_glslang_sources.py", null, root, Utilities.RunOptions.ConsoleLogOutput) != 0) + throw new Exception("Failed to update glslang sources, make sure setuptools python package is installed."); foreach (var platform in options.Platforms) { From 4b552563beab961b978226f9ad0dc949a97b9d83 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 02:34:33 +0300 Subject: [PATCH 09/17] Fix PhysX compilation on Linux and macOS --- Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs index 9122f6565..f65767fd2 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs @@ -135,8 +135,7 @@ namespace Flax.Deps.Dependencies } break; case TargetPlatform.Linux: - ConfigureCmakeSwitch(cmakeParams, "CMAKE_C_FLAGS", ""-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs""); - ConfigureCmakeSwitch(cmakeParams, "CMAKE_CXX_FLAGS", ""-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs""); + ConfigureCmakeSwitch(cmakeParams, "PHYSX_CXX_FLAGS", "\"-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs\""); break; case TargetPlatform.Android: ConfigureCmakeSwitch(cmakeParams, "CMAKE_INSTALL_PREFIX", $"install/android-{Configuration.AndroidPlatformApi}/PhysX"); @@ -145,8 +144,7 @@ namespace Flax.Deps.Dependencies break; case TargetPlatform.Mac: ConfigureCmakeSwitch(cmakeParams, "CMAKE_OSX_DEPLOYMENT_TARGET", Configuration.MacOSXMinVer); - ConfigureCmakeSwitch(cmakeParams, "CMAKE_C_FLAGS", ""-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs""); - ConfigureCmakeSwitch(cmakeParams, "CMAKE_CXX_FLAGS", ""-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs""); + ConfigureCmakeSwitch(cmakeParams, "PHYSX_CXX_FLAGS", "\"-Wno-error=format -Wno-error=unused-but-set-variable -Wno-error=switch-default -Wno-error=invalid-offsetof -Wno-error=unsafe-buffer-usage -Wno-error=unsafe-buffer-usage-in-libc-call -Wno-error=missing-include-dirs\""); break; case TargetPlatform.iOS: ConfigureCmakeSwitch(cmakeParams, "CMAKE_OSX_DEPLOYMENT_TARGET", Configuration.iOSMinVer); @@ -498,7 +496,7 @@ namespace Flax.Deps.Dependencies var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "PhysX"); Directory.GetFiles(dstIncludePath, "*.h", SearchOption.AllDirectories).ToList().ForEach(File.Delete); Utilities.FileCopy(Path.Combine(root, "LICENSE.md"), Path.Combine(dstIncludePath, "License.txt")); - Utilities.DirectoryCopy(Path.Combine(root, "physx", "include"), dstIncludePath); + Utilities.DirectoryCopy(Path.Combine(root, "physx", "include"), dstIncludePath, true, true); } } } From 1d2b3bc858615bcb16acb2b8a2d492f8857d68bb Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 02:34:41 +0300 Subject: [PATCH 10/17] Fix NvCloth compilation on Linux and macOS --- .../Tools/Flax.Build/Deps/Dependencies/NvCloth.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs index 25557cb70..aa15aadac 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs @@ -1,5 +1,6 @@ // Copyright (c) Wojciech Figat. All rights reserved. +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -89,6 +90,15 @@ namespace Flax.Deps.Dependencies // Get the source CloneGitRepoSingleBranch(root, "https://github.com/FlaxEngine/NvCloth.git", "master"); + // Patch the CMakeLists.txt to support custom compilation flags + foreach (var os in new[] { "android", "ios", "linux", "mac", "windows", }) + { + var filePath = Path.Combine(nvCloth, "compiler", "cmake", os, "CMakeLists.txt"); + var appendLine = "SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${NVCLOTH_CXX_FLAGS}\")"; + if (!File.ReadAllText(filePath).Contains(appendLine)) + File.AppendAllText(filePath, Environment.NewLine + appendLine + Environment.NewLine); + } + foreach (var platform in options.Platforms) { foreach (var architecture in options.Architectures) @@ -185,7 +195,7 @@ namespace Flax.Deps.Dependencies } break; case TargetPlatform.Mac: - cmakeArgs += " -DTARGET_BUILD_PLATFORM=mac"; + cmakeArgs += " -DTARGET_BUILD_PLATFORM=mac -DNVCLOTH_CXX_FLAGS=\"-Wno-error=poison-system-directories -Wno-error=missing-include-dirs\""; cmakeName = "mac"; binariesPrefix = "lib"; break; @@ -195,7 +205,7 @@ namespace Flax.Deps.Dependencies binariesPrefix = "lib"; break; case TargetPlatform.Linux: - cmakeArgs += " -DTARGET_BUILD_PLATFORM=linux"; + cmakeArgs += " -DTARGET_BUILD_PLATFORM=linux -DNVCLOTH_CXX_FLAGS=\"-Wno-error=poison-system-directories -Wno-error=missing-include-dirs\""; cmakeName = "linux"; binariesPrefix = "lib"; envVars.Add("CC", "clang-" + Configuration.LinuxClangMinVer); From af54d04f9d567e39ee55bdf289a9ea5fb124da6d Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 02:34:50 +0300 Subject: [PATCH 11/17] Fix building ogg+vorbis on macOS --- .../Flax.Build/Deps/Dependencies/vorbis.cs | 240 ++++++++---------- 1 file changed, 111 insertions(+), 129 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs index 402adbe4f..5fc08cf60 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs @@ -83,18 +83,20 @@ namespace Flax.Deps.Dependencies { public string Filename; public string SrcFolder; + public string DstFilename; - public Binary(string filename, string srcFolder) + public Binary(string filename, string srcFolder, string dstFilename = null) { Filename = filename; SrcFolder = srcFolder; + DstFilename = dstFilename; } } private bool hasSourcesReady; private string root; private string rootMsvcLib; - private string configurationMsvc; + private string _configuration = "Release"; private List vcxprojContentsWindows; private string[] vcxprojPathsWindows; @@ -104,22 +106,6 @@ namespace Flax.Deps.Dependencies new Binary("libvorbisfile_static.lib", "libvorbisfile"), }; - private (string, string)[] vorbisBinariesToCopyWindowsCmake = - { - ("vorbis.lib", "libvorbis_static.lib"), - ("vorbisfile.lib", "libvorbisfile_static.lib"), - }; - - private Binary[] oggBinariesToCopyWindows = - { - new Binary("libogg_static.lib", "ogg"), - }; - - private (string, string)[] oggBinariesToCopyWindowsCmake = - { - ("ogg.lib", "libogg_static.lib"), - }; - private void PatchWindowsTargetPlatformVersion(string windowsTargetPlatformVersion, string platformToolset) { // Fix the MSVC project settings for Windows @@ -137,7 +123,6 @@ namespace Flax.Deps.Dependencies return; hasSourcesReady = true; - configurationMsvc = "Release"; string oggRoot = Path.Combine(root, "libogg"); string vorbisRoot = Path.Combine(root, "libvorbis"); @@ -227,7 +212,7 @@ namespace Flax.Deps.Dependencies break; default: throw new InvalidArchitectureException(architecture); } - binariesToCopy.AddRange(vorbisBinariesToCopyWindows.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc)))); + binariesToCopy.AddRange(vorbisBinariesToCopyWindows.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, _configuration)))); break; } case TargetPlatform.PS4: @@ -246,7 +231,7 @@ namespace Flax.Deps.Dependencies buildDir, true, true); Utilities.FileCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg", "ogg", "config_types.h"), Path.Combine(root, "libogg", "include", "ogg", "config_types.h")); - binariesToCopy.AddRange(binariesToCopyVorbis.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc)))); + binariesToCopy.AddRange(binariesToCopyVorbis.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, _configuration)))); break; } case TargetPlatform.PS5: @@ -267,7 +252,7 @@ namespace Flax.Deps.Dependencies Utilities.FileCopy( Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg", "ogg", "config_types.h"), Path.Combine(root, "libogg", "include", "ogg", "config_types.h")); - binariesToCopy.AddRange(binariesToCopyVorbis.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc)))); + binariesToCopy.AddRange(binariesToCopyVorbis.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, _configuration)))); break; } case TargetPlatform.XboxOne: @@ -275,21 +260,21 @@ namespace Flax.Deps.Dependencies vcxprojPaths = vcxprojPathsWindows; buildPlatform = "x64"; PatchWindowsTargetPlatformVersion("10.0", "v143"); - binariesToCopy.AddRange(vorbisBinariesToCopyWindows.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc)))); + binariesToCopy.AddRange(vorbisBinariesToCopyWindows.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, _configuration)))); break; case TargetPlatform.XboxScarlett: buildDir = Path.Combine(rootMsvcLib, "win32", "VS2010"); vcxprojPaths = vcxprojPathsWindows; buildPlatform = "x64"; PatchWindowsTargetPlatformVersion("10.0", "v143"); - binariesToCopy.AddRange(vorbisBinariesToCopyWindows.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc)))); + binariesToCopy.AddRange(vorbisBinariesToCopyWindows.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, _configuration)))); break; default: throw new InvalidPlatformException(platform); } // Build foreach (var vcxprojPath in vcxprojPaths) - Deploy.VCEnvironment.BuildSolution(vcxprojPath, configurationMsvc, buildPlatform); + Deploy.VCEnvironment.BuildSolution(vcxprojPath, _configuration, buildPlatform); // Copy binaries var depsFolder = GetThirdPartyFolder(options, platform, architecture); @@ -303,48 +288,107 @@ namespace Flax.Deps.Dependencies string oggRoot = Path.Combine(root, "libogg"); string vorbisRoot = Path.Combine(root, "libvorbis"); - var oggBuildDir = Path.Combine(oggRoot, "build-" + architecture.ToString()); var vorbisBuildDir = Path.Combine(vorbisRoot, "build-" + architecture.ToString()); + var installDir = Path.Combine(root, "install"); string ext; + string oggConfig = $"-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE={_configuration} -DCMAKE_INSTALL_PREFIX=\"{installDir}\""; + string vorbisConfig = $"-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE={_configuration} -DCMAKE_INSTALL_PREFIX=\"{installDir}\""; + Dictionary envVars = new Dictionary(); + (string, string)[] oggBinariesToCopy; + Binary[] vorbisBinariesToCopy; switch (platform) { case TargetPlatform.Windows: case TargetPlatform.UWP: case TargetPlatform.XboxOne: + oggConfig += " -DBUILD_SHARED_LIBS=OFF"; + vorbisConfig += " -DBUILD_SHARED_LIBS=OFF"; ext = ".lib"; break; case TargetPlatform.Linux: + oggConfig += " -DCMAKE_POSITION_INDEPENDENT_CODE=ON"; + vorbisConfig += " -DCMAKE_POSITION_INDEPENDENT_CODE=ON"; + envVars = new Dictionary + { + { "CC", "clang-" + Configuration.LinuxClangMinVer }, + { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, + { "CXX", "clang++-" + Configuration.LinuxClangMinVer }, + { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, + }; + ext = ".a"; + break; + case TargetPlatform.Mac: + //oggConfig += $" -DOGG_INCLUDE_DIR=\"{oggRoot}/install/include\" -DOGG_LIBRARY=\"{oggRoot}/install/lib\""; ext = ".a"; break; default: throw new InvalidPlatformException(platform); } - var binariesToCopy = new List<(string, string)>(); - - // Build ogg + switch (platform) { - var solutionPath = Path.Combine(oggBuildDir, "ogg.sln"); - - RunCmake(oggRoot, platform, architecture, $"-B\"{oggBuildDir}\" -DBUILD_SHARED_LIBS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5"); - Deploy.VCEnvironment.BuildSolution(solutionPath, configurationMsvc, architecture.ToString()); - foreach (var file in oggBinariesToCopyWindowsCmake) - binariesToCopy.Add((Path.Combine(oggBuildDir, configurationMsvc, file.Item1), file.Item2)); + case TargetPlatform.Windows: + case TargetPlatform.UWP: + case TargetPlatform.XboxOne: + oggBinariesToCopy = + [ + ("ogg.lib", "libogg_static.lib") + ]; + vorbisBinariesToCopy = + [ + new Binary("vorbis.lib", "libvorbis", "libvorbis_static.lib"), + new Binary("vorbisfile.lib", "libvorbisfile", "libvorbisfile_static.lib") + ]; + break; + case TargetPlatform.Linux: + case TargetPlatform.Mac: + oggBinariesToCopy = + [ + ("libogg.a", "libogg.a") + ]; + vorbisBinariesToCopy = + [ + new Binary("libvorbis.a", "lib"), + new Binary("libvorbisenc.a", "lib"), + new Binary("libvorbisfile.a", "lib") + ]; + break; + default: throw new InvalidPlatformException(platform); } + vorbisConfig += $" -DOGG_INCLUDE_DIR=\"{Path.Combine(installDir, "include")}\" -DOGG_LIBRARY=\"{Path.Combine(installDir, "lib", "libogg" + ext)}\""; + + var binariesToCopy = new List<(string, string)>(); + + SetupDirectory(installDir, true); + // Build ogg + { + SetupDirectory(oggBuildDir, true); + RunCmake(oggRoot, platform, architecture, $"-B\"{oggBuildDir}\" " + oggConfig, envVars); + if (platform == TargetPlatform.Windows) + Deploy.VCEnvironment.BuildSolution(Path.Combine(oggBuildDir, "ogg.sln"), _configuration, architecture.ToString()); + else if (platform == TargetPlatform.Mac || platform == TargetPlatform.Linux) + BuildCmake(oggBuildDir); + Utilities.Run("cmake", "--build . --target install", null, oggBuildDir, Utilities.RunOptions.DefaultTool); + } // Build vorbis { - var oggLibraryPath = Path.Combine(oggBuildDir, configurationMsvc, "ogg" + ext); - var solutionPath = Path.Combine(vorbisBuildDir, "vorbis.sln"); - - RunCmake(vorbisRoot, platform, architecture, $"-B\"{vorbisBuildDir}\" -DOGG_INCLUDE_DIR=\"{Path.Combine(oggRoot, "include")}\" -DOGG_LIBRARY=\"{oggLibraryPath}\" -DBUILD_SHARED_LIBS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5"); - Deploy.VCEnvironment.BuildSolution(solutionPath, configurationMsvc, architecture.ToString()); - foreach (var file in vorbisBinariesToCopyWindowsCmake) - binariesToCopy.Add((Path.Combine(vorbisBuildDir, "lib", configurationMsvc, file.Item1), file.Item2)); + SetupDirectory(vorbisBuildDir, true); + RunCmake(vorbisRoot, platform, architecture, $"-B\"{vorbisBuildDir}\" " + vorbisConfig); + if (platform == TargetPlatform.Windows) + Deploy.VCEnvironment.BuildSolution(Path.Combine(vorbisBuildDir, "vorbis.sln"), _configuration, architecture.ToString()); + else if (platform == TargetPlatform.Mac || platform == TargetPlatform.Linux) + BuildCmake(vorbisBuildDir); + Utilities.Run("cmake", "--build . --target install", null, vorbisBuildDir, Utilities.RunOptions.DefaultTool); } // Copy binaries + foreach (var file in oggBinariesToCopy) + binariesToCopy.Add((Path.Combine(installDir, "lib", file.Item1), file.Item2)); + foreach (var file in vorbisBinariesToCopy) + binariesToCopy.Add((Path.Combine(installDir, "lib", file.Filename), file.DstFilename ?? file.Filename)); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); foreach (var file in binariesToCopy) Utilities.FileCopy(file.Item1, Path.Combine(depsFolder, file.Item2)); @@ -389,31 +433,7 @@ namespace Flax.Deps.Dependencies } case TargetPlatform.Linux: { - // Note: assumes the libogg-dev package is pre-installed on the system - - // Get the source - CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); - - var envVars = new Dictionary - { - { "CC", "clang-" + Configuration.LinuxClangMinVer }, - { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, - { "CXX", "clang++-" + Configuration.LinuxClangMinVer }, - { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel }, - }; - var buildDir = Path.Combine(root, "build"); - - Utilities.Run(Path.Combine(root, "autogen.sh"), null, null, root, Utilities.RunOptions.DefaultTool, envVars); - - // Build for Linux - var toolchain = UnixToolchain.GetToolchainName(platform, architecture); - Utilities.Run(Path.Combine(root, "configure"), string.Format("--host={0}", toolchain), null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars); - SetupDirectory(buildDir, true); - Utilities.Run("cmake", "-G \"Unix Makefiles\" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release ..", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars); - Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars); - var depsFolder = GetThirdPartyFolder(options, platform, architecture); - foreach (var file in binariesToCopyUnix) - Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); + BuildCmake(options, TargetPlatform.Linux, architecture); break; } case TargetPlatform.PS4: @@ -460,51 +480,33 @@ namespace Flax.Deps.Dependencies var oggBuildDir = Path.Combine(oggRoot, "build"); 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), "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), "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); - var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); - foreach (var file in binariesToCopyUnix) - Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); - break; - } - case TargetPlatform.Mac: - { - var oggRoot = Path.Combine(root, "ogg"); - var oggBuildDir = Path.Combine(oggRoot, "build"); - var buildDir = Path.Combine(root, "build"); - // Get the source - CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git"); + 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), "Data/ogg"), oggRoot, true, true); + Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data/vorbis"), buildDir, true, true); - // Build for Mac + // Build for Switch SetupDirectory(oggBuildDir, true); - RunCmake(oggBuildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=\"../install\""); + 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), "Data/ogg", "include", "ogg", "config_types.h"), Path.Combine(oggRoot, "install", "include", "ogg", "config_types.h")); SetupDirectory(buildDir, true); - RunCmake(buildDir, platform, architecture, string.Format(".. -DCMAKE_BUILD_TYPE=Release -DOGG_INCLUDE_DIR=\"{0}/install/include\" -DOGG_LIBRARY=\"{0}/install/lib\"", oggRoot)); + 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); - var depsFolder = GetThirdPartyFolder(options, platform, architecture); + var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); foreach (var file in binariesToCopyUnix) Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename)); break; } + case TargetPlatform.Mac: + { + BuildCmake(options, TargetPlatform.Mac, architecture); + break; + } case TargetPlatform.iOS: { var oggRoot = Path.Combine(root, "ogg"); @@ -532,37 +534,17 @@ namespace Flax.Deps.Dependencies } } - // Backup files - if (hasSourcesReady) - root = rootMsvcLib; - var srcIncludePath = Path.Combine(root, "include", "vorbis"); - var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "vorbis"); - foreach (var filename in filesToKeep) - { - var src = Path.Combine(dstIncludePath, filename); - var dst = Path.Combine(options.IntermediateFolder, filename + ".tmp"); - Utilities.FileCopy(src, dst); - } + // Setup headers directory + var installDir = Path.Combine(root, "install"); + var oggOut = Path.Combine(options.ThirdPartyFolder, "ogg"); + var vorbisOut = Path.Combine(options.ThirdPartyFolder, "vorbis"); - try - { - // Setup headers directory - SetupDirectory(dstIncludePath, true); + // Deploy header files + Utilities.DirectoryCopy(Path.Combine(installDir, "include", "ogg"), oggOut, true, true); + Utilities.DirectoryCopy(Path.Combine(installDir, "include", "vorbis"), vorbisOut, true, true); - // Deploy header files and restore files - Directory.GetFiles(srcIncludePath, "Makefile*").ToList().ForEach(File.Delete); - Utilities.DirectoryCopy(srcIncludePath, dstIncludePath, true, true); - Utilities.FileCopy(Path.Combine(root, "COPYING"), Path.Combine(dstIncludePath, "COPYING")); - } - finally - { - foreach (var filename in filesToKeep) - { - var src = Path.Combine(options.IntermediateFolder, filename + ".tmp"); - var dst = Path.Combine(dstIncludePath, filename); - Utilities.FileCopy(src, dst); - } - } + Utilities.FileCopy(Path.Combine(root, "libogg", "COPYING"), Path.Combine(oggOut, "COPYING")); + Utilities.FileCopy(Path.Combine(root, "libvorbis", "COPYING"), Path.Combine(vorbisOut, "COPYING")); } } } From 47cdd0582c51ecee2680dca19bdd11333e512a9d Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 03:24:51 +0300 Subject: [PATCH 12/17] Check VS2026 toolset before trying to compile PhysX --- .../Tools/Flax.Build/Deps/Dependencies/PhysX.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs index f65767fd2..46ad23381 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs @@ -425,15 +425,20 @@ namespace Flax.Deps.Dependencies { if (architecture == TargetArchitecture.x64 || architecture == TargetArchitecture.ARM64) { - try + if (WindowsPlatform.GetToolsets().Any(x => x.Key == WindowsPlatformToolset.v145)) { - Build(options, architecture == TargetArchitecture.x64 ? "vc18win64" : "vc18win-arm64", platform, architecture); + try + { + Build(options, architecture == TargetArchitecture.x64 ? "vc18win64" : "vc18win-arm64", platform, architecture); + } + catch (Exception e) + { + Log.Warning($"Failed to generate VS2026 solution for PhysX, fallback to VS2022: {e.Message}"); + Build(options, architecture == TargetArchitecture.x64 ? "vc17win64" : "vc17win-arm64", platform, architecture); + } } - catch - { - Log.Verbose("Failed to generate VS2026 solution for PhysX, fallback to VS2022"); + else Build(options, architecture == TargetArchitecture.x64 ? "vc17win64" : "vc17win-arm64", platform, architecture); - } } else throw new InvalidArchitectureException(architecture); From afd59d7eb344b7bdae0e5ae18063ab38806fc983 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 03:31:07 +0300 Subject: [PATCH 13/17] Fix building vorbis on Windows --- Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs index 5fc08cf60..6f6dde474 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs @@ -295,6 +295,7 @@ namespace Flax.Deps.Dependencies string ext; string oggConfig = $"-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE={_configuration} -DCMAKE_INSTALL_PREFIX=\"{installDir}\""; string vorbisConfig = $"-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE={_configuration} -DCMAKE_INSTALL_PREFIX=\"{installDir}\""; + string liboggFilename = "libogg"; Dictionary envVars = new Dictionary(); (string, string)[] oggBinariesToCopy; Binary[] vorbisBinariesToCopy; @@ -306,6 +307,7 @@ namespace Flax.Deps.Dependencies oggConfig += " -DBUILD_SHARED_LIBS=OFF"; vorbisConfig += " -DBUILD_SHARED_LIBS=OFF"; ext = ".lib"; + liboggFilename = "ogg"; break; case TargetPlatform.Linux: oggConfig += " -DCMAKE_POSITION_INDEPENDENT_CODE=ON"; @@ -357,7 +359,7 @@ namespace Flax.Deps.Dependencies default: throw new InvalidPlatformException(platform); } - vorbisConfig += $" -DOGG_INCLUDE_DIR=\"{Path.Combine(installDir, "include")}\" -DOGG_LIBRARY=\"{Path.Combine(installDir, "lib", "libogg" + ext)}\""; + vorbisConfig += $" -DOGG_INCLUDE_DIR=\"{Path.Combine(installDir, "include")}\" -DOGG_LIBRARY=\"{Path.Combine(installDir, "lib", liboggFilename + ext)}\""; var binariesToCopy = new List<(string, string)>(); From b08c765400faa29a8d7399e007b0706484091cca Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 18 Oct 2025 04:18:01 +0300 Subject: [PATCH 14/17] Add dependency build script for WinPixEventRuntime --- .../Deps/Dependencies/WinPixEventRuntime.cs | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Source/Tools/Flax.Build/Deps/Dependencies/WinPixEventRuntime.cs diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/WinPixEventRuntime.cs b/Source/Tools/Flax.Build/Deps/Dependencies/WinPixEventRuntime.cs new file mode 100644 index 000000000..84a6f4f8b --- /dev/null +++ b/Source/Tools/Flax.Build/Deps/Dependencies/WinPixEventRuntime.cs @@ -0,0 +1,91 @@ +// Copyright (c) Wojciech Figat. All rights reserved. + +using System; +using System.IO; +using System.IO.Compression; +using System.Linq; +using Flax.Build; +using Flax.Build.Platforms; + +namespace Flax.Deps.Dependencies +{ + /// + /// WinPixEventRuntime. https://github.com/microsoft/PixEvents + /// + /// + class WinPixEventRuntime : Dependency + { + /// + public override TargetPlatform[] Platforms + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetPlatform.Windows, + }; + default: return new TargetPlatform[0]; + } + } + } + + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + + /// + public override void Build(BuildOptions options) + { + // Get the source + var root = options.IntermediateFolder; + var packagePath = Path.Combine(root, $"package.zip"); + if (!File.Exists(packagePath)) + { + Downloader.DownloadFileFromUrlToPath("https://www.nuget.org/api/v2/package/WinPixEventRuntime/1.0.240308001", packagePath); + } + var extractedPath = Path.Combine(root, "extracted"); + if (!Directory.Exists(extractedPath)) + { + using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read)) + archive.ExtractToDirectory(extractedPath); + } + root = extractedPath; + + foreach (var platform in options.Platforms) + { + foreach (var architecture in options.Architectures) + { + BuildStarted(platform, architecture); + switch (platform) + { + case TargetPlatform.Windows: + { + var bin = Path.Combine(root, "bin", architecture.ToString()); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + Utilities.FileCopy(Path.Combine(bin, "WinPixEventRuntime.dll"), Path.Combine(depsFolder, "WinPixEventRuntime.dll")); + Utilities.FileCopy(Path.Combine(bin, "WinPixEventRuntime.lib"), Path.Combine(depsFolder, "WinPixEventRuntime.lib")); + break; + } + } + } + } + } + } +} From 9becddd84f43762bef6b360d63640057344fe7f2 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 19 Oct 2025 13:47:58 +0300 Subject: [PATCH 15/17] Add dependency build script for Visual Studio EnvDTE --- .../Flax.Build/Deps/Dependencies/EnvDTE.cs | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Source/Tools/Flax.Build/Deps/Dependencies/EnvDTE.cs diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/EnvDTE.cs b/Source/Tools/Flax.Build/Deps/Dependencies/EnvDTE.cs new file mode 100644 index 000000000..32d783e81 --- /dev/null +++ b/Source/Tools/Flax.Build/Deps/Dependencies/EnvDTE.cs @@ -0,0 +1,95 @@ +// Copyright (c) Wojciech Figat. All rights reserved. + +using System; +using System.IO; +using System.IO.Compression; +using System.Linq; +using Flax.Build; +using Flax.Build.Platforms; + +namespace Flax.Deps.Dependencies +{ + /// + /// Visual Studio EnvDTE COM library. https://learn.microsoft.com/en-us/dotnet/api/envdte?view=visualstudiosdk-2022 + /// + /// + class EnvDTE : Dependency + { + /// + public override TargetPlatform[] Platforms + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetPlatform.Windows, + }; + default: return new TargetPlatform[0]; + } + } + } + + /// + public override TargetArchitecture[] Architectures + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } + + /// + public override void Build(BuildOptions options) + { + options.IntermediateFolder.Replace("/" + GetType().Name, "/Microsoft.VisualStudio.Setup.Configuration.Native"); + + // Get the source + var root = options.IntermediateFolder; + var packagePath = Path.Combine(root, $"package.zip"); + if (!File.Exists(packagePath)) + { + Downloader.DownloadFileFromUrlToPath("https://www.nuget.org/api/v2/package/Microsoft.VisualStudio.Setup.Configuration.Native/3.14.2075", packagePath); + } + var extractedPath = Path.Combine(root, "extracted"); + if (!Directory.Exists(extractedPath)) + { + using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read)) + archive.ExtractToDirectory(extractedPath); + } + root = extractedPath; + + foreach (var platform in options.Platforms) + { + foreach (var architecture in options.Architectures) + { + BuildStarted(platform, architecture); + switch (platform) + { + case TargetPlatform.Windows: + { + var bin = Path.Combine(root, "lib", "native", "v141", architecture.ToString().ToLower()); + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + Utilities.FileCopy(Path.Combine(bin, "Microsoft.VisualStudio.Setup.Configuration.Native.lib"), Path.Combine(depsFolder, "Microsoft.VisualStudio.Setup.Configuration.Native.lib")); + + var include = Path.Combine(root, "lib", "native", "include"); + Utilities.FileCopy(Path.Combine(include, "Setup.Configuration.h"), Path.Combine(options.ThirdPartyFolder, "Microsoft.VisualStudio.Setup.Configuration.Native", "Setup.Configuration.h")); + break; + } + } + } + } + } + } +} From ea20dc6da040c6b487c43f84cf0dfe3563857def Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 19 Oct 2025 17:24:10 +0300 Subject: [PATCH 16/17] Fix wrong build configuration used in ogg and vorbis for Windows --- .../Tools/Flax.Build/Deps/Dependencies/vorbis.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs index 6f6dde474..c19fab782 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs @@ -370,9 +370,9 @@ namespace Flax.Deps.Dependencies RunCmake(oggRoot, platform, architecture, $"-B\"{oggBuildDir}\" " + oggConfig, envVars); if (platform == TargetPlatform.Windows) Deploy.VCEnvironment.BuildSolution(Path.Combine(oggBuildDir, "ogg.sln"), _configuration, architecture.ToString()); - else if (platform == TargetPlatform.Mac || platform == TargetPlatform.Linux) + else BuildCmake(oggBuildDir); - Utilities.Run("cmake", "--build . --target install", null, oggBuildDir, Utilities.RunOptions.DefaultTool); + Utilities.Run("cmake", $"--build . --config {_configuration} --target install", null, oggBuildDir, Utilities.RunOptions.DefaultTool); } // Build vorbis { @@ -380,9 +380,9 @@ namespace Flax.Deps.Dependencies RunCmake(vorbisRoot, platform, architecture, $"-B\"{vorbisBuildDir}\" " + vorbisConfig); if (platform == TargetPlatform.Windows) Deploy.VCEnvironment.BuildSolution(Path.Combine(vorbisBuildDir, "vorbis.sln"), _configuration, architecture.ToString()); - else if (platform == TargetPlatform.Mac || platform == TargetPlatform.Linux) + else BuildCmake(vorbisBuildDir); - Utilities.Run("cmake", "--build . --target install", null, vorbisBuildDir, Utilities.RunOptions.DefaultTool); + Utilities.Run("cmake", $"--build . --config {_configuration} --target install", null, vorbisBuildDir, Utilities.RunOptions.DefaultTool); } // Copy binaries @@ -467,7 +467,7 @@ namespace Flax.Deps.Dependencies // Build for Android 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.Run("cmake", "--build . --config Release --target install", null, oggBuildDir, Utilities.RunOptions.ConsoleLogOutput); 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); @@ -494,7 +494,7 @@ namespace Flax.Deps.Dependencies // 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.Run("cmake", "--build . --config Release --target install", null, oggBuildDir, Utilities.RunOptions.ConsoleLogOutput); 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)); @@ -523,7 +523,7 @@ namespace Flax.Deps.Dependencies // Build for Mac 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.Run("cmake", "--build . --config Release --target install", null, oggBuildDir, Utilities.RunOptions.ConsoleLogOutput); 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); From fc2f56aca6310d5edd81ecd6b0907801acd95683 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 12 Jan 2026 00:31:59 +0100 Subject: [PATCH 17/17] Fix missing console platforms #3746 --- .../Tools/Flax.Build/Deps/Dependencies/AGS.cs | 1 - .../Dependencies/DirectXShaderCompiler.cs | 1 - .../Deps/Dependencies/DirectXTex.cs | 6 + .../Flax.Build/Deps/Dependencies/EnvDTE.cs | 11 +- .../Flax.Build/Deps/Dependencies/NvCloth.cs | 64 ----------- .../Flax.Build/Deps/Dependencies/OpenAL.cs | 10 ++ .../Flax.Build/Deps/Dependencies/PhysX.cs | 64 ----------- .../Flax.Build/Deps/Dependencies/UVAtlas.cs | 12 -- .../Flax.Build/Deps/Dependencies/astc.cs | 11 +- .../Flax.Build/Deps/Dependencies/curl.cs | 2 +- .../Flax.Build/Deps/Dependencies/freetype.cs | 64 ----------- .../Flax.Build/Deps/Dependencies/mono.cs | 12 ++ .../Flax.Build/Deps/Dependencies/nethost.cs | 30 ----- .../Flax.Build/Deps/Dependencies/vorbis.cs | 64 ----------- Source/Tools/Flax.Build/Deps/Dependency.cs | 106 ++++++++++++++++-- 15 files changed, 136 insertions(+), 322 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/AGS.cs b/Source/Tools/Flax.Build/Deps/Dependencies/AGS.cs index c756bb28b..ff16bd1c1 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/AGS.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/AGS.cs @@ -29,7 +29,6 @@ namespace Flax.Deps.Dependencies return new[] { TargetArchitecture.x64, - TargetArchitecture.ARM64, }; default: return new TargetArchitecture[0]; } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs index 3c48290ee..f74494a30 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs @@ -1,6 +1,5 @@ // Copyright (c) Wojciech Figat. All rights reserved. -using System; using System.IO; using System.Linq; using Flax.Build; diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs index 3a842b48c..cfbb88870 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs @@ -43,6 +43,12 @@ namespace Flax.Deps.Dependencies TargetArchitecture.x64, TargetArchitecture.ARM64, }; + case TargetPlatform.XboxOne: + case TargetPlatform.XboxScarlett: + return new[] + { + TargetArchitecture.x64, + }; default: return new TargetArchitecture[0]; } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/EnvDTE.cs b/Source/Tools/Flax.Build/Deps/Dependencies/EnvDTE.cs index 32d783e81..3f9a2148b 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/EnvDTE.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/EnvDTE.cs @@ -1,11 +1,8 @@ // Copyright (c) Wojciech Figat. All rights reserved. -using System; using System.IO; using System.IO.Compression; -using System.Linq; using Flax.Build; -using Flax.Build.Platforms; namespace Flax.Deps.Dependencies { @@ -23,8 +20,8 @@ namespace Flax.Deps.Dependencies switch (BuildPlatform) { case TargetPlatform.Windows: - return new[] - { + return new[] + { TargetPlatform.Windows, }; default: return new TargetPlatform[0]; @@ -40,8 +37,8 @@ namespace Flax.Deps.Dependencies switch (BuildPlatform) { case TargetPlatform.Windows: - return new[] - { + return new[] + { TargetArchitecture.x64, TargetArchitecture.ARM64, }; diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs index aa15aadac..f3c3ff210 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/NvCloth.cs @@ -17,70 +17,6 @@ namespace Flax.Deps.Dependencies { private string root, nvCloth; - /// - public override TargetPlatform[] Platforms - { - get - { - switch (BuildPlatform) - { - case TargetPlatform.Windows: - return new[] - { - TargetPlatform.Windows, - TargetPlatform.XboxOne, - TargetPlatform.XboxScarlett, - TargetPlatform.PS4, - TargetPlatform.PS5, - TargetPlatform.Switch, - TargetPlatform.Android, - }; - case TargetPlatform.Linux: - return new[] - { - TargetPlatform.Linux, - }; - case TargetPlatform.Mac: - return new[] - { - TargetPlatform.Mac, - TargetPlatform.iOS, - }; - default: return new TargetPlatform[0]; - } - } - } - - /// - public override TargetArchitecture[] Architectures - { - get - { - switch (BuildPlatform) - { - case TargetPlatform.Windows: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - case TargetPlatform.Linux: - return new[] - { - TargetArchitecture.x64, - //TargetArchitecture.ARM64, - }; - case TargetPlatform.Mac: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - default: return new TargetArchitecture[0]; - } - } - } - /// public override void Build(BuildOptions options) { diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs b/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs index 5e194edd4..37e446ce1 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/OpenAL.cs @@ -70,6 +70,16 @@ namespace Flax.Deps.Dependencies TargetArchitecture.x64, TargetArchitecture.ARM64, }; + case TargetPlatform.iOS: + return new[] + { + TargetArchitecture.ARM64, + }; + case TargetPlatform.Android: + return new[] + { + TargetArchitecture.ARM64, + }; default: return new TargetArchitecture[0]; } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs index 46ad23381..18bb4e69f 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs @@ -17,70 +17,6 @@ namespace Flax.Deps.Dependencies /// class PhysX : Dependency { - /// - public override TargetPlatform[] Platforms - { - get - { - switch (BuildPlatform) - { - case TargetPlatform.Windows: - return new[] - { - TargetPlatform.Windows, - TargetPlatform.XboxOne, - TargetPlatform.PS4, - TargetPlatform.PS5, - TargetPlatform.XboxScarlett, - TargetPlatform.Android, - TargetPlatform.Switch, - }; - case TargetPlatform.Linux: - return new[] - { - TargetPlatform.Linux, - }; - case TargetPlatform.Mac: - return new[] - { - TargetPlatform.Mac, - TargetPlatform.iOS, - }; - default: return new TargetPlatform[0]; - } - } - } - - /// - public override TargetArchitecture[] Architectures - { - get - { - switch (BuildPlatform) - { - case TargetPlatform.Windows: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - case TargetPlatform.Linux: - return new[] - { - TargetArchitecture.x64, - //TargetArchitecture.ARM64, - }; - case TargetPlatform.Mac: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - default: return new TargetArchitecture[0]; - } - } - } - private string root; private string projectGenDir; private string projectGenPath; diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/UVAtlas.cs b/Source/Tools/Flax.Build/Deps/Dependencies/UVAtlas.cs index f0d29dba9..19e314326 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/UVAtlas.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/UVAtlas.cs @@ -42,18 +42,6 @@ namespace Flax.Deps.Dependencies TargetArchitecture.x64, TargetArchitecture.ARM64, }; - case TargetPlatform.Linux: - return new[] - { - TargetArchitecture.x64, - //TargetArchitecture.ARM64, - }; - case TargetPlatform.Mac: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; default: return new TargetArchitecture[0]; } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs b/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs index 40ae9d1e0..62a2b1097 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs @@ -1,6 +1,5 @@ // Copyright (c) Wojciech Figat. All rights reserved. -using System.Collections.Generic; using System.IO; using Flax.Build; @@ -76,7 +75,7 @@ namespace Flax.Deps.Dependencies { case TargetPlatform.Windows: { - string buildDir = Path.Combine(root, "build-" + architecture.ToString()); + string buildDir = Path.Combine(root, "build-" + architecture); var isa = architecture == TargetArchitecture.ARM64 ? "-DASTCENC_ISA_NEON=ON" : "-DASTCENC_ISA_SSE2=ON"; var lib = architecture == TargetArchitecture.ARM64 ? "astcenc-neon-static.lib" : "astcenc-sse2-static.lib"; SetupDirectory(buildDir, true); @@ -84,11 +83,11 @@ namespace Flax.Deps.Dependencies BuildCmake(buildDir); var depsFolder = GetThirdPartyFolder(options, platform, architecture); Utilities.FileCopy(Path.Combine(buildDir, "Source/Release", lib), Path.Combine(depsFolder, "astcenc.lib")); - } - break; + break; + } case TargetPlatform.Mac: { - string buildDir = Path.Combine(root, "build-" + architecture.ToString()); + string buildDir = Path.Combine(root, "build-" + architecture); var isa = architecture == TargetArchitecture.ARM64 ? "-DASTCENC_ISA_NEON=ON" : "-DASTCENC_ISA_SSE2=ON"; var lib = architecture == TargetArchitecture.ARM64 ? "libastcenc-neon-static.a" : "libastcenc-sse2-static.a"; SetupDirectory(buildDir, true); @@ -96,8 +95,8 @@ namespace Flax.Deps.Dependencies BuildCmake(buildDir); var depsFolder = GetThirdPartyFolder(options, platform, architecture); Utilities.FileCopy(Path.Combine(buildDir, "Source", lib), Path.Combine(depsFolder, "libastcenc.a")); + break; } - break; } } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs b/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs index ceca92798..2d25fed3d 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/curl.cs @@ -107,7 +107,7 @@ namespace Flax.Deps.Dependencies case TargetPlatform.Windows: { // Build for Windows - var buildDir = Path.Combine(root, "build-" + architecture.ToString()); + var buildDir = Path.Combine(root, "build-" + architecture); var solutionPath = Path.Combine(buildDir, "CURL.sln"); RunCmake(root, platform, architecture, $"-B\"{buildDir}\" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_STATIC_CRT=OFF"); diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs index ec3ab5e18..d43c73770 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs @@ -15,70 +15,6 @@ namespace Flax.Deps.Dependencies /// class freetype : Dependency { - /// - public override TargetPlatform[] Platforms - { - get - { - switch (BuildPlatform) - { - case TargetPlatform.Windows: - return new[] - { - TargetPlatform.Windows, - TargetPlatform.XboxOne, - TargetPlatform.PS4, - TargetPlatform.PS5, - TargetPlatform.XboxScarlett, - TargetPlatform.Android, - TargetPlatform.Switch, - }; - case TargetPlatform.Linux: - return new[] - { - TargetPlatform.Linux, - }; - case TargetPlatform.Mac: - return new[] - { - TargetPlatform.Mac, - TargetPlatform.iOS, - }; - default: return new TargetPlatform[0]; - } - } - } - - /// - public override TargetArchitecture[] Architectures - { - get - { - switch (BuildPlatform) - { - case TargetPlatform.Windows: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - case TargetPlatform.Linux: - return new[] - { - TargetArchitecture.x64, - //TargetArchitecture.ARM64, - }; - case TargetPlatform.Mac: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - default: return new TargetArchitecture[0]; - } - } - } - /// public override void Build(BuildOptions options) { diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/mono.cs b/Source/Tools/Flax.Build/Deps/Dependencies/mono.cs index ad402d3d4..a90d1c2a0 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/mono.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/mono.cs @@ -78,6 +78,18 @@ namespace Flax.Deps.Dependencies TargetArchitecture.x64, TargetArchitecture.ARM64, }; + case TargetPlatform.XboxOne: + case TargetPlatform.XboxScarlett: + return new[] + { + TargetArchitecture.x64, + }; + case TargetPlatform.Switch: + case TargetPlatform.Android: + return new[] + { + TargetArchitecture.ARM64, + }; default: return new TargetArchitecture[0]; } } diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/nethost.cs b/Source/Tools/Flax.Build/Deps/Dependencies/nethost.cs index 0ac16286f..f67244c9b 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/nethost.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/nethost.cs @@ -43,36 +43,6 @@ namespace Flax.Deps.Dependencies } } - /// - public override TargetArchitecture[] Architectures - { - get - { - switch (BuildPlatform) - { - case TargetPlatform.Windows: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - case TargetPlatform.Linux: - return new[] - { - TargetArchitecture.x64, - //TargetArchitecture.ARM64, - }; - case TargetPlatform.Mac: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - default: return new TargetArchitecture[0]; - } - } - } - /// public override bool BuildByDefault => false; diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs index c19fab782..15ca415da 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs @@ -15,70 +15,6 @@ namespace Flax.Deps.Dependencies /// class vorbis : Dependency { - /// - public override TargetPlatform[] Platforms - { - get - { - switch (BuildPlatform) - { - case TargetPlatform.Windows: - return new[] - { - TargetPlatform.Windows, - TargetPlatform.XboxOne, - TargetPlatform.PS4, - TargetPlatform.PS5, - TargetPlatform.XboxScarlett, - TargetPlatform.Android, - TargetPlatform.Switch, - }; - case TargetPlatform.Linux: - return new[] - { - TargetPlatform.Linux, - }; - case TargetPlatform.Mac: - return new[] - { - TargetPlatform.Mac, - TargetPlatform.iOS, - }; - default: return new TargetPlatform[0]; - } - } - } - - /// - public override TargetArchitecture[] Architectures - { - get - { - switch (BuildPlatform) - { - case TargetPlatform.Windows: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - case TargetPlatform.Linux: - return new[] - { - TargetArchitecture.x64, - //TargetArchitecture.ARM64, - }; - case TargetPlatform.Mac: - return new[] - { - TargetArchitecture.x64, - TargetArchitecture.ARM64, - }; - default: return new TargetArchitecture[0]; - } - } - } - private struct Binary { public string Filename; diff --git a/Source/Tools/Flax.Build/Deps/Dependency.cs b/Source/Tools/Flax.Build/Deps/Dependency.cs index 381783e29..7286bf9f3 100644 --- a/Source/Tools/Flax.Build/Deps/Dependency.cs +++ b/Source/Tools/Flax.Build/Deps/Dependency.cs @@ -52,7 +52,6 @@ namespace Flax.Deps /// protected static TargetPlatform BuildPlatform => Platform.BuildPlatform.Target; - private static Version? _cmakeVersion; protected static Version CMakeVersion { @@ -60,11 +59,19 @@ namespace Flax.Deps { if (_cmakeVersion == null) { - var versionOutput = Utilities.ReadProcessOutput("cmake", "--version"); - var versionStart = versionOutput.IndexOf("cmake version ") + "cmake version ".Length; - var versionEnd = versionOutput.IndexOfAny(['-', '\n', '\r'], versionStart); // End of line or dash before Git hash - var versionString = versionOutput.Substring(versionStart, versionEnd - versionStart); - _cmakeVersion = new Version(versionString); + try + { + var versionOutput = Utilities.ReadProcessOutput("cmake", "--version"); + var versionStart = versionOutput.IndexOf("cmake version ") + "cmake version ".Length; + var versionEnd = versionOutput.IndexOfAny(['-', '\n', '\r'], versionStart); // End of line or dash before Git hash + var versionString = versionOutput.Substring(versionStart, versionEnd - versionStart); + _cmakeVersion = new Version(versionString); + } + catch (Exception) + { + // Assume old version by default (in case of errors) + _cmakeVersion = new Version(3, 0); + } } return _cmakeVersion; } @@ -73,12 +80,95 @@ namespace Flax.Deps /// /// Gets the platforms list supported by this dependency to build on the current build platform (based on ). /// - public abstract TargetPlatform[] Platforms { get; } + public virtual TargetPlatform[] Platforms + { + get + { + // The most common build setup + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetPlatform.Windows, + TargetPlatform.XboxOne, + TargetPlatform.XboxScarlett, + TargetPlatform.PS4, + TargetPlatform.PS5, + TargetPlatform.Android, + TargetPlatform.Switch, + }; + case TargetPlatform.Linux: + return new[] + { + TargetPlatform.Linux, + }; + case TargetPlatform.Mac: + return new[] + { + TargetPlatform.Mac, + TargetPlatform.iOS, + }; + default: return new TargetPlatform[0]; + } + } + } /// /// Gets the architectures list supported by this dependency to build on the current build platform (based on ). /// - public abstract TargetArchitecture[] Architectures { get; } + public virtual TargetArchitecture[] Architectures + { + get + { + // Default value returns all supported architectures for all supported platforms + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.Linux: + return new[] + { + TargetArchitecture.x64, + //TargetArchitecture.ARM64, + }; + case TargetPlatform.Mac: + return new[] + { + TargetArchitecture.x64, + TargetArchitecture.ARM64, + }; + case TargetPlatform.XboxOne: + case TargetPlatform.XboxScarlett: + case TargetPlatform.PS4: + case TargetPlatform.PS5: + return new[] + { + TargetArchitecture.x64, + }; + case TargetPlatform.Switch: + return new[] + { + TargetArchitecture.ARM64, + }; + case TargetPlatform.Android: + return new[] + { + TargetArchitecture.ARM64, + }; + case TargetPlatform.iOS: + return new[] + { + TargetArchitecture.ARM64, + }; + default: return new TargetArchitecture[0]; + } + } + } /// /// True if build dependency by default, otherwise only when explicitly specified via command line.