From 10aa543b7e30a931b9cb4fb87d988c6abb268263 Mon Sep 17 00:00:00 2001 From: Markus Tavenrath Date: Wed, 6 Nov 2019 16:56:52 +0100 Subject: [PATCH] Use existing tests for appveyor. (#426) --- .appveyor.yml | 27 ++++++++++------------ tests/CMakeLists.txt | 8 +++++-- tests/DeviceFunctions/CMakeLists.txt | 30 +++++++++++++------------ tests/NoExceptions/CMakeLists.txt | 5 ++++- tests/NoExceptions/NoExceptions.cpp | 3 +++ tests/StructureChain/CMakeLists.txt | 5 ++++- tests/StructureChain/StructureChain.cpp | 16 ++++++++----- 7 files changed, 56 insertions(+), 38 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index a341eb2..2dc5e49 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -9,11 +9,18 @@ configuration: environment: matrix: - - GENERATOR: Visual Studio 15 2017 + - GENERATOR: Visual Studio 14 2015 + GENERATOR_ARCH: Win32 RAW_PLATFORM: x86 - - GENERATOR: Visual Studio 15 2017 Win64 + - GENERATOR: Visual Studio 14 2015 + GENERATOR_ARCH: x64 + RAW_PLATFORM: amd64 + - GENERATOR: Visual Studio 15 2017 + GENERATOR_ARCH: Win32 + RAW_PLATFORM: x86 + - GENERATOR: Visual Studio 15 2017 + GENERATOR_ARCH: x64 RAW_PLATFORM: amd64 - install: - git submodule update --init --recursive @@ -27,17 +34,7 @@ before_build: build_script: - mkdir appveyor-build - cd appveyor-build - - cmake .. "-G%GENERATOR%" - - cmake --build . --config %CONFIGURATION% + - cmake ..\tests -G "%GENERATOR%" -A %GENERATOR_ARCH% -DTESTS_BUILD_WITH_LOCAL_VULKAN_HPP=1 -DTESTS_BUILD_ONLY_DYNAMIC=1 test_script: - - "%CONFIGURATION%\\VulkanHppGenerator" - - ps: Write-Output "#include ""vulkan.hpp""" | Out-File -FilePath test.cpp - - ps: Write-Output "int myCreateInstance()" | Out-File -FilePath test.cpp -Append - - ps: Write-Output "{" | Out-File -FilePath test.cpp -Append - - ps: Write-Output " vk::Instance inst;" | Out-File -FilePath test.cpp -Append - - ps: Write-Output " auto const inst_info = vk::InstanceCreateInfo();" | Out-File -FilePath test.cpp -Append - - ps: Write-Output " vk::Result result = vk::createInstance(&inst_info, nullptr, &inst);" | Out-File -FilePath test.cpp -Append - - ps: Write-Output " return static_cast (result);" | Out-File -FilePath test.cpp -Append - - ps: Write-Output "}" | Out-File -FilePath test.cpp -Append - - cl.exe -I../vulkan -I../Vulkan-Headers/include /EHsc -c test.cpp + - cmake --build . --config %CONFIGURATION% diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b5ed176..7c833d9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,11 +14,15 @@ cmake_minimum_required(VERSION 3.2) -find_package(Vulkan REQUIRED) - project(Vulkan-Hpp_Tests) + option (TESTS_BUILD_WITH_LOCAL_VULKAN_HPP OFF) +option (TESTS_BUILD_ONLY_DYNAMIC OFF) + +if (NOT (TESTS_BUILD_ONLY_DYNAMIC AND TESTS_BUILD_WITH_LOCAL_VULKAN_HPP)) + find_package(Vulkan REQUIRED) +endif() if (WIN32) add_definitions(-DNOMINMAX -DVK_USE_PLATFORM_WIN32_KHR) diff --git a/tests/DeviceFunctions/CMakeLists.txt b/tests/DeviceFunctions/CMakeLists.txt index ffea320..2769714 100644 --- a/tests/DeviceFunctions/CMakeLists.txt +++ b/tests/DeviceFunctions/CMakeLists.txt @@ -14,22 +14,24 @@ cmake_minimum_required(VERSION 3.2) -project(DeviceFunctions) +if (NOT TESTS_BUILD_ONLY_DYNAMIC) + project(DeviceFunctions) -set(HEADERS -) + set(HEADERS + ) -set(SOURCES - DeviceFunctions.cpp -) + set(SOURCES + DeviceFunctions.cpp + ) -source_group(headers FILES ${HEADERS}) -source_group(sources FILES ${SOURCES}) + source_group(headers FILES ${HEADERS}) + source_group(sources FILES ${SOURCES}) -add_executable(DeviceFunctions - ${HEADERS} - ${SOURCES} -) + add_executable(DeviceFunctions + ${HEADERS} + ${SOURCES} + ) -set_target_properties(DeviceFunctions PROPERTIES FOLDER "Tests") -target_link_libraries(DeviceFunctions "${Vulkan_LIBRARIES}") + set_target_properties(DeviceFunctions PROPERTIES FOLDER "Tests") + target_link_libraries(DeviceFunctions "${Vulkan_LIBRARIES}") +endif() \ No newline at end of file diff --git a/tests/NoExceptions/CMakeLists.txt b/tests/NoExceptions/CMakeLists.txt index 510e06f..6feb80e 100644 --- a/tests/NoExceptions/CMakeLists.txt +++ b/tests/NoExceptions/CMakeLists.txt @@ -31,5 +31,8 @@ add_executable(NoExceptions ${SOURCES} ) +if (UNIX) + target_link_libraries(NoExceptions "-ldl") +endif() + set_target_properties(NoExceptions PROPERTIES FOLDER "Tests") -target_link_libraries(NoExceptions "${Vulkan_LIBRARIES}") diff --git a/tests/NoExceptions/NoExceptions.cpp b/tests/NoExceptions/NoExceptions.cpp index 2923d8b..f9e5fa0 100644 --- a/tests/NoExceptions/NoExceptions.cpp +++ b/tests/NoExceptions/NoExceptions.cpp @@ -17,6 +17,7 @@ // Note: this is _no_ functional test!! Don't ever code this way!! #define VULKAN_HPP_NO_EXCEPTIONS +#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1 #include "vulkan/vulkan.hpp" #include @@ -24,6 +25,8 @@ static char const* AppName = "DeviceFunctions"; static char const* EngineName = "Vulkan.hpp"; +VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE; + int main(int /*argc*/, char ** /*argv*/) { vk::ApplicationInfo appInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_1); diff --git a/tests/StructureChain/CMakeLists.txt b/tests/StructureChain/CMakeLists.txt index 19ecbbd..ad05f73 100644 --- a/tests/StructureChain/CMakeLists.txt +++ b/tests/StructureChain/CMakeLists.txt @@ -31,5 +31,8 @@ add_executable(StructureChain ${SOURCES} ) +if (UNIX) + target_link_libraries(StructureChain "-ldl") +endif() + set_target_properties(StructureChain PROPERTIES FOLDER "Tests") -target_link_libraries(StructureChain "${Vulkan_LIBRARIES}") diff --git a/tests/StructureChain/StructureChain.cpp b/tests/StructureChain/StructureChain.cpp index b496267..07cde8f 100644 --- a/tests/StructureChain/StructureChain.cpp +++ b/tests/StructureChain/StructureChain.cpp @@ -15,6 +15,8 @@ // VulkanHpp Tests : StructureChain // Compile-test for StructureChains +#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1 + #include "vulkan/vulkan.hpp" #include @@ -29,10 +31,16 @@ static char const* EngineName = "Vulkan.hpp"; // unknow compiler... just ignore the warnings for yourselves ;) #endif +VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE; + int main(int /*argc*/, char ** /*argv*/) { try { + vk::DynamicLoader dl; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = dl.getProcAddress("vkGetInstanceProcAddr"); + VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); + vk::ApplicationInfo appInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_1); vk::UniqueInstance instance = vk::createInstanceUnique(vk::InstanceCreateInfo({}, &appInfo)); vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front(); @@ -46,7 +54,7 @@ int main(int /*argc*/, char ** /*argv*/) vk::StructureChain sc6; vk::StructureChain sc7; - // some not valid StructureChains + // some invalid StructureChains //vk::StructureChain x; //vk::StructureChain x; //vk::StructureChain x; @@ -59,16 +67,14 @@ int main(int /*argc*/, char ** /*argv*/) // simple calls, getting structure back vk::PhysicalDeviceFeatures2 a = physicalDevice.getFeatures2(); - vk::PhysicalDeviceFeatures2 b = physicalDevice.getFeatures2(vk::DispatchLoaderStatic()); // complex calls, getting StructureChain back auto c = physicalDevice.getFeatures2(); vk::PhysicalDeviceFeatures2 & c0 = c.get(); - vk::PhysicalDeviceVariablePointerFeatures & c1 = c.get(); auto t0 = c.get(); - auto d = physicalDevice.getFeatures2(vk::DispatchLoaderStatic()); + auto d = physicalDevice.getFeatures2(); vk::PhysicalDeviceFeatures2 & d0 = d.get(); vk::PhysicalDeviceVariablePointerFeatures & d1 = d.get(); @@ -76,7 +82,7 @@ int main(int /*argc*/, char ** /*argv*/) using StructureChain = vk::StructureChain; using AllocatorType = std::vector::allocator_type; - auto qfd = physicalDevice.getQueueFamilyProperties2(vk::DispatchLoaderStatic()); + auto qfd = physicalDevice.getQueueFamilyProperties2(VULKAN_HPP_DEFAULT_DISPATCHER); } catch (vk::SystemError err) {