diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs new file mode 100644 index 000000000..df7d49a81 --- /dev/null +++ b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXShaderCompiler.cs @@ -0,0 +1,69 @@ +// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. + +using System; +using System.IO; +using System.Linq; +using Flax.Build; +using Flax.Build.Platforms; + +namespace Flax.Deps.Dependencies +{ + /// + /// DirectX Shader Compiler and tools. https://github.com/microsoft/DirectXShaderCompiler + /// + /// + class DirectXShaderCompiler : Dependency + { + /// + public override TargetPlatform[] Platforms + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetPlatform.Windows, + }; + default: return new TargetPlatform[0]; + } + } + } + + /// + public override void Build(BuildOptions options) + { + foreach (var platform in options.Platforms) + { + 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()); + + foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + { + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + + string dxilLocation = @$"{binLocation}\{architecture}\dxil.dll"; + string dxcompilerLocation = @$"{binLocation}\{architecture}\dxcompiler.dll"; + string d3dcompilerLocation = @$"{binLocation}\{architecture}\d3dcompiler_47.dll"; + Utilities.FileCopy(dxilLocation, Path.Combine(depsFolder, Path.GetFileName(dxilLocation))); + Utilities.FileCopy(dxcompilerLocation, Path.Combine(depsFolder, Path.GetFileName(dxcompilerLocation))); + Utilities.FileCopy(d3dcompilerLocation, Path.Combine(depsFolder, Path.GetFileName(d3dcompilerLocation))); + + string dxcompilerLibLocation = @$"{sdkLibLocation}\{architecture}\dxcompiler.lib"; + 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; + } + } + } + } + } +} diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/dbghelp.cs b/Source/Tools/Flax.Build/Deps/Dependencies/dbghelp.cs new file mode 100644 index 000000000..e9096be08 --- /dev/null +++ b/Source/Tools/Flax.Build/Deps/Dependencies/dbghelp.cs @@ -0,0 +1,60 @@ +// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. + +using System; +using System.IO; +using System.Linq; +using Flax.Build; +using Flax.Build.Platforms; + +namespace Flax.Deps.Dependencies +{ + /// + /// Windows Debug Help Library. + /// + /// + class dbghelp : Dependency + { + /// + public override TargetPlatform[] Platforms + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Windows: + return new[] + { + TargetPlatform.Windows, + }; + default: return new TargetPlatform[0]; + } + } + } + + /// + public override void Build(BuildOptions options) + { + foreach (var platform in options.Platforms) + { + switch (platform) + { + case TargetPlatform.Windows: + { + var sdk = WindowsPlatformBase.GetSDKs().Last(); + + foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) + { + var depsFolder = GetThirdPartyFolder(options, platform, architecture); + + string libLocation = @$"{sdk.Value}Debuggers\lib\{architecture}\dbghelp.lib"; + string 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; + } + } + } + } + } +}