diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml new file mode 100644 index 0000000..e9f3617 --- /dev/null +++ b/.github/workflows/generate.yml @@ -0,0 +1,21 @@ +name: Generate Headers +on: + pull_request: + push: + branches: + - master +jobs: + generate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5.0.0 + with: + submodules: true + fetch-tags: true + - name: Generate Headers + run: | + git fetch --unshallow --tags + cmake -B build -DVMA_HPP_GENERATOR_BUILD=ON -DVMA_HPP_RUN_GENERATOR=ON -DVMA_HPP_DO_UPDATE=ON -DVMA_HPP_SAMPLES_BUILD=OFF + cmake --build build + git diff --exit-code diff --git a/CMakeLists.txt b/CMakeLists.txt index a8eab7c..936f4bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,9 @@ option(VMA_HPP_RUN_GENERATOR "Run the HPP generator" ${PROJECT_IS_TOP_LEVE option(VMA_HPP_SAMPLES_BUILD "Build samples" ${PROJECT_IS_TOP_LEVEL}) option(VMA_HPP_DO_UPDATE "Update VMA submodule" OFF) set(VMA_HPP_INPUT_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/VulkanMemoryAllocator/include/vk_mem_alloc.h" CACHE FILEPATH "Input vk_mem_alloc.h file") -set(VMA_HPP_VULKAN_MIN_REVISION "1.4.334" CACHE INTERNAL "Minimal Vulkan-Headers revision") -set(VMA_HPP_VULKAN_REVISION "v${VMA_HPP_VULKAN_MIN_REVISION}" CACHE STRING "Vulkan-Headers revision") -set(VMA_HPP_VMA_REVISION "v${PROJECT_VERSION}" CACHE STRING "VulkanMemoryAllocator revision" FORCE) +set(VMA_HPP_VULKAN_MIN_VERSION "1.4.335" CACHE INTERNAL "Minimal Vulkan-Headers revision") +set(VMA_HPP_VULKAN_REVISION "v${VMA_HPP_VULKAN_MIN_VERSION}" CACHE STRING "Vulkan-Headers revision") +set(VMA_HPP_VMA_REVISION "v${PROJECT_VERSION}" CACHE STRING "VulkanMemoryAllocator revision" FORCE) if (VMA_HPP_DO_UPDATE) # Find Git. @@ -65,11 +65,11 @@ if (VMA_HPP_DO_UPDATE) string(STRIP ${CMAKE_MATCH_1} VMA_HPP_VMA_VERSION) # Update versions in the README. - message(STATUS "Updating README with VMA ${VMA_HPP_VMA_VERSION} and Vulkan ${VMA_HPP_VULKAN_MIN_REVISION}") + message(STATUS "Updating README with VMA ${VMA_HPP_VMA_VERSION} and Vulkan ${VMA_HPP_VULKAN_MIN_VERSION}") file(READ "${CMAKE_CURRENT_SOURCE_DIR}/README.md" VMA_HPP_README) string(REPLACE ";" "\\;" VMA_HPP_README "${VMA_HPP_README}") # Do not mess up semicolons in the README string(REGEX REPLACE "[^<]*" "${VMA_HPP_VMA_VERSION}" VMA_HPP_README "${VMA_HPP_README}") - string(REGEX REPLACE "[^<]*" "${VMA_HPP_VULKAN_MIN_REVISION}" VMA_HPP_README "${VMA_HPP_README}") + string(REGEX REPLACE "[^<]*" "${VMA_HPP_VULKAN_MIN_VERSION}" VMA_HPP_README "${VMA_HPP_README}") file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/README.md" ${VMA_HPP_README}) # Generate "imported" utility header. @@ -116,7 +116,7 @@ if (VMA_HPP_RUN_GENERATOR) WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Running VmaHppGenerator" DEPENDS VmaHppGenerator "${VMA_HPP_INPUT_HEADER}") - add_custom_target(GenerateVmaHpp DEPENDS ${VMA_HPP_GENERATED_FILES}) + add_custom_target(GenerateVmaHpp ALL DEPENDS ${VMA_HPP_GENERATED_FILES}) add_dependencies(VulkanMemoryAllocator-Hpp GenerateVmaHpp) endif () diff --git a/README.md b/README.md index 18689a2..cb38a46 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ consistent and compatible with Vulkan C++ bindings ([Vulkan-Hpp](https://github. #### Requirements - C++11 or newer -- [Vulkan headers](https://github.com/KhronosGroup/Vulkan-Headers) **1.4.334** or newer +- [Vulkan headers](https://github.com/KhronosGroup/Vulkan-Headers) **1.4.335** or newer - [VulkanMemoryAllocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) - *[GitHub releases](https://github.com/YaaZ/VulkanMemoryAllocator-Hpp/releases) is the recommended way to get VMA-Hpp, they already include a compatible `vk_mem_alloc.h` header* @@ -70,7 +70,7 @@ target_sources( PRIVATE ```c++ // Do not define VMA_IMPLEMENTATION -import vk_mem_alloc_hpp; // Also imports vulkan_hpp and std +import vk_mem_alloc; // Also imports vulkan and std ``` diff --git a/VmaHppGenerator.cpp b/VmaHppGenerator.cpp index 1b8fd54..a7ed010 100644 --- a/VmaHppGenerator.cpp +++ b/VmaHppGenerator.cpp @@ -1,8 +1,11 @@ #include #include +#include +#include #include #include #include +#include #include #include #include @@ -2130,7 +2133,7 @@ void generateModule(const ConditionalTree& tree, const Symbols& symbols) { if (endsWith(*t.name, "FlagBits")) specializations << n << navigate(t) << "template<> struct FlagTraits;"; - // fatal error C1116: unrecoverable error importing module 'vk_mem_alloc_hpp'. Specialization of 'vma::operator ==' with arguments 'vma::Pool, 0' + // fatal error C1116: unrecoverable error importing module 'vk_mem_alloc'. Specialization of 'vma::operator ==' with arguments 'vma::Pool, 0' for (const Symbol& t : symbols.handles) specializations << n << navigate(t) << "template<> struct isVulkanHandleType;"; @@ -2156,8 +2159,8 @@ void generateModule(const ConditionalTree& tree, const Symbols& symbols) { #define VMA_IMPLEMENTATION #include "vk_mem_alloc.hpp" #include "vk_mem_alloc_raii.hpp" - export module vk_mem_alloc_hpp; - export import vulkan_hpp; + export module vk_mem_alloc; + export import vulkan; export namespace VMA_HPP_NAMESPACE { #ifndef VULKAN_HPP_NO_TO_STRING @@ -2195,7 +2198,7 @@ void generateModule(const ConditionalTree& tree, const Symbols& symbols) { module : private; namespace VULKAN_HPP_NAMESPACE { - // This is needed for template specializations to be visible outside the module when importing vulkan_hpp (is this a MSVC bug?). + // This is needed for template specializations to be visible outside the module when importing vulkan (is this a MSVC bug?). $3 #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE namespace VULKAN_HPP_RAII_NAMESPACE { @@ -2214,9 +2217,9 @@ std::string readSource() { in.seekg(0, std::ios::beg); text.assign(std::istreambuf_iterator(in), {}); + text = text.substr(0, text.find("#ifdef VMA_IMPLEMENTATION")); // Strip implementation part text = std::regex_replace(text, std::regex(R"(/\*[\s\S]*?\*/)"), ""); // Delete multi-line comments text = std::regex_replace(text, std::regex("//.*"), ""); // Delete single-line comments - text = text.substr(0, text.find("#ifdef VMA_IMPLEMENTATION")); // Strip implementation part return text; } diff --git a/include/vk_mem_alloc.cppm b/include/vk_mem_alloc.cppm index 42e6f8c..87e068a 100644 --- a/include/vk_mem_alloc.cppm +++ b/include/vk_mem_alloc.cppm @@ -4,8 +4,8 @@ module; #define VMA_IMPLEMENTATION #include "vk_mem_alloc.hpp" #include "vk_mem_alloc_raii.hpp" -export module vk_mem_alloc_hpp; -export import vulkan_hpp; +export module vk_mem_alloc; +export import vulkan; export namespace VMA_HPP_NAMESPACE { #ifndef VULKAN_HPP_NO_TO_STRING @@ -104,7 +104,7 @@ export namespace VMA_HPP_NAMESPACE { module : private; namespace VULKAN_HPP_NAMESPACE { - // This is needed for template specializations to be visible outside the module when importing vulkan_hpp (is this a MSVC bug?). + // This is needed for template specializations to be visible outside the module when importing vulkan (is this a MSVC bug?). template<> struct FlagTraits; template<> struct FlagTraits; template<> struct FlagTraits; diff --git a/include/vk_mem_alloc.hpp b/include/vk_mem_alloc.hpp index b22a215..9b6f92e 100644 --- a/include/vk_mem_alloc.hpp +++ b/include/vk_mem_alloc.hpp @@ -17,7 +17,7 @@ #define VULKAN_MEMORY_ALLOCATOR_HPP #ifdef VMA_HPP_CXX_MODULE -import vulkan_hpp; +import vulkan; #else #include #endif diff --git a/samples/common.hpp b/samples/common.hpp index 20341ff..4938310 100644 --- a/samples/common.hpp +++ b/samples/common.hpp @@ -1,5 +1,5 @@ #ifdef USE_MODULES -import vk_mem_alloc_hpp; +import vk_mem_alloc; #else #define VMA_IMPLEMENTATION #include