Compare commits
3 Commits
fix/mktime
...
feat/add_s
Author | SHA1 | Date | |
---|---|---|---|
f8195b2cdd | |||
b6be1a6397 | |||
6bae6cdc87 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ build/
|
|||||||
compile_commands.json
|
compile_commands.json
|
||||||
.gdb_history
|
.gdb_history
|
||||||
.cmake.conf
|
.cmake.conf
|
||||||
|
third_party/
|
||||||
|
@ -173,12 +173,13 @@ if((NOT TILE_HAVE_GETIFADDRS) OR (NOT TILE_HAVE_FREEIFADDRS))
|
|||||||
list(APPEND TILE_SRCS "tile/base/net/detail/android/ifaddrs.c")
|
list(APPEND TILE_SRCS "tile/base/net/detail/android/ifaddrs.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(tile SHARED ${TILE_SRCS})
|
if(TILE_BUILD_SHARED)
|
||||||
add_library(tile_static STATIC ${TILE_SRCS})
|
add_library(tile SHARED ${TILE_SRCS})
|
||||||
|
else()
|
||||||
|
add_library(tile STATIC ${TILE_SRCS})
|
||||||
|
endif()
|
||||||
set_target_properties(tile PROPERTIES VERSION ${PROJECT_VERSION}
|
set_target_properties(tile PROPERTIES VERSION ${PROJECT_VERSION}
|
||||||
SOVERSION ${PROJECT_VERSION_MAJOR})
|
SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||||
set_target_properties(tile_static PROPERTIES VERSION ${PROJECT_VERSION}
|
|
||||||
SOVERSION ${PROJECT_VERSION_MAJOR})
|
|
||||||
|
|
||||||
target_precompile_headers(
|
target_precompile_headers(
|
||||||
tile
|
tile
|
||||||
@ -189,16 +190,7 @@ target_precompile_headers(
|
|||||||
# ${CMAKE_CURRENT_SOURCE_DIR}/third_party/inja/inja/string_view.h
|
# ${CMAKE_CURRENT_SOURCE_DIR}/third_party/inja/inja/string_view.h
|
||||||
# ${CMAKE_CURRENT_SOURCE_DIR}/third_party/inja/inja/inja.h
|
# ${CMAKE_CURRENT_SOURCE_DIR}/third_party/inja/inja/inja.h
|
||||||
)
|
)
|
||||||
target_precompile_headers(
|
|
||||||
tile_static
|
|
||||||
PUBLIC
|
|
||||||
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/third_party/header_only/toml.hpp>"
|
|
||||||
# "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/third_party/result/result.hpp>"
|
|
||||||
# ${CMAKE_CURRENT_SOURCE_DIR}/third_party/json/nlohann/json.hpp
|
|
||||||
# ${CMAKE_CURRENT_SOURCE_DIR}/third_party/inja/inja/string_view.h
|
|
||||||
# ${CMAKE_CURRENT_SOURCE_DIR}/third_party/inja/inja/inja.h
|
|
||||||
# target_sources(tile PRIVATE ${TILE_SRCS})
|
# target_sources(tile PRIVATE ${TILE_SRCS})
|
||||||
)
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
tile
|
tile
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/third_party/mustache.hpp"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/third_party/mustache.hpp"
|
||||||
@ -211,21 +203,8 @@ target_include_directories(
|
|||||||
RPIVATE
|
RPIVATE
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/header_only/"
|
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/header_only/"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
|
"${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
|
||||||
target_include_directories(
|
|
||||||
tile_static
|
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/third_party/mustache.hpp"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmt/include"
|
|
||||||
# "${CMAKE_CURRENT_BINARY_DIR}/third_party/glog"
|
|
||||||
# "${CMAKE_CURRENT_SOURCE_DIR}/third_party/glog/src"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
||||||
${THIRD_PARTY_INCLUDE_DIRS}
|
|
||||||
RPIVATE
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/header_only/"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
|
|
||||||
if(TILE_WITH_MIMALLOC)
|
if(TILE_WITH_MIMALLOC)
|
||||||
target_link_libraries(tile PUBLIC mimalloc-obj)
|
target_link_libraries(tile PUBLIC mimalloc-obj)
|
||||||
target_link_libraries(tile_static PUBLIC mimalloc-obj)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
@ -237,44 +216,15 @@ target_link_libraries(
|
|||||||
# -Wl,--end-group
|
# -Wl,--end-group
|
||||||
libcurl
|
libcurl
|
||||||
fmt)
|
fmt)
|
||||||
target_link_libraries(
|
|
||||||
tile_static
|
|
||||||
PUBLIC # -Wl,--start-group nova_context
|
|
||||||
zlib
|
|
||||||
gflags::gflags # glog::glog
|
|
||||||
jsoncpp_static
|
|
||||||
# -Wl,--end-group
|
|
||||||
libcurl
|
|
||||||
fmt)
|
|
||||||
if((CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES
|
if((CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES
|
||||||
"mips*"))
|
"mips*"))
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
target_link_libraries(tile PUBLIC atomic)
|
target_link_libraries(tile PUBLIC atomic)
|
||||||
target_link_libraries(tile_static PUBLIC atomic)
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# set(LIB_NAMES tile)
|
|
||||||
#
|
|
||||||
# if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) OR
|
|
||||||
# ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") OR ("${CMAKE_SYSTEM_NAME}"
|
|
||||||
# STREQUAL "GNU") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") OR
|
|
||||||
# ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") OR ("${CMAKE_SYSTEM_NAME}"
|
|
||||||
# STREQUAL "DragonFly") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME:
|
|
||||||
# It should be "GNU ld # for elf" set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES}
|
|
||||||
# -Wl,--no-whole-archive) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
|
||||||
# set(LIB_NAMES -Wl,-all_load ${LIB_NAMES}) endif()
|
|
||||||
|
|
||||||
add_library(tile::tile ALIAS tile)
|
add_library(tile::tile ALIAS tile)
|
||||||
add_library(tile::tile_static ALIAS tile_static)
|
|
||||||
# add_library(tile SHARED $<TARGET_OBJECTS:tile>) target_include_directories(
|
|
||||||
# tile PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmt/include"
|
|
||||||
# "${CMAKE_CURRENT_BINARY_DIR}/third_party/glog"
|
|
||||||
# "${CMAKE_CURRENT_SOURCE_DIR}/third_party/glog/src"
|
|
||||||
# "${CMAKE_CURRENT_SOURCE_DIR}" RPIVATE
|
|
||||||
# "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
|
|
||||||
# target_link_libraries( tile PRIVATE ${WHOLE_ARCHIVE_PREFIX} gflags::gflags
|
|
||||||
# glog::glog libcurl fmt::fmt ${NO_WHOLE_ARCHIVE_PREFIX})
|
|
||||||
|
|
||||||
if(TILE_BUILD_TESTS)
|
if(TILE_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
@ -5,4 +5,7 @@
|
|||||||
- [ ] 支持UDP
|
- [ ] 支持UDP
|
||||||
- [ ] 支持TCP
|
- [ ] 支持TCP
|
||||||
|
|
||||||
|
## 同步容器
|
||||||
|
- [ ] queue
|
||||||
|
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ LogMessageTime::init(const std::tm &t, std::time_t timestamp, WallTime now)
|
|||||||
void
|
void
|
||||||
LogMessageTime::CalcGmtOffset()
|
LogMessageTime::CalcGmtOffset()
|
||||||
{
|
{
|
||||||
std::tm gmt_struct{0};
|
std::tm gmt_struct;
|
||||||
int isDst = 0;
|
int isDst = 0;
|
||||||
if (true) {
|
if (true) {
|
||||||
localtime_r(×tamp_, &gmt_struct);
|
localtime_r(×tamp_, &gmt_struct);
|
||||||
@ -495,12 +495,8 @@ LogToSinks(LogSeverity severity,
|
|||||||
const char *message,
|
const char *message,
|
||||||
size_t message_len)
|
size_t message_len)
|
||||||
{
|
{
|
||||||
std::vector<LogSink::Ptr> sinks;
|
std::lock_guard<std::mutex> _(g_sink_mutex);
|
||||||
{
|
for (auto &&sink : g_sinks_arr) {
|
||||||
std::lock_guard<std::mutex> _(g_sink_mutex);
|
|
||||||
sinks = g_sinks_arr;
|
|
||||||
}
|
|
||||||
for (auto &&sink : sinks) {
|
|
||||||
if (sink->ShouldLog(severity)) {
|
if (sink->ShouldLog(severity)) {
|
||||||
try {
|
try {
|
||||||
sink->Send(severity, full_filename, base_filename, line, time, message, message_len);
|
sink->Send(severity, full_filename, base_filename, line, time, message, message_len);
|
||||||
@ -515,13 +511,8 @@ LogToSinks(LogSeverity severity,
|
|||||||
void
|
void
|
||||||
WaitForSinks()
|
WaitForSinks()
|
||||||
{
|
{
|
||||||
std::vector<LogSink::Ptr> sinks;
|
std::lock_guard<std::mutex> _(g_sink_mutex);
|
||||||
{
|
for (auto &&sink : g_sinks_arr) {
|
||||||
std::lock_guard<std::mutex> _(g_sink_mutex);
|
|
||||||
sinks = g_sinks_arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto &&sink : sinks) {
|
|
||||||
try {
|
try {
|
||||||
sink->Flush();
|
sink->Flush();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
11
tile/init.cc
11
tile/init.cc
@ -32,6 +32,7 @@ namespace tile {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::atomic<bool> g_quit_siganl{false};
|
std::atomic<bool> g_quit_siganl{false};
|
||||||
|
std::atomic<bool> g_tile_running{false};
|
||||||
|
|
||||||
void
|
void
|
||||||
QuitSignalHandler(int sig)
|
QuitSignalHandler(int sig)
|
||||||
@ -58,6 +59,11 @@ InstallQuitSignalHandler()
|
|||||||
int
|
int
|
||||||
Start(int argc, char **argv, std::function<int(int, char **)> cb, bool single_thread, bool enable_crash_catch)
|
Start(int argc, char **argv, std::function<int(int, char **)> cb, bool single_thread, bool enable_crash_catch)
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
bool expected = false;
|
||||||
|
TILE_CHECK(g_tile_running.compare_exchange_strong(expected, true), "tile already running.");
|
||||||
|
}
|
||||||
|
|
||||||
if (enable_crash_catch) {
|
if (enable_crash_catch) {
|
||||||
// TODO: Add InstallFailureSignalHandler
|
// TODO: Add InstallFailureSignalHandler
|
||||||
// google::InstallFailureSignalHandler();
|
// google::InstallFailureSignalHandler();
|
||||||
@ -134,13 +140,14 @@ TerminateBasicRuntime()
|
|||||||
std::mutex init_lock;
|
std::mutex init_lock;
|
||||||
std::condition_variable init_cv;
|
std::condition_variable init_cv;
|
||||||
std::thread *lib_thread;
|
std::thread *lib_thread;
|
||||||
const char *my_argv[1] = {"unknown"};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Init(int argc, char **argv, std::function<int(int, char **)> cb)
|
Init(int argc, char **argv, std::function<int(int, char **)> cb)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> _(init_lock);
|
std::unique_lock<std::mutex> _(init_lock);
|
||||||
assert(!lib_thread && "ReInitialize!!!");
|
TILE_CHECK(g_tile_running.load() == false, "tile already running.");
|
||||||
|
assert(lib_thread && "ReInitialize!!!");
|
||||||
|
const char *my_argv[1] = {"unknown"};
|
||||||
|
|
||||||
if (!argv) {
|
if (!argv) {
|
||||||
argc = 1;
|
argc = 1;
|
||||||
|
Reference in New Issue
Block a user