|
| 1 | +#include "pch.h" |
| 2 | +#include "tasks.h" |
| 3 | + |
| 4 | +namespace mob::tasks { |
| 5 | + |
| 6 | + namespace { |
| 7 | + |
| 8 | + msbuild create_msbuild_tool(arch a, config config, |
| 9 | + msbuild::ops o = msbuild::build) |
| 10 | + { |
| 11 | + return std::move(msbuild(o).architecture(a).configuration(config).solution( |
| 12 | + directxtex::source_path() / "DirectXTex" / |
| 13 | + "DirectXTex_Desktop_2022.vcxproj")); |
| 14 | + } |
| 15 | + |
| 16 | + } // namespace |
| 17 | + |
| 18 | + directxtex::directxtex() : basic_task("directxtex") {} |
| 19 | + |
| 20 | + std::string directxtex::version() |
| 21 | + { |
| 22 | + return conf().version().get("directxtex"); |
| 23 | + } |
| 24 | + |
| 25 | + bool directxtex::prebuilt() |
| 26 | + { |
| 27 | + return false; |
| 28 | + } |
| 29 | + |
| 30 | + fs::path directxtex::source_path() |
| 31 | + { |
| 32 | + return conf().path().build() / "DirectXTex"; |
| 33 | + } |
| 34 | + |
| 35 | + void directxtex::do_clean(clean c) |
| 36 | + { |
| 37 | + if (is_set(c, clean::reclone)) { |
| 38 | + git_wrap::delete_directory(cx(), source_path()); |
| 39 | + return; |
| 40 | + } |
| 41 | + |
| 42 | + if (is_set(c, clean::rebuild)) { |
| 43 | + run_tool(create_msbuild_tool(arch::x64, config::release, msbuild::clean)); |
| 44 | + run_tool(create_msbuild_tool(arch::x64, config::debug, msbuild::clean)); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + void directxtex::do_fetch() |
| 49 | + { |
| 50 | + run_tool(make_git() |
| 51 | + .url(make_git_url("microsoft", "DirectXTex")) |
| 52 | + .branch(version()) |
| 53 | + .root(source_path())); |
| 54 | + } |
| 55 | + |
| 56 | + void directxtex::do_build_and_install() |
| 57 | + { |
| 58 | + op::create_directories(cx(), directxtex::source_path() / "Include"); |
| 59 | + op::create_directories(cx(), directxtex::source_path() / "Lib" / "Debug"); |
| 60 | + op::create_directories(cx(), directxtex::source_path() / "Lib" / "Release"); |
| 61 | + |
| 62 | + // DO NOT run these in parallel because both generate files that are shared |
| 63 | + // between release and debug |
| 64 | + run_tool(create_msbuild_tool(arch::x64, config::release)); |
| 65 | + run_tool(create_msbuild_tool(arch::x64, config::debug)); |
| 66 | + |
| 67 | + const auto binary_path = |
| 68 | + source_path() / "DirectXTex" / "Bin" / "Desktop_2022" / "x64"; |
| 69 | + |
| 70 | + for (const auto& header : {"DDS.h", "DirectXTex.h", "DirectXTex.inl "}) { |
| 71 | + op::copy_file_to_dir_if_better(cx(), source_path() / "DirectXTex" / header, |
| 72 | + source_path() / "Include"); |
| 73 | + } |
| 74 | + op::copy_file_to_dir_if_better(cx(), binary_path / "Debug" / "DirectXTex.lib", |
| 75 | + source_path() / "Lib" / "Debug"); |
| 76 | + op::copy_file_to_dir_if_better(cx(), binary_path / "Release" / "DirectXTex.lib", |
| 77 | + source_path() / "Lib" / "Release"); |
| 78 | + } |
| 79 | + |
| 80 | +} // namespace mob::tasks |
0 commit comments