6 Commits

Author SHA1 Message Date
7e72e856e1 Fix building ogg+vorbis on macOS
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled
2025-10-18 02:34:50 +03:00
2e78190bf0 Fix NvCloth compilation on Linux and macOS 2025-10-18 02:34:41 +03:00
03df23679f Fix PhysX compilation on Linux and macOS 2025-10-18 02:34:33 +03:00
c2cbf11e4d Fix python tool call on macOS for glslang 2025-10-18 02:34:22 +03:00
f4c3fb1c72 Fix building PhysX on Linux and macOS 2025-10-18 02:34:14 +03:00
5327529f38 Support building OpenAL from Git repository in other platforms 2025-10-18 02:34:04 +03:00
5 changed files with 181 additions and 187 deletions

View File

@@ -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)
@@ -184,7 +194,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;
@@ -194,7 +204,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";
break;

View File

@@ -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
@@ -99,24 +102,21 @@ namespace Flax.Deps.Dependencies
{
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 +136,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:
@@ -194,14 +166,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;
@@ -219,12 +193,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)
@@ -244,12 +220,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)
@@ -269,12 +247,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)
@@ -284,6 +264,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)));
}
}
}
}

View File

@@ -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,9 @@ namespace Flax.Deps.Dependencies
ConfigureCmakeSwitch(cmakeParams, "PX_COPY_EXTERNAL_DLL", "OFF");
}
break;
case TargetPlatform.Linux:
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");
ConfigureCmakeSwitch(cmakeParams, "ANDROID_NATIVE_API_LEVEL", $"android-{Configuration.AndroidPlatformApi}");
@@ -136,6 +144,7 @@ namespace Flax.Deps.Dependencies
break;
case TargetPlatform.Mac:
ConfigureCmakeSwitch(cmakeParams, "CMAKE_OSX_DEPLOYMENT_TARGET", Configuration.MacOSXMinVer);
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);
@@ -156,6 +165,7 @@ namespace Flax.Deps.Dependencies
bool suppressBitsPostfix = false;
string binariesPrefix = string.Empty;
var envVars = new Dictionary<string, string>();
envVars.Add("CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel);
switch (architecture)
{
case TargetArchitecture.x86:
@@ -484,7 +494,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);
}
}
}

View File

@@ -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)
{

View File

@@ -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<string> 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,105 @@ 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<string, string> envVars = new Dictionary<string, string>();
(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<string, string>
{
{ "CC", "clang-" + Configuration.LinuxClangMinVer },
{ "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }
};
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,29 +431,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<string, string>
{
{ "CC", "clang-" + Configuration.LinuxClangMinVer },
{ "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }
};
var buildDir = Path.Combine(root, "build");
Utilities.Run(Path.Combine(root, "autogen.sh"), null, null, root, Utilities.RunOptions.Default, 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.Default, 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:
@@ -458,51 +478,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");
@@ -530,37 +532,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"));
}
}
}