From e93adcdcdbf08f340635dd087fc1c02774a55100 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 7 Nov 2020 23:40:15 +0800 Subject: [PATCH] merge directxtk --- .github/workflows/windows.yml | 2 +- packages/d/directxtk/xmake.lua | 42 ++++++++++++++++++++++++++++++++++ scripts/test.lua | 4 ++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 packages/d/directxtk/xmake.lua diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 3fb736a59..44c9f9a63 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -21,5 +21,5 @@ jobs: - name: Tests run: | - xmake l ./scripts/test.lua -D -k ${{ matrix.kind }} + xmake l ./scripts/test.lua -D -k ${{ matrix.kind }} --vs_sdkver=10.0.19041.0 diff --git a/packages/d/directxtk/xmake.lua b/packages/d/directxtk/xmake.lua new file mode 100644 index 000000000..6fd71e7ab --- /dev/null +++ b/packages/d/directxtk/xmake.lua @@ -0,0 +1,42 @@ +package("DirectXTK") + + set_homepage("https://github.com/microsoft/DirectXTK") + set_description("This package contains the \"DirectX Tool Kit\", a collection of helper classes for writing Direct3D 11 C++ code for Universal Windows Platform (UWP) apps for Windows 10, Xbox One, and Win32 desktop applications for Windows 7 Service Pack 1 or later.") + + set_urls("https://github.com/microsoft/DirectXTK/archive/$(version).zip", + "https://github.com/microsoft/DirectXTK.git", + {version = function (version) + local versions = { + ["20.9.0"] = "sept2020" + } + return versions[version] + end}) + + add_versions("20.9.0", "9d5131243bf3e33db2e3a968720d860abdcbbe7cb037c2cb5dd06046d439ed09") + + on_install("windows", function (package) + local configs = {} + local vs_sdkver = get_config("vs_sdkver") + if vs_sdkver then + local build_ver = string.match(vs_sdkver, "%d+%.%d+%.(%d+)%.?%d*") + assert(tonumber(build_ver) >= 19041, "DirectXTK requires Windows SDK to be at least 10.0.19041.0") + table.insert(configs, "-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=" .. vs_sdkver) + table.insert(configs, "-DCMAKE_SYSTEM_VERSION=" .. vs_sdkver) + end + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + import("package.tools.cmake").install(package, configs) + os.cp("Inc/*", package:installdir("include")) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + void test() + { + DirectX::SimpleMath::Vector3 eye(0.0f, 0.7f, 1.5f); + DirectX::SimpleMath::Vector3 at(0.0f, -0.1f, 0.0f); + + auto lookAt = DirectX::SimpleMath::Matrix::CreateLookAt(eye, at, DirectX::SimpleMath::Vector3::UnitY); + } + ]]}, {configs = {languages = "c++11"}, includes = { "SimpleMath.h" } })) + end) diff --git a/scripts/test.lua b/scripts/test.lua index c61ee5bb5..78ea2d7df 100644 --- a/scripts/test.lua +++ b/scripts/test.lua @@ -18,6 +18,7 @@ local options = , {nil, "ldflags", "kv", nil, "Set the ldflags." } , {nil, "ndk", "kv", nil, "Set the android NDK directory." } , {nil, "sdk", "kv", nil, "Set the SDK directory of cross toolchain." } +, {nil, "vs_sdkver", "kv", nil, "Set the Windows SDK version." } , {nil, "mingw", "kv", nil, "Set the MingW directory." } , {nil, "packages", "vs", nil, "The package list." } } @@ -47,6 +48,9 @@ function _require_packages(argv, packages) if argv.sdk then table.insert(config_argv, "--sdk=" .. argv.sdk) end + if argv.vs_sdkver then + table.insert(config_argv, "--vs_sdkver=" .. argv.vs_sdkver) + end if argv.mingw then table.insert(config_argv, "--mingw=" .. argv.mingw) end