build: create a dynamic libvulkan.so

This commit is contained in:
Danny Robson 2019-03-03 12:18:58 +11:00
parent 154e3b039b
commit 45953b9dcf
4 changed files with 26 additions and 15 deletions

View File

@ -61,7 +61,7 @@ endif()
##-----------------------------------------------------------------------------
add_library (cruft-vk-load STATIC
list (APPEND VK_LOAD_SOURCES
load/fwd.hpp
${GENERATED_PREFIX}/load/vtable.hpp
${GENERATED_PREFIX}/load/dispatch.cpp
@ -74,14 +74,23 @@ add_library (cruft-vk-load STATIC
load/vtable.cpp
)
target_include_directories (cruft-vk-load
add_library (vulkan SHARED ${VK_LOAD_SOURCES})
set_target_properties(vulkan PROPERTIES VERSION 1.1.98)
set_target_properties(vulkan PROPERTIES SOVERSION 1)
add_library (cruft-vk-load STATIC ${VK_LOAD_SOURCES})
foreach (lib vulkan cruft-vk-load)
target_include_directories (${lib}
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/specs/include/vulkan"
)
)
target_link_libraries (cruft-vk-load cruft-json cruft)
target_link_libraries (${lib} cruft-json cruft)
endforeach ()
###############################################################################
list (APPEND sources
@ -189,9 +198,11 @@ foreach (t info hello)
set_target_properties(vk_${t} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}/tools")
target_link_libraries (vk_${t} cruft-vk glfw)
endforeach ()
target_link_libraries (vk_info cruft-vk cruft-vk-load)
target_link_libraries (vk_hello cruft-vk glfw)
##-----------------------------------------------------------------------------
add_dependencies (vk_hello hello.vert.spv hello.frag.spv)

View File

@ -13,5 +13,5 @@
#include <iosfwd>
namespace cruft::vk::load {
std::ostream& operator<< (std::ostream&, icd_t const&);
std::ostream& operator<< [[gnu::visibility("default")]] (std::ostream&, icd_t const&);
}

View File

@ -22,7 +22,7 @@ namespace cruft::vk::load {
std::vector<icd_t>
enumerate (void);
enumerate [[gnu::visibility("default")]] (void);
struct vendor_table {
@ -31,7 +31,7 @@ namespace cruft::vk::load {
void* (*vk_icdGetPhysicalDeviceProcAddr) (VkInstance, char const*) = nullptr;
};
class vendor {
class [[gnu::visibility("default")]] vendor {
public:
vendor (icd_t const&);
vendor (::cruft::library &&);

View File

@ -429,7 +429,7 @@ class Command(Type):
return f"{{ name: '{self.name}', result: '{self.result}', param: {self.params} }}"
def declare(self):
return 'extern "C" %(result)s %(name)s (%(params)s) noexcept;' % {
return 'extern "C" %(result)s %(name)s [[gnu::visibility("default")]] (%(params)s) noexcept;' % {
'name': rename(self.name),
'result': self.result,
'params': ", ".join(p.param for p in self.params)
@ -837,8 +837,8 @@ def write_load(dst: TextIO, q: List[Type], reg: Registry):
dst.write("""
struct vendor_table;
extern cruft::vk::load::vendor_table const *v_table;
extern cruft::vk::load::instance_table const *i_table;
extern cruft::vk::load::vendor_table const *v_table [[gnu::visibility("default")]];
extern cruft::vk::load::instance_table const *i_table [[gnu::visibility("default")]];
}
""")