Use the OpenAL Git repository as a source for building other platforms
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

This commit is contained in:
2025-10-12 20:41:49 +03:00
parent 6ca949e70b
commit 52c2634414

View File

@@ -80,42 +80,35 @@ namespace Flax.Deps.Dependencies
{
var root = options.IntermediateFolder;
var version = "1.23.1";
var cmakeArgs = "-DCMAKE_POLICY_VERSION_MINIMUM=3.5";
var configuration = "Release";
var cmakeArgs = $"-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE={configuration}";
var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "OpenAL");
if (options.Platforms.Contains(TargetPlatform.Windows))
// Get the source
#if true
CloneGitRepo(root, "https://github.com/kcat/openal-soft.git");
GitCheckout(root, "master", "d3875f333fb6abe2f39d82caca329414871ae53b"); // 1.23.1
#else
var packagePath = Path.Combine(root, $"package-{version}.tar.bz2");
if (!File.Exists(packagePath))
{
// 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);
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)
// The certificate was expired, use alternative source
//Downloader.DownloadFileFromUrlToPath($"https://openal-soft.org/openal-releases/openal-soft-{version}.tar.bz2", packagePath);
Downloader.DownloadFileFromUrlToPath($"https://github.com/kcat/openal-soft/releases/download/{version}/openal-soft-{version}.tar.bz2", packagePath);
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);
Utilities.Run(sevenZip, $"x {packagePath}", 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)
{
@@ -131,46 +124,17 @@ namespace Flax.Deps.Dependencies
"OpenAL32.lib",
"OpenAL32.dll",
};
string configuration = "Release";
var config = "-DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=\"/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR /EHsc\" -DCMAKE_CXX_FLAGS=\"/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR /EHsc\" " + cmakeArgs;
// Build for Windows
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\" " + cmakeArgs);
SetupDirectory(buildDir, true);
RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + config);
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);
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:
@@ -179,21 +143,18 @@ namespace Flax.Deps.Dependencies
{
"libopenal.a",
};
var envVars = new Dictionary<string, string>
/*var envVars = new Dictionary<string, string>
{
{ "CC", "clang-7" },
{ "CC_FOR_BUILD", "clang-7" }
};
var config = "-DALSOFT_REQUIRE_ALSA=ON -DALSOFT_REQUIRE_OSS=ON -DALSOFT_REQUIRE_PORTAUDIO=ON -DALSOFT_REQUIRE_PULSEAUDIO=ON -DALSOFT_REQUIRE_JACK=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);
};*/
var config = "-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DALSOFT_REQUIRE_ALSA=ON -DALSOFT_REQUIRE_OSS=ON -DALSOFT_REQUIRE_PORTAUDIO=ON -DALSOFT_REQUIRE_PULSEAUDIO=ON -DALSOFT_REQUIRE_JACK=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs;
// Build for Linux
Utilities.Run("cmake", "-G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLIBTYPE=STATIC " + config + " ..", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars);
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput, envVars);
var buildDir = Path.Combine(root, "build-" + architecture.ToString());
SetupDirectory(buildDir, true);
RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + config);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
foreach (var file in binariesToCopy)
Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file));
@@ -207,13 +168,10 @@ namespace Flax.Deps.Dependencies
};
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");
// Build for Android
var buildDir = Path.Combine(root, "build-" + architecture.ToString());
SetupDirectory(buildDir, true);
// Build
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config);
RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + config);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
foreach (var file in binariesToCopy)
@@ -228,13 +186,10 @@ namespace Flax.Deps.Dependencies
};
var config = "-DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs;
// Use separate build directory
root = Path.Combine(root, "openal-soft-" + version);
var buildDir = Path.Combine(root, "build");
// Build for Mac
var buildDir = Path.Combine(root, "build-" + architecture.ToString());
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, architecture, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config);
RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + config);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, architecture);
foreach (var file in binariesToCopy)
@@ -247,15 +202,12 @@ namespace Flax.Deps.Dependencies
{
"libopenal.a",
};
var config = "-DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs;
// Use separate build directory
root = Path.Combine(root, "openal-soft-" + version);
var buildDir = Path.Combine(root, "build");
var config = "-DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES " + cmakeArgs;
// Build for iOS
var buildDir = Path.Combine(root, "build-" + architecture.ToString());
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config);
RunCmake(root, platform, architecture, $"-B\"{buildDir}\" " + config);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
foreach (var file in binariesToCopy)
@@ -265,6 +217,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)));
}
}
}
}