Skip to content

Commit

Permalink
Add support for external import std control with `VULKAN_HPP_ENABLE…
Browse files Browse the repository at this point in the history
…_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
  • Loading branch information
sharadhr committed Aug 16, 2024
1 parent 3b2d354 commit 339a2b8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
4 changes: 4 additions & 0 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ void VulkanHppGenerator::generateCppModuleFile() const

module;

#if defined( __cpp_lib_modules )
#define VULKAN_HPP_ENABLE_STD_MODULE
#endif

#include <vulkan/${api}.hpp>
#include <vulkan/${api}_extension_inspection.hpp>
#include <vulkan/${api}_format_traits.hpp>
Expand Down
12 changes: 6 additions & 6 deletions snippets/includes.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <vulkan/vulkan_hpp_macros.hpp>

#if !defined( VULKAN_HPP_STD_MODULE )
#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) )
# include <algorithm>
# include <array> // ArrayWrapperND
# include <string.h> // strnlen
Expand All @@ -12,16 +12,16 @@ import VULKAN_HPP_STD_COMPAT_MODULE;
#endif
#include <vulkan/${vulkan_h}>

#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 <string_view>
#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 <tuple> // std::tie
# include <vector> // 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 <system_error> // std::is_error_code_enum
#endif

Expand All @@ -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 <compare>
#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 <span>
#endif
4 changes: 2 additions & 2 deletions snippets/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <expected>
# endif
# define VULKAN_HPP_EXPECTED std::expected
Expand Down
4 changes: 4 additions & 0 deletions vulkan/vulkan.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

module;

#if defined( __cpp_lib_modules )
# define VULKAN_HPP_ENABLE_STD_MODULE
#endif

#include <vulkan/vulkan.hpp>
#include <vulkan/vulkan_extension_inspection.hpp>
#include <vulkan/vulkan_format_traits.hpp>
Expand Down
14 changes: 7 additions & 7 deletions vulkan/vulkan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <vulkan/vulkan_hpp_macros.hpp>

#if !defined( VULKAN_HPP_STD_MODULE )
#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) )
# include <algorithm>
# include <array> // ArrayWrapperND
# include <string.h> // strnlen
Expand All @@ -22,16 +22,16 @@ import VULKAN_HPP_STD_COMPAT_MODULE;
#endif
#include <vulkan/vulkan.h>

#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 <string_view>
#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 <tuple> // std::tie
# include <vector> // 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 <system_error> // std::is_error_code_enum
#endif

Expand All @@ -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 <compare>
#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 <span>
#endif

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions vulkan/vulkan_hpp_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <expected>
# endif
# define VULKAN_HPP_EXPECTED std::expected
Expand Down

0 comments on commit 339a2b8

Please sign in to comment.