Skip to content

Commit 0fa3cf3

Browse files
committed
add more NBL_API2 for some classes and update builtin resource generation python scripts - make their sources be independent of Nabla's NBL_API2. Update builtin CMake utils
1 parent e73e0af commit 0fa3cf3

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

include/nbl/system/CFileViewVirtualAllocatorWin32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace nbl::system
55
{
66
#ifdef _NBL_PLATFORM_WINDOWS_
7-
class CFileViewVirtualAllocatorWin32 : public IFileViewAllocator
7+
class NBL_API2 CFileViewVirtualAllocatorWin32 : public IFileViewAllocator
88
{
99
public:
1010
using IFileViewAllocator::IFileViewAllocator;

include/nbl/system/IFileArchive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace nbl::system
2121
class IFile;
2222

2323
//! The FileArchive manages archives and provides access to files inside them.
24-
class IFileArchive : public core::IReferenceCounted
24+
class NBL_API2 IFileArchive : public core::IReferenceCounted
2525
{
2626
public:
2727
enum E_ALLOCATOR_TYPE

src/nbl/builtin/builtinHeaderGen.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
resourcesFile = sys.argv[3]
1919
resourcesNamespace = sys.argv[4]
2020
guardSuffix = sys.argv[5]
21-
isSharedLibrary = sys.argv[6]
21+
isSharedLibrary = True if sys.argv[6] == "True" else False
2222

2323
file = open(resourcesFile, 'r')
2424
resourcePaths = file.readlines()
@@ -37,19 +37,25 @@
3737
if isSharedLibrary:
3838
outp.write("#if defined(__NBL_BUILDING_TARGET__) // currently compiling the target, this define is passed through the commandline\n")
3939
outp.write("#if defined(_MSC_VER)\n")
40-
outp.write("#define NBL_API2 __declspec(dllexport)\n")
40+
outp.write("#define BR_API __declspec(dllexport)\n")
4141
outp.write("#elif defined(__GNUC__)\n")
42-
outp.write('#define NBL_API2 __attribute__ ((visibility ("default")))' + "\n")
42+
outp.write('#define BR_API __attribute__ ((visibility ("default")))' + "\n")
4343
outp.write("#endif\n")
4444
outp.write("#else\n")
4545
outp.write("#if defined(_MSC_VER)\n")
46-
outp.write("#define NBL_API2 __declspec(dllimport)\n")
46+
outp.write("#define BR_API __declspec(dllimport)\n")
4747
outp.write("#else\n")
48-
outp.write("#define NBL_API2\n")
48+
outp.write("#define BR_API\n")
4949
outp.write("#endif\n")
5050
outp.write("#endif\n\n")
5151

5252
outp.write("namespace " + resourcesNamespace + " { \n")
53+
54+
if isSharedLibrary:
55+
outp.write("\t\tBR_API std::pair<const uint8_t*, size_t> get_resource_runtime(const std::string& filename);\n\n")
56+
else:
57+
outp.write("\t\tstd::pair<const uint8_t*, size_t> get_resource_runtime(const std::string& filename);\n\n")
58+
5359
outp.write("\t\ttemplate<nbl::core::StringLiteral Path>\n")
5460
outp.write("\t\tconst std::pair<const uint8_t*, size_t> get_resource();\n")
5561

@@ -59,14 +65,14 @@
5965
x = itemData[0].rstrip()
6066

6167
if isSharedLibrary:
62-
outp.write('\n\t\ttemplate<> NBL_API2 const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % x)
68+
outp.write('\n\t\ttemplate<> BR_API const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % x)
6369
else:
6470
outp.write('\n\t\ttemplate<> const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % x)
6571

6672
if len(itemData) > 1:
6773
for i in range(1, len(itemData)):
6874
if isSharedLibrary:
69-
outp.write('\n\t\ttemplate<> NBL_API2 const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % itemData[i].rstrip())
75+
outp.write('\n\t\ttemplate<> BR_API const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % itemData[i].rstrip())
7076
else:
7177
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())
7278

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ namespace @_NAMESPACE_@
88
{
99
constexpr std::string_view pathPrefix = "@_BUNDLE_ARCHIVE_ABSOLUTE_PATH_@";
1010
constexpr bool hasPathPrefix(std::string_view str) { return str.find(pathPrefix) == 0ull; }
11-
12-
std::pair<const uint8_t*, size_t> get_resource_runtime(const std::string& filename);
1311

1412
class CArchive final : public nbl::system::CFileArchive
1513
{

src/nbl/builtin/utils.cmake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH
4545
if(NOT DEFINED _Python3_EXECUTABLE)
4646
message(FATAL_ERROR "_Python3_EXECUTABLE must be defined - call find_package(Python3 COMPONENTS Interpreter REQUIRED)")
4747
endif()
48+
49+
if("${ARGV7}" STREQUAL "SHARED")
50+
set(_LIB_TYPE_ SHARED)
51+
set(_SHARED_ True)
52+
else()
53+
set(_LIB_TYPE_ STATIC)
54+
set(_SHARED_ False)
55+
endif()
4856

4957
set(NBL_TEMPLATE_RESOURCES_ARCHIVE_HEADER "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/CArchive.h.in")
5058
set(NBL_BUILTIN_HEADER_GEN_PY "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/builtinHeaderGen.py")
@@ -115,14 +123,6 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH
115123

116124
set(NBL_BUILTIN_RESOURCES_HEADER "${_OUTPUT_HEADER_DIRECTORY_}/${NBL_BS_HEADER_FILENAME}")
117125
set(NBL_BUILTIN_RESOURCE_DATA_SOURCE "${_OUTPUT_SOURCE_DIRECTORY_}/${NBL_BS_DATA_SOURCE_FILENAME}")
118-
119-
if("${ARGV7}" STREQUAL "SHARED")
120-
set(_LIB_TYPE_ SHARED)
121-
set(_SHARED_ True)
122-
else()
123-
set(_LIB_TYPE_ STATIC)
124-
set(_SHARED_ False)
125-
endif()
126126

127127
add_custom_command(
128128
OUTPUT "${NBL_BUILTIN_RESOURCES_HEADER}" "${NBL_BUILTIN_RESOURCE_DATA_SOURCE}"

0 commit comments

Comments
 (0)