Skip to content

Commit 51b95d5

Browse files
authored
Merge branch 'newBuiltinResources' into bugfix/address-build-problems-builtin-linux-window
2 parents 9cfedb9 + 46b2b71 commit 51b95d5

File tree

13 files changed

+372
-282
lines changed

13 files changed

+372
-282
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)

cmake/common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE
8484

8585
target_include_directories(${EXECUTABLE_NAME}
8686
PUBLIC "${NBL_ROOT_PATH}/examples_tests/common"
87+
PUBLIC "${NBL_ROOT_PATH_BINARY}/include"
8788
PUBLIC ../../include
8889
PRIVATE ${_EXTRA_INCLUDES}
8990
)

include/nbl/builtin/common.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,14 @@
1111

1212
#include <string>
1313
#include <string_view>
14-
15-
#include "nbl/core/string/StringLiteral.h"
14+
//#include "nbl/builtin/"
15+
#include "nbl/builtin/builtinResources.h"
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "nbl/system/ICancellableAsyncQueueDispatcher.h"
1111
#include "nbl/system/IFileArchive.h"
12-
#include "nbl/builtin/builtinResources.h"
1312

1413
#include <variant>
1514

@@ -84,6 +83,15 @@ class NBL_API2 ISystem : public core::IReferenceCounted
8483
void handle_request(SRequestType& req, SRequestParams_WRITE& param);
8584
core::smart_refctd_ptr<ICaller> m_caller;
8685
};
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+
8795
friend class ISystemFile;
8896
CAsyncQueue m_dispatcher;
8997

src/nbl/CMakeLists.txt

Lines changed: 19 additions & 10 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>
@@ -411,6 +412,20 @@ if(NOT NBL_STATIC_BUILD)
411412
set_target_properties(Nabla PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${NBL_ASSEMBLY_DIRECTORY})
412413
endif()
413414

415+
if(NBL_EMBED_BUILTIN_RESOURCES)
416+
add_dependencies(Nabla ${_NBL_BUILTIN_RESOURCES_LIBRARIES_})
417+
418+
if(NBL_STATIC_BUILD)
419+
target_link_libraries(Nabla INTERFACE
420+
${_NBL_BUILTIN_RESOURCES_LIBRARIES_}
421+
)
422+
else()
423+
target_link_libraries(Nabla PRIVATE
424+
${_NBL_BUILTIN_RESOURCES_LIBRARIES_}
425+
)
426+
endif()
427+
endif()
428+
414429
## Set up 3rdparty deps
415430
# Parallel Hashmap
416431
target_include_directories(Nabla PUBLIC ${THIRD_PARTY_SOURCE_DIR}/parallel-hashmap/parallel_hashmap)
@@ -611,12 +626,6 @@ if(NBL_PCH)
611626
target_precompile_headers(Nabla PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/pch.h")
612627
endif()
613628

614-
if(NBL_EMBED_BUILTIN_RESOURCES)
615-
add_dependencies(Nabla nblBuiltinResourceData)
616-
target_link_libraries(Nabla PUBLIC nblBuiltinResourceData)
617-
target_include_directories(Nabla PUBLIC "${NBL_BUILTIN_RESOURCES_HEADER}")
618-
endif()
619-
620629
# extensions
621630
start_tracking_variables_for_propagation_to_parent()
622631
add_subdirectory(ext)
@@ -628,13 +637,13 @@ if(NOT NBL_STATIC_BUILD)
628637
COMMENT "Launching defines.h generation script!"
629638
VERBATIM
630639
)
631-
632-
add_custom_target(generate_define_header ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/generated/define.h")
633-
add_dependencies(Nabla generate_define_header)
634640
endif()
635641

636642
nbl_install_headers("${NABLA_HEADERS_PUBLIC}" "${NBL_ROOT_PATH}/include")
637-
nbl_install_file("${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/generated/define.h" "")
643+
if(NOT NBL_STATIC_BUILD)
644+
nbl_install_file("${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/generated/define.h" "")
645+
endif()
646+
nbl_install_file("${NBL_ROOT_PATH_BINARY}/include/nbl/builtin/builtinResources.h" "nbl/builtin")
638647
nbl_install_config_header(BuildConfigOptions.h)
639648

640649
# TODO: @AnastazIuk change macros to functions! https://github.com/buildaworldnet/IrrlichtBAW/issues/311

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>

0 commit comments

Comments
 (0)