Skip to content

Commit 57a69bd

Browse files
Merge pull request #500 from Devsh-Graphics-Programming/sharedBR
Make SHARED builtin-resources builds work
2 parents e36e9b7 + eb338d4 commit 57a69bd

File tree

7 files changed

+34
-6
lines changed

7 files changed

+34
-6
lines changed

include/nbl/system/CFileArchive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class CInnerArchiveFile : public CFileView<T>
6868

6969

7070
//!
71-
class CFileArchive : public IFileArchive
71+
class NBL_API2 CFileArchive : public IFileArchive
7272
{
7373
static inline constexpr size_t SIZEOF_INNER_ARCHIVE_FILE = std::max(sizeof(CInnerArchiveFile<CPlainHeapAllocator>), sizeof(CInnerArchiveFile<VirtualMemoryAllocator>));
7474
static inline constexpr size_t ALIGNOF_INNER_ARCHIVE_FILE = std::max(alignof(CInnerArchiveFile<CPlainHeapAllocator>), alignof(CInnerArchiveFile<VirtualMemoryAllocator>));

include/nbl/system/atomic_state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _NBL_SYSTEM_ATOMIC_STATE_H_INCLUDED_
33

44
#include <atomic>
5+
#include "assert.h"
56

67
namespace nbl::system
78
{

src/nbl/builtin/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,6 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/blit/normalization/shared_nor
240240
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/line.hlsl")
241241

242242
macro(NBL_ADD_BUILTIN_RESOURCES _TARGET_) # internal & Nabla only, must be added with the macro to properly propagate scope
243-
ADD_CUSTOM_BUILTIN_RESOURCES("${_TARGET_}" NBL_RESOURCES_TO_EMBED "${NBL_ROOT_PATH}/include" "nbl/builtin" "nbl::builtin" "${NBL_ROOT_PATH_BINARY}/include" "${NBL_ROOT_PATH_BINARY}/src")
243+
ADD_CUSTOM_BUILTIN_RESOURCES("${_TARGET_}" NBL_RESOURCES_TO_EMBED "${NBL_ROOT_PATH}/include" "nbl/builtin" "nbl::builtin" "${NBL_ROOT_PATH_BINARY}/include" "${NBL_ROOT_PATH_BINARY}/src" "STATIC" "INTERNAL")
244244
endmacro()
245245

src/nbl/builtin/builtinHeaderGen.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828

2929
outp.write("#ifndef _" + guardSuffix + "_BUILTINRESOURCEDATA_H_\n")
3030
outp.write("#define _" + guardSuffix + "_BUILTINRESOURCEDATA_H_\n")
31+
32+
outp.write("#ifdef __INTELLISENSE__\n")
33+
outp.write("#include <codeanalysis\warnings.h>\n")
34+
outp.write("#pragma warning( push )\n")
35+
outp.write("#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )\n")
36+
outp.write("#endif // __INTELLISENSE__\n")
37+
3138
outp.write("#include <stdlib.h>\n")
3239
outp.write("#include <cstdint>\n")
3340
outp.write("#include <string>\n")
@@ -76,7 +83,12 @@
7683
else:
7784
outp.write('\n\t\ttemplate<> const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % itemData[i].rstrip())
7885

79-
outp.write("\n\t}")
80-
outp.write("\n#endif // _" + guardSuffix + "_BUILTINRESOURCEDATA_H_")
86+
outp.write("\n\t}\n")
87+
88+
outp.write("#ifdef __INTELLISENSE__\n")
89+
outp.write("#pragma warning( pop )\n")
90+
outp.write("#endif // __INTELLISENSE__\n")
91+
92+
outp.write("#endif // _" + guardSuffix + "_BUILTINRESOURCEDATA_H_")
8193

8294
outp.close()

src/nbl/builtin/template/CArchive.h.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
#define _@_GUARD_SUFFIX_@_C_ARCHIVE_H_
33

44
#include "nbl/system/CFileArchive.h"
5+
#include "nbl/core/def/smart_refctd_ptr.h"
56
#include "@NBL_BS_HEADER_FILENAME@"
67

78
namespace @_NAMESPACE_@
89
{
910
constexpr std::string_view pathPrefix = "@_BUNDLE_ARCHIVE_ABSOLUTE_PATH_@";
1011
constexpr bool hasPathPrefix(std::string_view str) { return str.find(pathPrefix) == 0ull; }
1112

12-
class @_NBL_BR_API_@ CArchive final : public nbl::system::CFileArchive
13+
class @NBL_BR_API@ CArchive final : public nbl::system::CFileArchive
1314
{
1415
public:
1516
CArchive(nbl::system::logger_opt_smart_ptr&& logger);

src/nbl/builtin/utils.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH
5555
set(_SHARED_ False)
5656
unset(NBL_BR_API)
5757
endif()
58+
59+
if("${ARGV8}" STREQUAL "INTERNAL")
60+
set(_NBL_INTERNAL_BR_CREATION_ ON)
61+
else()
62+
set(_NBL_INTERNAL_BR_CREATION_ OFF)
63+
endif()
5864

5965
set(NBL_TEMPLATE_RESOURCES_ARCHIVE_HEADER "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/CArchive.h.in")
6066
set(NBL_TEMPLATE_RESOURCES_ARCHIVE_SOURCE "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/CArchive.cpp.in")
@@ -152,6 +158,14 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH
152158

153159
if(TARGET Nabla)
154160
get_target_property(_NABLA_INCLUDE_DIRECTORIES_ Nabla INCLUDE_DIRECTORIES)
161+
162+
if(NBL_STATIC_BUILD AND _LIB_TYPE_ STREQUAL SHARED)
163+
message(FATAL_ERROR "Nabla must be built as dynamic library in order to combine this tool with SHARED setup!")
164+
endif()
165+
166+
if(NOT _NBL_INTERNAL_BR_CREATION_)
167+
target_link_libraries(${_TARGET_NAME_} Nabla) # be aware Nabla must be linked to the BRs
168+
endif()
155169
endif()
156170

157171
if(NOT DEFINED _NABLA_INCLUDE_DIRECTORIES_) # TODO, validate by populating generator expressions if any and checking whether a path to the BuildConfigOptions.h exists per config

0 commit comments

Comments
 (0)