Skip to content

Commit 1917ce9

Browse files
committed
add more validation for builtin resources, do not allow static nabla and dynamic BRs. Mute IntelliSense warnings in builtin resources header by turning off all of it's warnings
1 parent 4e95000 commit 1917ce9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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 _WIN32 // Visual Studio define\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 // _WIN32\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 _WIN32\n")
89+
outp.write("#pragma warning( pop )\n")
90+
outp.write("#endif // _WIN32\n")
91+
92+
outp.write("#endif // _" + guardSuffix + "_BUILTINRESOURCEDATA_H_")
8193

8294
outp.close()

src/nbl/builtin/utils.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH
159159
if(TARGET Nabla)
160160
get_target_property(_NABLA_INCLUDE_DIRECTORIES_ Nabla INCLUDE_DIRECTORIES)
161161

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+
162166
if(NOT _NBL_INTERNAL_BR_CREATION_)
163167
target_link_libraries(${_TARGET_NAME_} Nabla) # be aware Nabla must be linked to the BRs
164168
endif()

0 commit comments

Comments
 (0)