Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd237207d4 | ||
|
|
20893d1bf3 | ||
|
|
3ef1013b85 | ||
|
|
ff70dc685d |
No files matched your search
+46
-1
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 4.0.0)
|
cmake_minimum_required(VERSION 4.0.0)
|
||||||
project(Void VERSION 1.2.0 LANGUAGES CXX)
|
project(Void VERSION 1.2.1 LANGUAGES CXX)
|
||||||
if(PROJECT_IS_TOP_LEVEL)
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
option(BUILD_SHARED_LIBS "Build Void modules as shared libraries" ON)
|
option(BUILD_SHARED_LIBS "Build Void modules as shared libraries" ON)
|
||||||
elseif(NOT DEFINED BUILD_SHARED_LIBS)
|
elseif(NOT DEFINED BUILD_SHARED_LIBS)
|
||||||
@@ -30,8 +30,47 @@ set(EXPORT_SET_NAME ${PROJECT_NAME}Targets)
|
|||||||
|
|
||||||
include(cmake/Module.cmake)
|
include(cmake/Module.cmake)
|
||||||
|
|
||||||
|
# Modules to configure, with the modules they need (INTERNAL_DEPS, followed
|
||||||
|
# transitively); empty configures every module. OPTIONAL_DEPS are used only
|
||||||
|
# when named too. A project that embeds Void selects what it links, so the
|
||||||
|
# external packages of modules it never builds (LibArchive, OpenSSL, SQLite,
|
||||||
|
# libsodium) need not exist, as when cross-compiling.
|
||||||
|
set(VOID_ENABLED_MODULES "" CACHE STRING
|
||||||
|
"Void modules to configure (and their internal dependencies); empty for all")
|
||||||
|
set(_void_selected "")
|
||||||
|
if(VOID_ENABLED_MODULES)
|
||||||
|
set(_void_pending ${VOID_ENABLED_MODULES})
|
||||||
|
while(_void_pending)
|
||||||
|
list(POP_FRONT _void_pending _void_module)
|
||||||
|
if(_void_module IN_LIST _void_selected)
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
set(_void_module_file "${CMAKE_CURRENT_SOURCE_DIR}/src/${_void_module}/module.cmake")
|
||||||
|
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/${_void_module}")
|
||||||
|
message(FATAL_ERROR "[Void] VOID_ENABLED_MODULES names an unknown module '${_void_module}'")
|
||||||
|
endif()
|
||||||
|
list(APPEND _void_selected ${_void_module})
|
||||||
|
if(EXISTS "${_void_module_file}")
|
||||||
|
file(READ "${_void_module_file}" _void_text)
|
||||||
|
# The words after INTERNAL_DEPS up to the next keyword or ')'.
|
||||||
|
if(_void_text MATCHES "INTERNAL_DEPS([^)]*)")
|
||||||
|
separate_arguments(_void_words UNIX_COMMAND "${CMAKE_MATCH_1}")
|
||||||
|
foreach(_void_word IN LISTS _void_words)
|
||||||
|
if(_void_word MATCHES "^[A-Z0-9_]+$")
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
list(APPEND _void_pending ${_void_word})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endwhile()
|
||||||
|
endif()
|
||||||
|
|
||||||
file(GLOB children RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/*)
|
file(GLOB children RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/*)
|
||||||
foreach(module_path ${children})
|
foreach(module_path ${children})
|
||||||
|
if(_void_selected AND NOT module_path IN_LIST _void_selected)
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/${module_path})
|
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/${module_path})
|
||||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/${module_path}/module.cmake)
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/${module_path}/module.cmake)
|
||||||
include(src/${module_path}/module.cmake)
|
include(src/${module_path}/module.cmake)
|
||||||
@@ -71,6 +110,12 @@ configure_package_config_file(
|
|||||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Support headers shared by several modules (e.g. Void/Detail/Enum.hpp, used by
|
||||||
|
# Core, Log, Configuration and Data). They belong to no module's FILE_SET, so
|
||||||
|
# they are installed here; every module's install include dir covers them.
|
||||||
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/Void/Detail"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/Void")
|
||||||
|
|
||||||
install(EXPORT ${EXPORT_SET_NAME}
|
install(EXPORT ${EXPORT_SET_NAME}
|
||||||
NAMESPACE ${PROJECT_NAME}::
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||||
|
|||||||
@@ -13,10 +13,11 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
// ── Void::Log — the emission facade
|
// ── Void::Log — the emission facade
|
||||||
// ─────────────────────────────────────────── Header-only so every module
|
// ─────────────────────────────────────────── Header-only apart from its
|
||||||
// (including INTERFACE libraries) can log with zero link dependencies. The full
|
// state, which Void::LogState (a small library with no dependencies) holds
|
||||||
// sink framework lives in Void::Logging (Logger.hpp); bridge with
|
// once per process, so every module (including INTERFACE libraries) can log by
|
||||||
// Void/Log/LoggingAdapter.hpp.
|
// linking only that. The full sink framework lives in Void::Logging
|
||||||
|
// (Logger.hpp); bridge with Void/Log/LoggingAdapter.hpp.
|
||||||
//
|
//
|
||||||
// Integration contract:
|
// Integration contract:
|
||||||
// * No sink installed (the default) — every call is a single relaxed
|
// * No sink installed (the default) — every call is a single relaxed
|
||||||
@@ -85,11 +86,9 @@ namespace Void::Log
|
|||||||
std::shared_mutex mutex;
|
std::shared_mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline State& state()
|
// The process's one State, defined in Void::LogState (a static in an
|
||||||
{
|
// inline function would be one per DLL on Windows).
|
||||||
static State s;
|
State& state();
|
||||||
return s;
|
|
||||||
}
|
|
||||||
} // namespace Detail
|
} // namespace Detail
|
||||||
|
|
||||||
/// Install the global sink. Any previously installed sink is replaced.
|
/// Install the global sink. Any previously installed sink is replaced.
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
void_add_module(Async)
|
void_add_module(Async
|
||||||
|
INTERNAL_DEPS LogState
|
||||||
|
)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// The Void::Log facade's one state per process. Compiled into its own small
|
||||||
|
// library rather than an inline function's static: Windows gives every DLL
|
||||||
|
// that inlines a function its own static, so a sink set in one DLL would
|
||||||
|
// never see the events of another. Every module that includes
|
||||||
|
// <Void/Log/Log.hpp> links this (it has no dependencies of its own).
|
||||||
|
#include <Void/Log/Log.hpp>
|
||||||
|
|
||||||
|
namespace Void::Log::Detail
|
||||||
|
{
|
||||||
|
State& state()
|
||||||
|
{
|
||||||
|
static State s;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
} // namespace Void::Log::Detail
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
void_add_module(LogState)
|
||||||
@@ -5,7 +5,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
void_add_module(Stacktrace
|
void_add_module(Stacktrace
|
||||||
INTERNAL_DEPS Functional
|
INTERNAL_DEPS Functional LogState
|
||||||
EXTERNAL_DEPS ${_void_stacktrace_target}
|
EXTERNAL_DEPS ${_void_stacktrace_target}
|
||||||
DEPS_UNIX dl
|
DEPS_UNIX dl
|
||||||
OPTIONS_UNIX -g -fno-omit-frame-pointer
|
OPTIONS_UNIX -g -fno-omit-frame-pointer
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
void_add_module(System
|
void_add_module(System
|
||||||
INTERNAL_DEPS Functional
|
INTERNAL_DEPS Functional LogState
|
||||||
EXTERNAL_DEPS Threads::Threads
|
EXTERNAL_DEPS Threads::Threads
|
||||||
)
|
)
|
||||||
@@ -47,18 +47,27 @@ static void crash_handler(int sig) {
|
|||||||
|
|
||||||
void install_signal_handlers(CrashCallback on_crash) {
|
void install_signal_handlers(CrashCallback on_crash) {
|
||||||
g_crash_callback = std::move(on_crash);
|
g_crash_callback = std::move(on_crash);
|
||||||
|
#ifdef _WIN32
|
||||||
|
// No sigaction on Windows: the C runtime's signal() covers these four.
|
||||||
|
std::signal(SIGSEGV, crash_handler); std::signal(SIGABRT, crash_handler); std::signal(SIGFPE, crash_handler); std::signal(SIGILL, crash_handler);
|
||||||
|
#else
|
||||||
struct sigaction sa{}; sa.sa_handler = crash_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0;
|
struct sigaction sa{}; sa.sa_handler = crash_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0;
|
||||||
sigaction(SIGSEGV, &sa, nullptr); sigaction(SIGABRT, &sa, nullptr); sigaction(SIGFPE, &sa, nullptr); sigaction(SIGILL, &sa, nullptr);
|
sigaction(SIGSEGV, &sa, nullptr); sigaction(SIGABRT, &sa, nullptr); sigaction(SIGFPE, &sa, nullptr); sigaction(SIGILL, &sa, nullptr);
|
||||||
#ifdef SIGBUS
|
#ifdef SIGBUS
|
||||||
sigaction(SIGBUS, &sa, nullptr);
|
sigaction(SIGBUS, &sa, nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninstall_signal_handlers() {
|
void uninstall_signal_handlers() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::signal(SIGSEGV, SIG_DFL); std::signal(SIGABRT, SIG_DFL); std::signal(SIGFPE, SIG_DFL); std::signal(SIGILL, SIG_DFL);
|
||||||
|
#else
|
||||||
struct sigaction sa{}; sa.sa_handler = SIG_DFL;
|
struct sigaction sa{}; sa.sa_handler = SIG_DFL;
|
||||||
sigaction(SIGSEGV, &sa, nullptr); sigaction(SIGABRT, &sa, nullptr); sigaction(SIGFPE, &sa, nullptr); sigaction(SIGILL, &sa, nullptr);
|
sigaction(SIGSEGV, &sa, nullptr); sigaction(SIGABRT, &sa, nullptr); sigaction(SIGFPE, &sa, nullptr); sigaction(SIGILL, &sa, nullptr);
|
||||||
#ifdef SIGBUS
|
#ifdef SIGBUS
|
||||||
sigaction(SIGBUS, &sa, nullptr);
|
sigaction(SIGBUS, &sa, nullptr);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
g_crash_callback = nullptr;
|
g_crash_callback = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
void_add_module(Testing
|
void_add_module(Testing
|
||||||
|
INTERNAL_DEPS LogState
|
||||||
OPTIONAL_DEPS Stacktrace Log Async Configuration Text
|
OPTIONAL_DEPS Stacktrace Log Async Configuration Text
|
||||||
)
|
)
|
||||||
Reference in new issue
Block a user