From 8c9dae0c1a42c49325b734d0e363a834daf4e550 Mon Sep 17 00:00:00 2001 From: Sharadh Rajaraman Date: Fri, 16 Aug 2024 03:28:32 +0100 Subject: [PATCH] Add support for external `import std` control with `VULKAN_HPP_ENABLE_STD_MODULE` - Rewrite `includes.hpp` and `macros.hpp` - Unconditionally set `VULKAN_HPP_ENABLE_STD_MODULE` for `vulkan.cppm` to bug-fix - Generated necessary files again --- VulkanHppGenerator.cpp | 4 ++++ snippets/includes.hpp | 12 ++++++------ snippets/macros.hpp | 4 ++-- vulkan/vulkan.cppm | 4 ++++ vulkan/vulkan.hpp | 14 +++++++------- vulkan/vulkan_hpp_macros.hpp | 4 ++-- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index a8aa2dcb3..e556177af 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -806,6 +806,10 @@ void VulkanHppGenerator::generateCppModuleFile() const module; +#if defined( __cpp_lib_modules ) +#define VULKAN_HPP_ENABLE_STD_MODULE +#endif + #include #include #include diff --git a/snippets/includes.hpp b/snippets/includes.hpp index 8a66239fa..1876d741a 100644 --- a/snippets/includes.hpp +++ b/snippets/includes.hpp @@ -1,6 +1,6 @@ #include -#if !defined( VULKAN_HPP_STD_MODULE ) +#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include # include // ArrayWrapperND # include // strnlen @@ -12,16 +12,16 @@ import VULKAN_HPP_STD_COMPAT_MODULE; #endif #include -#if 17 <= VULKAN_HPP_CPP_VERSION && !defined( VULKAN_HPP_STD_MODULE ) +#if 17 <= VULKAN_HPP_CPP_VERSION && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) && !defined( VULKAN_HPP_STD_MODULE ) +#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::tie # include // std::vector #endif -#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) && !defined( VULKAN_HPP_STD_MODULE ) +#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::is_error_code_enum #endif @@ -45,10 +45,10 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h # endif #endif -#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) && !defined( VULKAN_HPP_STD_MODULE ) +#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if defined( VULKAN_HPP_SUPPORT_SPAN ) && !defined( VULKAN_HPP_STD_MODULE ) +#if defined( VULKAN_HPP_SUPPORT_SPAN ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif diff --git a/snippets/macros.hpp b/snippets/macros.hpp index a3cb02cd3..9842a9f32 100644 --- a/snippets/macros.hpp +++ b/snippets/macros.hpp @@ -77,7 +77,7 @@ # define VULKAN_HPP_SUPPORT_SPAN #endif -#if ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_modules ) && !defined( VULKAN_HPP_STD_MODULE ) +#if defined( __cpp_lib_modules ) && !defined( VULKAN_HPP_STD_MODULE ) && defined( VULKAN_HPP_ENABLE_STD_MODULE ) # define VULKAN_HPP_STD_MODULE std # define VULKAN_HPP_STD_COMPAT_MODULE std.compat #endif @@ -274,7 +274,7 @@ namespace VULKAN_HPP_NAMESPACE #endif #if !defined( VULKAN_HPP_EXPECTED ) && ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_expected ) -# if !defined( VULKAN_HPP_STD_MODULE ) +# if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include # endif # define VULKAN_HPP_EXPECTED std::expected diff --git a/vulkan/vulkan.cppm b/vulkan/vulkan.cppm index 10e3f1f41..1fb1108bc 100644 --- a/vulkan/vulkan.cppm +++ b/vulkan/vulkan.cppm @@ -10,6 +10,10 @@ module; +#if defined( __cpp_lib_modules ) +# define VULKAN_HPP_ENABLE_STD_MODULE +#endif + #include #include #include diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index ffc5ab623..da21c873f 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -10,7 +10,7 @@ #include -#if !defined( VULKAN_HPP_STD_MODULE ) +#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include # include // ArrayWrapperND # include // strnlen @@ -22,16 +22,16 @@ import VULKAN_HPP_STD_COMPAT_MODULE; #endif #include -#if 17 <= VULKAN_HPP_CPP_VERSION && !defined( VULKAN_HPP_STD_MODULE ) +#if 17 <= VULKAN_HPP_CPP_VERSION && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) && !defined( VULKAN_HPP_STD_MODULE ) +#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::tie # include // std::vector #endif -#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) && !defined( VULKAN_HPP_STD_MODULE ) +#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::is_error_code_enum #endif @@ -55,11 +55,11 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h # endif #endif -#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) && !defined( VULKAN_HPP_STD_MODULE ) +#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if defined( VULKAN_HPP_SUPPORT_SPAN ) && !defined( VULKAN_HPP_STD_MODULE ) +#if defined( VULKAN_HPP_SUPPORT_SPAN ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif @@ -16736,7 +16736,7 @@ namespace VULKAN_HPP_NAMESPACE m_library = dlopen( "libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL ); } # elif defined( _WIN32 ) - m_library = ::LoadLibraryA( "vulkan-1.dll" ); + m_library = ::LoadLibraryA( "vulkan-1.dll" ); # else # error unsupported platform # endif diff --git a/vulkan/vulkan_hpp_macros.hpp b/vulkan/vulkan_hpp_macros.hpp index a59bda421..3e0e6f81b 100644 --- a/vulkan/vulkan_hpp_macros.hpp +++ b/vulkan/vulkan_hpp_macros.hpp @@ -87,7 +87,7 @@ # define VULKAN_HPP_SUPPORT_SPAN #endif -#if ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_modules ) && !defined( VULKAN_HPP_STD_MODULE ) +#if defined( __cpp_lib_modules ) && !defined( VULKAN_HPP_STD_MODULE ) && defined( VULKAN_HPP_ENABLE_STD_MODULE ) # define VULKAN_HPP_STD_MODULE std # define VULKAN_HPP_STD_COMPAT_MODULE std.compat #endif @@ -284,7 +284,7 @@ namespace VULKAN_HPP_NAMESPACE #endif #if !defined( VULKAN_HPP_EXPECTED ) && ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_expected ) -# if !defined( VULKAN_HPP_STD_MODULE ) +# if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include # endif # define VULKAN_HPP_EXPECTED std::expected