Files
FlaxEngine/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs
Ari Vuollet 96cc570e67
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
Add support for building dependencies with specific architecture
2025-10-12 17:50:33 +03:00

123 lines
4.9 KiB
C#

// Copyright (c) Wojciech Figat. All rights reserved.
using System.IO;
using Flax.Build;
namespace Flax.Deps.Dependencies
{
/// <summary>
/// DirectXTex texture processing library https://walbourn.github.io/directxtex/
/// </summary>
/// <seealso cref="Flax.Deps.Dependency" />
class DirectXTex : Dependency
{
/// <inheritdoc />
public override TargetPlatform[] Platforms
{
get
{
switch (BuildPlatform)
{
case TargetPlatform.Windows:
return new[]
{
TargetPlatform.Windows,
TargetPlatform.XboxOne,
TargetPlatform.XboxScarlett,
};
default: return new TargetPlatform[0];
}
}
}
/// <inheritdoc />
public override TargetArchitecture[] Architectures
{
get
{
switch (BuildPlatform)
{
case TargetPlatform.Windows:
return new[]
{
TargetArchitecture.x64,
TargetArchitecture.ARM64,
};
default: return new TargetArchitecture[0];
}
}
}
/// <inheritdoc />
public override void Build(BuildOptions options)
{
var root = options.IntermediateFolder;
var configuration = "Release";
var outputFileNames = new[]
{
"DirectXTex.lib",
"DirectXTex.pdb",
};
// Get the source
CloneGitRepo(root, "https://github.com/Microsoft/DirectXTex.git");
GitCheckout(root, "main", "5cfd711dc5d64cde1e8b27670036535df5c3f922");
foreach (var platform in options.Platforms)
{
foreach (var architecture in options.Architectures)
{
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;
}
}
}
}
// Deploy header files and license file
var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "DirectXTex");
foreach (var file in new[]
{
"DirectXTex/DirectXTex.h",
"DirectXTex/DirectXTex.inl",
"LICENSE",
})
{
Utilities.FileCopy(Path.Combine(root, file), Path.Combine(dstIncludePath, Path.GetFileName(file)));
}
}
}
}