write shit
This commit is contained in:
@@ -2,13 +2,20 @@ add_executable(BasaltPresenter "")
|
|||||||
target_sources(BasaltPresenter
|
target_sources(BasaltPresenter
|
||||||
PRIVATE
|
PRIVATE
|
||||||
main.cpp
|
main.cpp
|
||||||
|
dll_loader.cpp
|
||||||
|
)
|
||||||
|
target_sources(BasaltPresenter
|
||||||
|
PUBLIC
|
||||||
|
FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
dll_loader.hpp
|
||||||
)
|
)
|
||||||
target_include_directories(BasaltPresenter
|
target_include_directories(BasaltPresenter
|
||||||
PUBLIC
|
PUBLIC
|
||||||
"${CMAKE_CURRENT_LIST_DIR}"
|
"${CMAKE_CURRENT_LIST_DIR}"
|
||||||
)
|
)
|
||||||
# target_link_libraries(YYCCTest
|
target_link_libraries(BasaltPresenter
|
||||||
# PRIVATE
|
PRIVATE
|
||||||
# BasaltShared
|
BasaltShared
|
||||||
# )
|
)
|
||||||
|
|
||||||
|
|||||||
30
BasaltPresenter/Presenter/dll_loader.cpp
Normal file
30
BasaltPresenter/Presenter/dll_loader.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include "dll_loader.hpp"
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace Basalt::Presenter {
|
||||||
|
|
||||||
|
DllLoader::DllLoader(DllKind kind, const std::basic_string_view<BSCHAR> filename) {
|
||||||
|
// TODO:
|
||||||
|
// Add current executable location supports.
|
||||||
|
// Add sub directories supports.
|
||||||
|
// Fix file name terminal error.
|
||||||
|
#if defined(BASALT_OS_WINDOWS)
|
||||||
|
m_Handle = LoadLibraryW(filename.data());
|
||||||
|
#else
|
||||||
|
m_Handle = dlopen(filename.data(), RTLD_LAZY);
|
||||||
|
#endif
|
||||||
|
if (!m_Handle)
|
||||||
|
throw std::runtime_error("can not load given dynamic library.");
|
||||||
|
}
|
||||||
|
|
||||||
|
DllLoader::~DllLoader() {
|
||||||
|
if (m_Handle) {
|
||||||
|
#if defined(BASALT_OS_WINDOWS)
|
||||||
|
FreeLibrary(m_Handle);
|
||||||
|
#else
|
||||||
|
dlclose(m_Handle);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Basalt::Presenter
|
||||||
35
BasaltPresenter/Presenter/dll_loader.hpp
Normal file
35
BasaltPresenter/Presenter/dll_loader.hpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include <basalt_char.hpp>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
#if defined(BASALT_OS_WINDOWS)
|
||||||
|
#include <Windows.h>
|
||||||
|
#else
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Basalt::Presenter {
|
||||||
|
|
||||||
|
enum class DllKind {
|
||||||
|
RenderEngine,
|
||||||
|
DataDeliver,
|
||||||
|
ObjectLoader,
|
||||||
|
AnimationLoader,
|
||||||
|
};
|
||||||
|
|
||||||
|
class DllLoader {
|
||||||
|
public:
|
||||||
|
#if defined(BASALT_OS_WINDOWS)
|
||||||
|
using Handle = HMODULE;
|
||||||
|
#else
|
||||||
|
using Handle = void *;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
DllLoader(DllKind kind, const std::basic_string_view<BSCHAR> filename);
|
||||||
|
~DllLoader();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Handle m_Handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Basalt::Presenter
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
add_library(BasaltShared STATIC "")
|
||||||
|
target_sources(BasaltShared
|
||||||
|
PRIVATE
|
||||||
|
pipe_sender.cpp
|
||||||
|
)
|
||||||
|
target_sources(BasaltShared
|
||||||
|
PUBLIC
|
||||||
|
FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
# Headers
|
||||||
|
basalt_char.hpp
|
||||||
|
pipe_sender.hpp
|
||||||
|
)
|
||||||
|
target_include_directories(BasaltShared
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
|
||||||
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
|
)
|
||||||
|
# target_link_libraries(BasaltShared
|
||||||
|
# PRIVATE
|
||||||
|
# BasaltShared
|
||||||
|
# )
|
||||||
|
target_compile_definitions(BasaltShared
|
||||||
|
PUBLIC
|
||||||
|
$<$<PLATFORM_ID:Windows>:BASALT_OS_WINDOWS>
|
||||||
|
$<$<NOT:$<PLATFORM_ID:Windows>>:BASALT_OS_POSIX>
|
||||||
|
|
||||||
|
PUBLIC
|
||||||
|
# Use Unicode charset on MSVC
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:UNICODE>
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:_UNICODE>
|
||||||
|
# Fix MSVC shit
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_DEPRECATE>
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_WARNINGS>
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_DEPRECATE>
|
||||||
|
# Fix Windows header file shit
|
||||||
|
$<$<BOOL:${WIN32}>:WIN32_LEAN_AND_MEAN>
|
||||||
|
$<$<BOOL:${WIN32}>:NOMINMAX>
|
||||||
|
)
|
||||||
|
target_compile_options(BasaltShared
|
||||||
|
PUBLIC
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:/Zc:preprocessor>
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS BasaltShared
|
||||||
|
EXPORT BasaltSharedTargets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|||||||
10
BasaltPresenter/Shared/basalt_char.hpp
Normal file
10
BasaltPresenter/Shared/basalt_char.hpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include <cwchar>
|
||||||
|
|
||||||
|
#if defined(BASALT_OS_WINDOWS)
|
||||||
|
#define BSCHAR wchar_t
|
||||||
|
#define _BSTEXT(x) L##x
|
||||||
|
#define BSTEXT(x) _BSTEXT(x)
|
||||||
|
#else
|
||||||
|
#define BSCHAR char
|
||||||
|
#define BSTEXT(x) x
|
||||||
|
#endif
|
||||||
9
BasaltPresenter/Shared/pipe_sender.cpp
Normal file
9
BasaltPresenter/Shared/pipe_sender.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include "pipe_sender.hpp"
|
||||||
|
|
||||||
|
namespace Basalt::Shared {
|
||||||
|
|
||||||
|
PipeSender::PipeSender(PipeSenderKind kind) {}
|
||||||
|
|
||||||
|
PipeSender::~PipeSender() {}
|
||||||
|
|
||||||
|
}
|
||||||
19
BasaltPresenter/Shared/pipe_sender.hpp
Normal file
19
BasaltPresenter/Shared/pipe_sender.hpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
namespace Basalt::Shared {
|
||||||
|
|
||||||
|
enum class PipeSenderKind {
|
||||||
|
Data,
|
||||||
|
Command
|
||||||
|
};
|
||||||
|
|
||||||
|
class PipeSender {
|
||||||
|
public:
|
||||||
|
PipeSender(PipeSenderKind kind);
|
||||||
|
~PipeSender();
|
||||||
|
|
||||||
|
private:
|
||||||
|
PipeSenderKind kind;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user