Compare commits
5 Commits
feat/add_s
...
fix/mktime
Author | SHA1 | Date | |
---|---|---|---|
4f7fe89011 | |||
e16305d3dd | |||
acacfbe188 | |||
86f52567b7 | |||
471c2c1756 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,4 +4,3 @@ build/
|
||||
compile_commands.json
|
||||
.gdb_history
|
||||
.cmake.conf
|
||||
third_party/
|
||||
|
@ -173,13 +173,12 @@ if((NOT TILE_HAVE_GETIFADDRS) OR (NOT TILE_HAVE_FREEIFADDRS))
|
||||
list(APPEND TILE_SRCS "tile/base/net/detail/android/ifaddrs.c")
|
||||
endif()
|
||||
|
||||
if(TILE_BUILD_SHARED)
|
||||
add_library(tile SHARED ${TILE_SRCS})
|
||||
else()
|
||||
add_library(tile STATIC ${TILE_SRCS})
|
||||
endif()
|
||||
add_library(tile SHARED ${TILE_SRCS})
|
||||
add_library(tile_static STATIC ${TILE_SRCS})
|
||||
set_target_properties(tile PROPERTIES VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||
set_target_properties(tile_static PROPERTIES VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||
|
||||
target_precompile_headers(
|
||||
tile
|
||||
@ -190,7 +189,16 @@ target_precompile_headers(
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/third_party/inja/inja/string_view.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_include_directories(
|
||||
tile
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/third_party/mustache.hpp"
|
||||
@ -203,8 +211,21 @@ target_include_directories(
|
||||
RPIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/header_only/"
|
||||
"${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)
|
||||
target_link_libraries(tile PUBLIC mimalloc-obj)
|
||||
target_link_libraries(tile_static PUBLIC mimalloc-obj)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
@ -216,15 +237,44 @@ target_link_libraries(
|
||||
# -Wl,--end-group
|
||||
libcurl
|
||||
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
|
||||
"mips*"))
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_libraries(tile PUBLIC atomic)
|
||||
target_link_libraries(tile_static PUBLIC atomic)
|
||||
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_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)
|
||||
enable_testing()
|
||||
|
@ -347,7 +347,7 @@ LogMessageTime::init(const std::tm &t, std::time_t timestamp, WallTime now)
|
||||
void
|
||||
LogMessageTime::CalcGmtOffset()
|
||||
{
|
||||
std::tm gmt_struct;
|
||||
std::tm gmt_struct{0};
|
||||
int isDst = 0;
|
||||
if (true) {
|
||||
localtime_r(×tamp_, &gmt_struct);
|
||||
@ -495,8 +495,12 @@ LogToSinks(LogSeverity severity,
|
||||
const char *message,
|
||||
size_t message_len)
|
||||
{
|
||||
std::lock_guard<std::mutex> _(g_sink_mutex);
|
||||
for (auto &&sink : g_sinks_arr) {
|
||||
std::vector<LogSink::Ptr> sinks;
|
||||
{
|
||||
std::lock_guard<std::mutex> _(g_sink_mutex);
|
||||
sinks = g_sinks_arr;
|
||||
}
|
||||
for (auto &&sink : sinks) {
|
||||
if (sink->ShouldLog(severity)) {
|
||||
try {
|
||||
sink->Send(severity, full_filename, base_filename, line, time, message, message_len);
|
||||
@ -511,8 +515,13 @@ LogToSinks(LogSeverity severity,
|
||||
void
|
||||
WaitForSinks()
|
||||
{
|
||||
std::lock_guard<std::mutex> _(g_sink_mutex);
|
||||
for (auto &&sink : g_sinks_arr) {
|
||||
std::vector<LogSink::Ptr> sinks;
|
||||
{
|
||||
std::lock_guard<std::mutex> _(g_sink_mutex);
|
||||
sinks = g_sinks_arr;
|
||||
}
|
||||
|
||||
for (auto &&sink : sinks) {
|
||||
try {
|
||||
sink->Flush();
|
||||
} catch (const std::exception &e) {
|
||||
|
11
tile/init.cc
11
tile/init.cc
@ -32,7 +32,6 @@ namespace tile {
|
||||
namespace {
|
||||
|
||||
std::atomic<bool> g_quit_siganl{false};
|
||||
std::atomic<bool> g_tile_running{false};
|
||||
|
||||
void
|
||||
QuitSignalHandler(int sig)
|
||||
@ -59,11 +58,6 @@ InstallQuitSignalHandler()
|
||||
int
|
||||
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) {
|
||||
// TODO: Add InstallFailureSignalHandler
|
||||
// google::InstallFailureSignalHandler();
|
||||
@ -140,14 +134,13 @@ TerminateBasicRuntime()
|
||||
std::mutex init_lock;
|
||||
std::condition_variable init_cv;
|
||||
std::thread *lib_thread;
|
||||
const char *my_argv[1] = {"unknown"};
|
||||
|
||||
void
|
||||
Init(int argc, char **argv, std::function<int(int, char **)> cb)
|
||||
{
|
||||
std::unique_lock<std::mutex> _(init_lock);
|
||||
TILE_CHECK(g_tile_running.load() == false, "tile already running.");
|
||||
assert(lib_thread && "ReInitialize!!!");
|
||||
const char *my_argv[1] = {"unknown"};
|
||||
assert(!lib_thread && "ReInitialize!!!");
|
||||
|
||||
if (!argv) {
|
||||
argc = 1;
|
||||
|
Reference in New Issue
Block a user