Update ogg and vorbis to use CMake for compilation on Windows
This commit is contained in:
26
Source/ThirdParty/ogg/config_types.h
vendored
26
Source/ThirdParty/ogg/config_types.h
vendored
@@ -1,26 +0,0 @@
|
||||
#ifndef __CONFIG_TYPES_H__
|
||||
#define __CONFIG_TYPES_H__
|
||||
|
||||
/* these are filled in by configure */
|
||||
#define INCLUDE_INTTYPES_H 1
|
||||
#define INCLUDE_STDINT_H 1
|
||||
#define INCLUDE_SYS_TYPES_H 1
|
||||
|
||||
#if INCLUDE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
#if INCLUDE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#if INCLUDE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef uint16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef uint32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
typedef uint64_t ogg_uint64_t;
|
||||
|
||||
#endif
|
||||
1
Source/ThirdParty/ogg/ogg.h
vendored
1
Source/ThirdParty/ogg/ogg.h
vendored
@@ -11,6 +11,7 @@
|
||||
********************************************************************
|
||||
|
||||
function: toplevel libogg include
|
||||
last mod: $Id$
|
||||
|
||||
********************************************************************/
|
||||
#ifndef _OGG_H
|
||||
|
||||
14
Source/ThirdParty/ogg/os_types.h
vendored
14
Source/ThirdParty/ogg/os_types.h
vendored
@@ -10,7 +10,8 @@
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function: Define a consistent set of types on each platform.
|
||||
function: #ifdef jail to whip a few platforms into the UNIX ideal.
|
||||
last mod: $Id$
|
||||
|
||||
********************************************************************/
|
||||
#ifndef _OS_TYPES_H
|
||||
@@ -43,7 +44,6 @@
|
||||
typedef unsigned long long ogg_uint64_t;
|
||||
# elif defined(__MWERKS__)
|
||||
typedef long long ogg_int64_t;
|
||||
typedef unsigned long long ogg_uint64_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef short ogg_int16_t;
|
||||
@@ -62,7 +62,6 @@
|
||||
typedef __int64 ogg_int64_t;
|
||||
typedef __int32 ogg_int32_t;
|
||||
typedef unsigned __int32 ogg_uint32_t;
|
||||
typedef unsigned __int64 ogg_uint64_t;
|
||||
typedef __int16 ogg_int16_t;
|
||||
typedef unsigned __int16 ogg_uint16_t;
|
||||
# endif
|
||||
@@ -76,7 +75,6 @@
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef uint32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
typedef uint64_t ogg_uint64_t;
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
|
||||
@@ -87,7 +85,6 @@
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
typedef unsigned long long ogg_uint64_t;
|
||||
|
||||
#elif defined(__BEOS__)
|
||||
|
||||
@@ -98,7 +95,6 @@
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef uint32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
typedef uint64_t ogg_uint64_t;
|
||||
|
||||
#elif defined (__EMX__)
|
||||
|
||||
@@ -108,8 +104,6 @@
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
typedef unsigned long long ogg_uint64_t;
|
||||
|
||||
|
||||
#elif defined (DJGPP)
|
||||
|
||||
@@ -118,13 +112,11 @@
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
typedef unsigned long long ogg_uint64_t;
|
||||
|
||||
#elif defined(R5900)
|
||||
|
||||
/* PS2 EE */
|
||||
typedef long ogg_int64_t;
|
||||
typedef unsigned long ogg_uint64_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned ogg_uint32_t;
|
||||
typedef short ogg_int16_t;
|
||||
@@ -137,7 +129,6 @@
|
||||
typedef signed int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long int ogg_int64_t;
|
||||
typedef unsigned long long int ogg_uint64_t;
|
||||
|
||||
#elif defined(__TMS320C6X__)
|
||||
|
||||
@@ -147,7 +138,6 @@
|
||||
typedef signed int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long int ogg_int64_t;
|
||||
typedef unsigned long long int ogg_uint64_t;
|
||||
|
||||
#else
|
||||
|
||||
|
||||
2
Source/ThirdParty/vorbis/COPYING
vendored
2
Source/ThirdParty/vorbis/COPYING
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2002-2018 Xiph.org Foundation
|
||||
Copyright (c) 2002-2020 Xiph.org Foundation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
||||
2
Source/ThirdParty/vorbis/codec.h
vendored
2
Source/ThirdParty/vorbis/codec.h
vendored
@@ -6,7 +6,7 @@
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* by the Xiph.Org Foundation https://xiph.org/ *
|
||||
|
||||
********************************************************************
|
||||
|
||||
|
||||
2
Source/ThirdParty/vorbis/vorbisenc.h
vendored
2
Source/ThirdParty/vorbis/vorbisenc.h
vendored
@@ -6,7 +6,7 @@
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* by the Xiph.Org Foundation https://xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
|
||||
2
Source/ThirdParty/vorbis/vorbisfile.h
vendored
2
Source/ThirdParty/vorbis/vorbisfile.h
vendored
@@ -6,7 +6,7 @@
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* by the Xiph.Org Foundation https://xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Flax.Build;
|
||||
using Flax.Build.Platforms;
|
||||
|
||||
namespace Flax.Deps.Dependencies
|
||||
{
|
||||
/// <summary>
|
||||
/// Ogg project codecs use the Ogg bitstream format to arrange the raw, compressed bitstream into a more robust, useful form. For example, the Ogg bitstream makes seeking, time stamping and error recovery possible, as well as mixing several sepearate, concurrent media streams into a single physical bitstream.
|
||||
/// </summary>
|
||||
/// <seealso cref="Flax.Deps.Dependency" />
|
||||
class ogg : Dependency
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override TargetPlatform[] Platforms
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (BuildPlatform)
|
||||
{
|
||||
case TargetPlatform.Windows:
|
||||
return new[]
|
||||
{
|
||||
TargetPlatform.Windows,
|
||||
TargetPlatform.UWP,
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PatchWindowsTargetPlatformVersion(string vcxprojPath, string vcxprojContents, string windowsTargetPlatformVersion, string platformToolset)
|
||||
{
|
||||
// Fix the MSVC project settings for Windows
|
||||
var contents = vcxprojContents.Replace("<PlatformToolset>v140</PlatformToolset>", string.Format("<PlatformToolset>{0}</PlatformToolset>", platformToolset));
|
||||
contents = contents.Replace("</RootNamespace>", string.Format("</RootNamespace><WindowsTargetPlatformVersion>{0}</WindowsTargetPlatformVersion>", windowsTargetPlatformVersion));
|
||||
File.WriteAllText(vcxprojPath, contents);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Build(BuildOptions options)
|
||||
{
|
||||
var root = options.IntermediateFolder;
|
||||
var configuration = "Release";
|
||||
var filesToKeep = new[]
|
||||
{
|
||||
"ogg.Build.cs",
|
||||
};
|
||||
|
||||
// Get the source
|
||||
CloneGitRepo(root, "https://github.com/xiph/ogg");
|
||||
GitCheckout(root, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5");
|
||||
|
||||
var binariesToCopyMsvc = new[]
|
||||
{
|
||||
"libogg_static.lib",
|
||||
};
|
||||
var vsSolutionPath = Path.Combine(root, "win32", "VS2015", "libogg_static.sln");
|
||||
var vcxprojPath = Path.Combine(root, "win32", "VS2015", "libogg_static.vcxproj");
|
||||
var vcxprojContents = File.ReadAllText(vcxprojPath);
|
||||
var libraryFileName = "libogg.a";
|
||||
vcxprojContents = vcxprojContents.Replace("<RuntimeLibrary>MultiThreaded</RuntimeLibrary>", "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>");
|
||||
vcxprojContents = vcxprojContents.Replace("<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>", "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>");
|
||||
vcxprojContents = vcxprojContents.Replace("<WholeProgramOptimization>true</WholeProgramOptimization>", "<WholeProgramOptimization>false</WholeProgramOptimization>");
|
||||
var buildDir = Path.Combine(root, "build");
|
||||
|
||||
foreach (var platform in options.Platforms)
|
||||
{
|
||||
switch (platform)
|
||||
{
|
||||
case TargetPlatform.Windows:
|
||||
{
|
||||
// Fix the MSVC project settings for Windows
|
||||
PatchWindowsTargetPlatformVersion(vcxprojPath, vcxprojContents, "8.1", "140");
|
||||
|
||||
// Build for Win64
|
||||
Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configuration, "x64");
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
||||
foreach (var file in binariesToCopyMsvc)
|
||||
Utilities.FileCopy(Path.Combine(root, "win32", "VS2015", "x64", configuration, file), Path.Combine(depsFolder, file));
|
||||
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.UWP:
|
||||
{
|
||||
// Fix the MSVC project settings for UWP
|
||||
PatchWindowsTargetPlatformVersion(vcxprojPath, vcxprojContents, "10.0.17763.0", "v141");
|
||||
|
||||
// Build for UWP x64
|
||||
Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configuration, "x64");
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
||||
foreach (var file in binariesToCopyMsvc)
|
||||
Utilities.FileCopy(Path.Combine(root, "win32", "VS2015", "x64", configuration, file), Path.Combine(depsFolder, file));
|
||||
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.Linux:
|
||||
{
|
||||
var envVars = new Dictionary<string, string>
|
||||
{
|
||||
{ "CC", "clang-7" },
|
||||
{ "CC_FOR_BUILD", "clang-7" }
|
||||
};
|
||||
|
||||
Utilities.Run(Path.Combine(root, "autogen.sh"), null, null, root, Utilities.RunOptions.Default, envVars);
|
||||
|
||||
// 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.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, 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", "ogg"),
|
||||
Path.Combine(root, "PS4"), true, true);
|
||||
|
||||
// Build for PS4
|
||||
var solutionPath = Path.Combine(root, "PS4", "libogg_static.sln");
|
||||
Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "ORBIS");
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
||||
Utilities.FileCopy(Path.Combine(root, "PS4", "lib", libraryFileName), Path.Combine(depsFolder, libraryFileName));
|
||||
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.PS5:
|
||||
{
|
||||
// Get the build data files
|
||||
Utilities.DirectoryCopy(
|
||||
Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg"),
|
||||
Path.Combine(root, "PS5"), true, true);
|
||||
|
||||
// Build for PS5
|
||||
var solutionPath = Path.Combine(root, "PS5", "libogg_static.sln");
|
||||
Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "PROSPERO");
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
||||
Utilities.FileCopy(Path.Combine(root, "PS5", "lib", libraryFileName), Path.Combine(depsFolder, libraryFileName));
|
||||
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.XboxOne:
|
||||
{
|
||||
// Fix the MSVC project settings for Xbox Scarlett
|
||||
PatchWindowsTargetPlatformVersion(vcxprojPath, vcxprojContents, "10.0.19041.0", "v142");
|
||||
|
||||
// Build for Xbox Scarlett x64
|
||||
Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configuration, "x64");
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
||||
foreach (var file in binariesToCopyMsvc)
|
||||
Utilities.FileCopy(Path.Combine(root, "win32", "VS2015", "x64", configuration, file), Path.Combine(depsFolder, file));
|
||||
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.XboxScarlett:
|
||||
{
|
||||
// Fix the MSVC project settings for Xbox Scarlett
|
||||
PatchWindowsTargetPlatformVersion(vcxprojPath, vcxprojContents, "10.0.19041.0", "v142");
|
||||
|
||||
// Build for Xbox Scarlett x64
|
||||
Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configuration, "x64");
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
||||
foreach (var file in binariesToCopyMsvc)
|
||||
Utilities.FileCopy(Path.Combine(root, "win32", "VS2015", "x64", configuration, file), Path.Combine(depsFolder, file));
|
||||
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.Android:
|
||||
{
|
||||
// Build for Android
|
||||
SetupDirectory(buildDir, true);
|
||||
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -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:
|
||||
{
|
||||
// Get the build data files
|
||||
Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg"), root, true, true);
|
||||
|
||||
// Build for Switch
|
||||
SetupDirectory(buildDir, true);
|
||||
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -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 })
|
||||
{
|
||||
SetupDirectory(buildDir, true);
|
||||
RunCmake(buildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release");
|
||||
BuildCmake(buildDir);
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, architecture);
|
||||
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.iOS:
|
||||
{
|
||||
SetupDirectory(buildDir, true);
|
||||
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
|
||||
BuildCmake(buildDir);
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
|
||||
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Backup files
|
||||
var srcIncludePath = Path.Combine(root, "include", "ogg");
|
||||
var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "ogg");
|
||||
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
|
||||
SetupDirectory(dstIncludePath, true);
|
||||
|
||||
// Deploy header files and restore files
|
||||
Directory.GetFiles(srcIncludePath, "Makefile*").ToList().ForEach(File.Delete);
|
||||
Directory.GetFiles(srcIncludePath, "*.in").ToList().ForEach(File.Delete);
|
||||
Utilities.DirectoryCopy(srcIncludePath, dstIncludePath, true, true);
|
||||
File.Copy(Path.Combine(root, "COPYING"), Path.Combine(dstIncludePath, "COPYING"));
|
||||
foreach (var filename in filesToKeep)
|
||||
{
|
||||
var src = Path.Combine(options.IntermediateFolder, filename + ".tmp");
|
||||
var dst = Path.Combine(dstIncludePath, filename);
|
||||
Utilities.FileCopy(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,11 +69,24 @@ namespace Flax.Deps.Dependencies
|
||||
private List<string> vcxprojContentsWindows;
|
||||
private string[] vcxprojPathsWindows;
|
||||
|
||||
private Binary[] binariesToCopyWindows =
|
||||
private Binary[] vorbisBinariesToCopyWindows =
|
||||
{
|
||||
new Binary("libvorbis_static.lib", "libvorbis"),
|
||||
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)
|
||||
{
|
||||
@@ -92,28 +105,24 @@ namespace Flax.Deps.Dependencies
|
||||
return;
|
||||
|
||||
hasSourcesReady = true;
|
||||
|
||||
var packagePath = Path.Combine(root, "package.zip");
|
||||
configurationMsvc = "Release";
|
||||
|
||||
// Get the additional source (ogg dependency)
|
||||
Downloader.DownloadFileFromUrlToPath("http://downloads.xiph.org/releases/ogg/libogg-1.3.3.zip", packagePath);
|
||||
using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read))
|
||||
{
|
||||
archive.ExtractToDirectory(root);
|
||||
Directory.Move(Path.Combine(root, archive.Entries.First().FullName), Path.Combine(root, "libogg"));
|
||||
}
|
||||
string oggRoot = Path.Combine(root, "libogg");
|
||||
string vorbisRoot = Path.Combine(root, "libvorbis");
|
||||
|
||||
// Get the source
|
||||
File.Delete(packagePath);
|
||||
Downloader.DownloadFileFromUrlToPath("http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.zip", packagePath);
|
||||
using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read))
|
||||
{
|
||||
archive.ExtractToDirectory(root);
|
||||
rootMsvcLib = Path.Combine(root, archive.Entries.First().FullName);
|
||||
}
|
||||
SetupDirectory(oggRoot, false);
|
||||
CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git");
|
||||
GitResetLocalChanges(oggRoot); // Reset patches
|
||||
GitCheckout(oggRoot, "master", "db5c7a49ce7ebda47b15b78471e78fb7f2483e22");
|
||||
|
||||
// Patch Windows projects
|
||||
SetupDirectory(vorbisRoot, false);
|
||||
CloneGitRepo(vorbisRoot, "https://github.com/xiph/vorbis.git");
|
||||
GitResetLocalChanges(vorbisRoot); // Reset patches
|
||||
GitCheckout(vorbisRoot, "master", "84c023699cdf023a32fa4ded32019f194afcdad0");
|
||||
|
||||
rootMsvcLib = vorbisRoot;
|
||||
|
||||
// Patch Windows projects which use MSBuild
|
||||
vcxprojPathsWindows = new[]
|
||||
{
|
||||
Path.Combine(rootMsvcLib, "win32", "VS2010", "libvorbis", "libvorbis_static.vcxproj"),
|
||||
@@ -127,6 +136,36 @@ namespace Flax.Deps.Dependencies
|
||||
contents = contents.Replace("<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>", "<DebugInformationFormat></DebugInformationFormat>");
|
||||
vcxprojContentsWindows[i] = contents.Replace("<WholeProgramOptimization>true</WholeProgramOptimization>", "<WholeProgramOptimization>false</WholeProgramOptimization>");
|
||||
}
|
||||
|
||||
// TODO: FIXME for UWP/XBoxOne (use CMake for these too?)
|
||||
#if false
|
||||
var packagePath = Path.Combine(root, "package.zip");
|
||||
configurationMsvc = "Release";
|
||||
|
||||
// Get the additional source (ogg dependency)
|
||||
if (!Directory.Exists(Path.Combine(root, "libogg")))
|
||||
{
|
||||
File.Delete(packagePath);
|
||||
Downloader.DownloadFileFromUrlToPath("http://downloads.xiph.org/releases/ogg/libogg-1.3.3.zip", packagePath);
|
||||
using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read))
|
||||
{
|
||||
archive.ExtractToDirectory(root);
|
||||
Directory.Move(Path.Combine(root, archive.Entries.First().FullName), Path.Combine(root, "libogg"));
|
||||
}
|
||||
}
|
||||
|
||||
// Get the source
|
||||
if (!Directory.Exists(Path.Combine(root, "libvorbis")))
|
||||
{
|
||||
File.Delete(packagePath);
|
||||
Downloader.DownloadFileFromUrlToPath("http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.zip", packagePath);
|
||||
using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read))
|
||||
{
|
||||
archive.ExtractToDirectory(root);
|
||||
Directory.Move(Path.Combine(root, archive.Entries.First().FullName), Path.Combine(root, "libvorbis"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void BuildMsbuild(BuildOptions options, TargetPlatform platform, TargetArchitecture architecture)
|
||||
@@ -135,14 +174,14 @@ namespace Flax.Deps.Dependencies
|
||||
|
||||
string buildPlatform, buildDir;
|
||||
string[] vcxprojPaths;
|
||||
Binary[] binariesToCopy;
|
||||
List<Binary> binariesToCopy = new List<Binary>();
|
||||
switch (platform)
|
||||
{
|
||||
case TargetPlatform.Windows:
|
||||
{
|
||||
buildDir = Path.Combine(rootMsvcLib, "win32", "VS2010");
|
||||
binariesToCopy = binariesToCopyWindows;
|
||||
vcxprojPaths = vcxprojPathsWindows;
|
||||
PatchWindowsTargetPlatformVersion("8.1", "v140");
|
||||
PatchWindowsTargetPlatformVersion("10.0", "v143");
|
||||
switch (architecture)
|
||||
{
|
||||
case TargetArchitecture.x86:
|
||||
@@ -151,13 +190,17 @@ namespace Flax.Deps.Dependencies
|
||||
case TargetArchitecture.x64:
|
||||
buildPlatform = "x64";
|
||||
break;
|
||||
case TargetArchitecture.ARM64:
|
||||
buildPlatform = "ARM64";
|
||||
break;
|
||||
default: throw new InvalidArchitectureException(architecture);
|
||||
}
|
||||
|
||||
binariesToCopy.AddRange(vorbisBinariesToCopyWindows.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc))));
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.UWP:
|
||||
{
|
||||
buildDir = Path.Combine(rootMsvcLib, "win32", "VS2010");
|
||||
binariesToCopy = binariesToCopyWindows;
|
||||
vcxprojPaths = vcxprojPathsWindows;
|
||||
PatchWindowsTargetPlatformVersion("10.0.17763.0", "v141");
|
||||
switch (architecture)
|
||||
@@ -173,11 +216,13 @@ 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))));
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.PS4:
|
||||
{
|
||||
buildDir = Path.Combine(rootMsvcLib, "PS4");
|
||||
binariesToCopy = new[]
|
||||
var binariesToCopyVorbis = new[]
|
||||
{
|
||||
new Binary("libvorbis.a", "libvorbis"),
|
||||
};
|
||||
@@ -186,16 +231,17 @@ namespace Flax.Deps.Dependencies
|
||||
Path.Combine(buildDir, "libvorbis", "libvorbis_static.vcxproj"),
|
||||
};
|
||||
buildPlatform = "ORBIS";
|
||||
Utilities.DirectoryCopy(
|
||||
Path.Combine(GetBinariesFolder(options, platform), "Data", "vorbis"),
|
||||
Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "vorbis"),
|
||||
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"));
|
||||
Utilities.FileCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg", "ogg", "config_types.h"),
|
||||
Path.Combine(root, "..", "ogg", "include", "ogg", "config_types.h"));
|
||||
binariesToCopy.AddRange(binariesToCopyVorbis.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc))));
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.PS5:
|
||||
{
|
||||
buildDir = Path.Combine(rootMsvcLib, "PS5");
|
||||
binariesToCopy = new[]
|
||||
var binariesToCopyVorbis = new[]
|
||||
{
|
||||
new Binary("libvorbis.a", "libvorbis"),
|
||||
};
|
||||
@@ -209,21 +255,23 @@ 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"));
|
||||
Path.Combine(root, "..", "ogg", "include", "ogg", "config_types.h"));
|
||||
binariesToCopy.AddRange(binariesToCopyVorbis.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc))));
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.XboxOne:
|
||||
buildDir = Path.Combine(rootMsvcLib, "win32", "VS2010");
|
||||
binariesToCopy = binariesToCopyWindows;
|
||||
vcxprojPaths = vcxprojPathsWindows;
|
||||
buildPlatform = "x64";
|
||||
PatchWindowsTargetPlatformVersion("10.0.19041.0", "v142");
|
||||
binariesToCopy.AddRange(vorbisBinariesToCopyWindows.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc))));
|
||||
break;
|
||||
case TargetPlatform.XboxScarlett:
|
||||
buildDir = Path.Combine(rootMsvcLib, "win32", "VS2010");
|
||||
binariesToCopy = binariesToCopyWindows;
|
||||
vcxprojPaths = vcxprojPathsWindows;
|
||||
buildPlatform = "x64";
|
||||
PatchWindowsTargetPlatformVersion("10.0.19041.0", "v142");
|
||||
binariesToCopy.AddRange(vorbisBinariesToCopyWindows.Select(x => new Binary(x.Filename, Path.Combine(buildDir, x.SrcFolder, buildPlatform, configurationMsvc))));
|
||||
break;
|
||||
default: throw new InvalidPlatformException(platform);
|
||||
}
|
||||
@@ -235,7 +283,60 @@ namespace Flax.Deps.Dependencies
|
||||
// Copy binaries
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, architecture);
|
||||
foreach (var filename in binariesToCopy)
|
||||
Utilities.FileCopy(Path.Combine(buildDir, filename.SrcFolder, buildPlatform, configurationMsvc, filename.Filename), Path.Combine(depsFolder, filename.Filename));
|
||||
Utilities.FileCopy(Path.Combine(filename.SrcFolder, filename.Filename), Path.Combine(depsFolder, filename.Filename));
|
||||
}
|
||||
|
||||
private void BuildCmake(BuildOptions options, TargetPlatform platform, TargetArchitecture architecture)
|
||||
{
|
||||
GetSources();
|
||||
|
||||
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());
|
||||
|
||||
string ext;
|
||||
switch (platform)
|
||||
{
|
||||
case TargetPlatform.Windows:
|
||||
case TargetPlatform.UWP:
|
||||
case TargetPlatform.XboxOne:
|
||||
ext = ".lib";
|
||||
break;
|
||||
case TargetPlatform.Linux:
|
||||
ext = ".a";
|
||||
break;
|
||||
default:
|
||||
throw new InvalidPlatformException(platform);
|
||||
}
|
||||
|
||||
List<(string, string)> binariesToCopy = new List<(string, string)>();
|
||||
// Build ogg
|
||||
{
|
||||
var solutionPath = Path.Combine(oggBuildDir, "ogg.sln");
|
||||
|
||||
RunCmake(oggRoot, platform, architecture, $"-B\"{oggBuildDir}\" -DBUILD_SHARED_LIBS=OFF");
|
||||
Deploy.VCEnvironment.BuildSolution(solutionPath, configurationMsvc, architecture.ToString());
|
||||
foreach (var file in oggBinariesToCopyWindowsCmake)
|
||||
binariesToCopy.Add((Path.Combine(oggBuildDir, configurationMsvc, file.Item1), file.Item2));
|
||||
}
|
||||
|
||||
// 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");
|
||||
Deploy.VCEnvironment.BuildSolution(solutionPath, configurationMsvc, architecture.ToString());
|
||||
foreach (var file in vorbisBinariesToCopyWindowsCmake)
|
||||
binariesToCopy.Add((Path.Combine(vorbisBuildDir, "lib", configurationMsvc, file.Item1), file.Item2));
|
||||
}
|
||||
|
||||
// Copy binaries
|
||||
var depsFolder = GetThirdPartyFolder(options, platform, architecture);
|
||||
foreach (var file in binariesToCopy)
|
||||
Utilities.FileCopy(file.Item1, Path.Combine(depsFolder, file.Item2));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -259,7 +360,8 @@ namespace Flax.Deps.Dependencies
|
||||
{
|
||||
case TargetPlatform.Windows:
|
||||
{
|
||||
BuildMsbuild(options, TargetPlatform.Windows, TargetArchitecture.x64);
|
||||
BuildCmake(options, TargetPlatform.Windows, TargetArchitecture.x64);
|
||||
BuildCmake(options, TargetPlatform.Windows, TargetArchitecture.ARM64);
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.UWP:
|
||||
@@ -428,18 +530,24 @@ namespace Flax.Deps.Dependencies
|
||||
Utilities.FileCopy(src, dst);
|
||||
}
|
||||
|
||||
// Setup headers directory
|
||||
SetupDirectory(dstIncludePath, 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"));
|
||||
foreach (var filename in filesToKeep)
|
||||
try
|
||||
{
|
||||
var src = Path.Combine(options.IntermediateFolder, filename + ".tmp");
|
||||
var dst = Path.Combine(dstIncludePath, filename);
|
||||
Utilities.FileCopy(src, dst);
|
||||
// Setup headers directory
|
||||
SetupDirectory(dstIncludePath, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user