Skip to content

Commit b6d5e30

Browse files
committed
move some code from common.h to autogenerated CArchive.h, update src/nbl/CMakeLists.txt with builtin python generation, update some source files, introduce Nabla internal NBL_BUILTIN_RESOURCES_DIRECTORY_PATH, add CArchive.h.in file
1 parent a4b32c6 commit b6d5e30

File tree

12 files changed

+60
-58
lines changed

12 files changed

+60
-58
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ endif()
5555

5656
get_filename_component(NBL_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
5757
get_filename_component(NBL_ROOT_PATH_BINARY "${CMAKE_CURRENT_BINARY_DIR}" ABSOLUTE)
58+
set(NBL_BUILTIN_RESOURCES_DIRECTORY_PATH "${NBL_ROOT_PATH}/include")
5859

5960
# Configure CCache if available
6061
find_program(CCACHE_FOUND ccache)

include/nbl/builtin/common.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,9 @@
1616

1717
namespace nbl::builtin
1818
{
19-
20-
constexpr std::string_view PathPrefix = "nbl/builtin/";
21-
constexpr bool hasPathPrefix(std::string_view str) { return str.find(PathPrefix) == 0ull; }
2219

2320
// if you attempt to use this without `NBL_EMBED_BUILTIN_RESOURCES_` CMake option, this will always return `{nullptr,0ull}`
2421
std::pair<const uint8_t*,size_t> get_resource_runtime(const std::string&);
2522

26-
#ifndef _NBL_EMBED_BUILTIN_RESOURCES_
27-
#define _NBL_BUILTIN_PATH_AVAILABLE
28-
constexpr std::string_view getBuiltinResourcesDirectoryPath()
29-
{
30-
std::string_view retval = __FILE__;
31-
retval.remove_suffix(PathPrefix.size()+std::string_view("common.h").size());
32-
return retval;
33-
}
34-
#endif
35-
3623
}
3724
#endif

include/nbl/config/BuildConfigOptions.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
#endif
7878
#endif
7979

80+
#define NBL_BUILTIN_RESOURCES_DIRECTORY_PATH "@NBL_BUILTIN_RESOURCES_DIRECTORY_PATH@"
81+
8082
// DDL exports
8183
#cmakedefine _NBL_SHARED_BUILD_
8284
#ifdef _NBL_SHARED_BUILD_

include/nbl/system/ISystem.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ class NBL_API2 ISystem : public core::IReferenceCounted
8383
void handle_request(SRequestType& req, SRequestParams_WRITE& param);
8484
core::smart_refctd_ptr<ICaller> m_caller;
8585
};
86+
87+
#ifndef _NBL_EMBED_BUILTIN_RESOURCES_
88+
constexpr std::string_view getBuiltinResourcesDirectoryPath()
89+
{
90+
std::string_view retval = NBL_BUILTIN_RESOURCES_DIRECTORY_PATH;
91+
return retval;
92+
}
93+
#endif
94+
8695
friend class ISystemFile;
8796
CAsyncQueue m_dispatcher;
8897

src/nbl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ set(NABLA_HEADERS "${NBL_ROOT_PATH}/include/nabla.h" ${NABLA_HEADERS_PUBLIC} ${N
364364
set(NBL_LIBRARY_CREATION_SOURCES
365365
${NABLA_SRCS_COMMON}
366366
${NABLA_HEADERS}
367+
${_NBL_BUILTIN_RESOURCES_ARCHIVE_APK_SOURCES_}
367368
$<TARGET_OBJECTS:aesGladman>
368369
$<TARGET_OBJECTS:bzip2>
369370
$<TARGET_OBJECTS:lz4>

src/nbl/asset/utils/CGLSLCompiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
// For conditions of distribution and use, see copyright notice in nabla.h
44
#include "nbl/asset/utils/CGLSLCompiler.h"
55
#include "nbl/asset/utils/shadercUtils.h"
6+
#include "nbl/builtin/CArchive.h"
67

78
#include <sstream>
89
#include <regex>
910
#include <iterator>
1011

11-
1212
using namespace nbl;
1313
using namespace nbl::asset;
1414

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// For conditions of distribution and use, see copyright notice in nabla.h
44
#include "nbl/asset/utils/CHLSLCompiler.h"
55
#include "nbl/asset/utils/shadercUtils.h"
6+
#include "nbl/builtin/CArchive.h"
67

78
#include <wrl.h>
89
#include <combaseapi.h>

src/nbl/builtin/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "nbl/builtin/glsl/blit/normalizatio
247247
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "nbl/builtin/glsl/blit/normalization/shared_normalization.glsl")
248248

249249
function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH_DIRECTORY_ _NAMESPACE_ _OUTPUT_DIRECTORY_)
250-
set(NBL_TEMPLATE_APK_RESOURCES_ARCHIVE_SOURCE "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/CAPKResourcesArchieve.cpp.in")
251-
set(NBL_TEMPLATE_APK_RESOURCES_ARCHIVE_HEADER "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/CAPKResourcesArchieve.h.in")
250+
set(NBL_TEMPLATE_APK_RESOURCES_ARCHIVE_HEADER "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/CArchive.h.in")
252251
set(NBL_BUILTIN_HEADER_GEN_PY "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/builtinHeaderGen.py")
253252
set(NBL_BUILTIN_DATA_GEN_PY "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/builtinDataGen.py")
254253

@@ -266,16 +265,15 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH
266265
list(APPEND NBL_DEPENDENCY_FILES "${_BUNDLE_SEARCH_DIRECTORY_}/${_CURRENT_PATH_}")
267266
file(SIZE "${_BUNDLE_SEARCH_DIRECTORY_}/${_CURRENT_PATH_}" _FILE_SIZE_)
268267

269-
string(APPEND _RESOURCES_INIT_LIST_ "\t\t{\"${_CURRENT_PATH_}\", ${_FILE_SIZE_}, 0xdeadbeefu, ${_ITR_}, EAT_NULL},\n") # initializer list
268+
string(APPEND _RESOURCES_INIT_LIST_ "\t\t\t\t\t{\"${_CURRENT_PATH_}\", ${_FILE_SIZE_}, 0xdeadbeefu, ${_ITR_}, nbl::system::IFileArchive::E_ALLOCATOR_TYPE::EAT_NULL},\n") # initializer list
270269
else()
271270
message(FATAL_ERROR "!") # TODO: set GENERATED property, therefore we could turn some input into output and list it as builtin resource
272271
endif()
273272

274273
math(EXPR _ITR_ "${_ITR_} + 1")
275274
endforeach()
276275

277-
configure_file("${NBL_TEMPLATE_APK_RESOURCES_ARCHIVE_SOURCE}" "${_OUTPUT_DIRECTORY_}/CAPKResourcesArchieve.cpp")
278-
configure_file("${NBL_TEMPLATE_APK_RESOURCES_ARCHIVE_HEADER}" "${_OUTPUT_DIRECTORY_}/CAPKResourcesArchieve.h")
276+
configure_file("${NBL_TEMPLATE_APK_RESOURCES_ARCHIVE_HEADER}" "${_OUTPUT_DIRECTORY_}/CArchive.h")
279277

280278
list(APPEND NBL_DEPENDENCY_FILES "${NBL_BUILTIN_HEADER_GEN_PY}")
281279
list(APPEND NBL_DEPENDENCY_FILES "${NBL_BUILTIN_DATA_GEN_PY}")
@@ -317,6 +315,9 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH
317315
set_property(TARGET ${_TARGET_NAME_} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
318316
endif()
319317

318+
list(APPEND _NBL_BUILTIN_RESOURCES_ARCHIVE_APK_SOURCES_ "${_OUTPUT_DIRECTORY_}/CArchive.h")
319+
set(_NBL_BUILTIN_RESOURCES_ARCHIVE_APK_SOURCES_ ${_NBL_BUILTIN_RESOURCES_ARCHIVE_APK_SOURCES_} PARENT_SCOPE)
320+
320321
list(APPEND _NBL_BUILTIN_RESOURCES_LIBRARIES_ ${_TARGET_NAME_})
321322
set(_NBL_BUILTIN_RESOURCES_LIBRARIES_ ${_NBL_BUILTIN_RESOURCES_LIBRARIES_} PARENT_SCOPE) # override
322323
endfunction()

src/nbl/builtin/template/CAPKResourcesArchieve.cpp.in

Lines changed: 0 additions & 14 deletions
This file was deleted.

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

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)