Skip to content

Commit

Permalink
update for a test
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroAir committed Dec 8, 2023
1 parent 28a7186 commit 6ed85dc
Show file tree
Hide file tree
Showing 25 changed files with 6,189 additions and 252 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,6 @@ target_link_libraries(lithium_server ${CFITSIO_LIBRARIES})
target_link_libraries(lithium_server OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(lithium_server ${ZLIB_LIBRARIES})
target_link_libraries(lithium_server libzip::zip)
if(WIN32)
target_link_libraries(lithium_server pugixml-shared)
else()
target_link_libraries(lithium_server pugixml-shared)
endif()
target_link_libraries(lithium_server sqlite3)
target_link_libraries(lithium_server cpp_httplib)
target_link_libraries(lithium_server backward)
Expand Down
2 changes: 1 addition & 1 deletion libs
Submodule libs updated from baf0cf to ea6696
40 changes: 30 additions & 10 deletions locale/lithium.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2023-12-01 13:45+0000\n"
"POT-Creation-Date: 2023-12-07 06:05+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -17,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: /workspaces/Lithium/src/device/device_manager.cpp:161
#: /workspaces/Lithium/src/device/device_manager.cpp:162
msgid "A device with name {} already exists, please choose a different name"
msgstr ""

Expand Down Expand Up @@ -72,34 +72,54 @@ msgstr ""
msgid "Set server port to %d"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:80
#: /workspaces/Lithium/src/LithiumApp.cpp:84
msgid "Failed to load Lithium App , error : {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:97
#: /workspaces/Lithium/src/LithiumApp.cpp:120
msgid "Get config value: {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:103
#: /workspaces/Lithium/src/LithiumApp.cpp:126
msgid "Set {} to {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:301
#: /workspaces/Lithium/src/LithiumApp.cpp:344
msgid "Failed to run chai command : {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:319
#: /workspaces/Lithium/src/LithiumApp.cpp:362
msgid "Failed to run chai multi command {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:332
#: /workspaces/Lithium/src/LithiumApp.cpp:375
msgid "Failed to load chaiscript file {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:345
#: /workspaces/Lithium/src/LithiumApp.cpp:388
msgid "Failed to unload chaiscript file {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:358
#: /workspaces/Lithium/src/LithiumApp.cpp:401
msgid "Failed to run chai script {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:423
msgid "Failed to load module {} in {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:442
msgid "Failed to unload module {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:464
msgid "Failed to reload module {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:502
msgid "Failed to enable module {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:521
msgid "Failed to disable module {}"
msgstr ""
38 changes: 29 additions & 9 deletions locale/po/en_US.UTF-8/lithium.po
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#: /workspaces/Lithium/src/device/device_manager.cpp:161
#: /workspaces/Lithium/src/device/device_manager.cpp:162
msgid "A device with name {} already exists, please choose a different name"
msgstr ""

Expand Down Expand Up @@ -53,34 +53,54 @@ msgstr ""
msgid "Set server port to %d"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:80
#: /workspaces/Lithium/src/LithiumApp.cpp:84
msgid "Failed to load Lithium App , error : {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:97
#: /workspaces/Lithium/src/LithiumApp.cpp:120
msgid "Get config value: {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:103
#: /workspaces/Lithium/src/LithiumApp.cpp:126
msgid "Set {} to {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:301
#: /workspaces/Lithium/src/LithiumApp.cpp:344
msgid "Failed to run chai command : {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:319
#: /workspaces/Lithium/src/LithiumApp.cpp:362
msgid "Failed to run chai multi command {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:332
#: /workspaces/Lithium/src/LithiumApp.cpp:375
msgid "Failed to load chaiscript file {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:345
#: /workspaces/Lithium/src/LithiumApp.cpp:388
msgid "Failed to unload chaiscript file {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:358
#: /workspaces/Lithium/src/LithiumApp.cpp:401
msgid "Failed to run chai script {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:423
msgid "Failed to load module {} in {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:442
msgid "Failed to unload module {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:464
msgid "Failed to reload module {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:502
msgid "Failed to enable module {}"
msgstr ""

#: /workspaces/Lithium/src/LithiumApp.cpp:521
msgid "Failed to disable module {}"
msgstr ""
167 changes: 5 additions & 162 deletions src/ErrorHandler.cpp

Large diffs are not rendered by default.

21 changes: 9 additions & 12 deletions src/LithiumApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,22 +454,19 @@ namespace Lithium
{
if (m_ModuleLoader->HasModule(name))
{
if(unloadModule(name))
if (unloadModule(name))
{
return loadModule(m_ModuleLoader->GetModulePath(name), name);
}
}
else
{
LOG_F(ERROR, _("Failed to reload module {}"), name);
json res = {
{"command", __func__},
{"status", false},
{"message", _(fmt::format("Failed to reload module {}", name).c_str())},
{"timestamp", GetTimestampString()}};
sendJsonMessage("error", res);
return false;
}
LOG_F(ERROR, _("Failed to reload module {}"), name);
json res = {
{"command", __func__},
{"status", false},
{"message", _(fmt::format("Failed to reload module {}", name).c_str())},
{"timestamp", GetTimestampString()}};
sendJsonMessage("error", res);
return false;
}

bool LithiumApp::reloadAllModules()
Expand Down
1 change: 1 addition & 0 deletions src/atom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CHECK_INCLUDE_FILE(format HAS_STD_FORMAT)

add_subdirectory(io)
add_subdirectory(log)
add_subdirectory(type)
add_subdirectory(web)

if(NOT HAS_STD_FORMAT)
Expand Down
20 changes: 10 additions & 10 deletions src/atom/plugin/module_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace Lithium
/**
* @brief Loads a dynamic module from the given path.
*
* This function loads a dynamic module from the given path. If the loading is successful, it returns true and saves the handle to the module in the handles_ map.
* This function loads a dynamic module from the given path. If the loading is successful, it returns true and saves the handle to the module in the modules_ map.
* If the loading fails, it returns false and logs an error message.
*
* @param[in] path The path of the dynamic module to load.
Expand Down Expand Up @@ -252,18 +252,18 @@ namespace Lithium
template <typename T>
T GetFunction(const std::string &name, const std::string &function_name)
{
auto handle_it = handles_.find(name);
if (handle_it == handles_.end())
auto handle_it = modules_.find(name);
if (handle_it == modules_.end())
{
LOG_F(ERROR, "Failed to find module %s", name.c_str());
LOG_F(ERROR, "Failed to find module {}", name);
return nullptr;
}

auto func_ptr = reinterpret_cast<T>(LOAD_FUNCTION(handle_it->second, function_name.c_str()));
auto func_ptr = reinterpret_cast<T>(LOAD_FUNCTION(handle_it->second->handle, function_name.c_str()));

if (!func_ptr)
{
LOG_F(ERROR, "Failed to get symbol %s from module %s: %s", function_name.c_str(), name.c_str(), dlerror());
LOG_F(ERROR, "Failed to get symbol {} from module {}: {}", function_name, name, dlerror());
return nullptr;
}

Expand All @@ -283,17 +283,17 @@ namespace Lithium
std::shared_ptr<T> GetInstance(const std::string &name, const json &config,
const std::string &symbol_name)
{
auto handle_it = handles_.find(name);
if (handle_it == handles_.end())
auto handle_it = modules_.find(name);
if (handle_it == modules_.end())
{
LOG_F(ERROR, "Failed to find module %s", name.c_str());
LOG_F(ERROR, "Failed to find module {}", name);
return nullptr;
}

auto get_instance_func = GetFunction<std::shared_ptr<T> (*)(const json &)>(name, symbol_name);
if (!get_instance_func)
{
LOG_F(ERROR, "Failed to get symbol %s from module %s: %s", symbol_name.c_str(), name.c_str(), dlerror());
LOG_F(ERROR, "Failed to get symbol {} from module {}: {}", symbol_name, name, dlerror());
return nullptr;
}

Expand Down
114 changes: 114 additions & 0 deletions src/atom/type/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
cmake_minimum_required(VERSION 3.15)
project(tinyxml2 VERSION 9.0.0)

##
## Honor tinyxml2_SHARED_LIBS to match install interface
##

if (DEFINED tinyxml2_SHARED_LIBS)
set(BUILD_SHARED_LIBS "${tinyxml2_SHARED_LIBS}")
endif ()

##
## Main library build
##

set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)

add_library(tinyxml2 tinyxml2.cpp tinyxml2.h)
add_library(tinyxml2::tinyxml2 ALIAS tinyxml2)

# Uncomment the following line to require C++11 (or greater) to use tinyxml2
# target_compile_features(tinyxml2 PUBLIC cxx_std_11)
target_include_directories(tinyxml2 PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")

target_compile_definitions(
tinyxml2
PUBLIC $<$<CONFIG:Debug>:TINYXML2_DEBUG>
INTERFACE $<$<BOOL:${BUILD_SHARED_LIBS}>:TINYXML2_IMPORT>
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
PUBLIC _FILE_OFFSET_BITS=64
)

set_target_properties(
tinyxml2
PROPERTIES
DEFINE_SYMBOL "TINYXML2_EXPORT"
VERSION "${tinyxml2_VERSION}"
SOVERSION "${tinyxml2_VERSION_MAJOR}"
)

##
## Installation
##

## Standard modules
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

## Custom locations
set(tinyxml2_INSTALL_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
CACHE PATH "Directory for pkgconfig files")

set(tinyxml2_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/tinyxml2"
CACHE STRING "Path to tinyxml2 CMake files")

## CMake targets and export scripts

install(
TARGETS tinyxml2 EXPORT tinyxml2-targets
RUNTIME COMPONENT tinyxml2_runtime
LIBRARY COMPONENT tinyxml2_runtime
NAMELINK_COMPONENT tinyxml2_development
ARCHIVE COMPONENT tinyxml2_development
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

# Type-specific targets

if (BUILD_SHARED_LIBS)
set(type shared)
else ()
set(type static)
endif ()

install(
EXPORT tinyxml2-targets
DESTINATION "${tinyxml2_INSTALL_CMAKEDIR}"
NAMESPACE tinyxml2::
FILE tinyxml2-${type}-targets.cmake
COMPONENT tinyxml2_development
)

# Auto-generated version compatibility file
write_basic_package_version_file(
tinyxml2-config-version.cmake
COMPATIBILITY SameMajorVersion
)

install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/tinyxml2-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/tinyxml2-config-version.cmake"
DESTINATION "${tinyxml2_INSTALL_CMAKEDIR}"
COMPONENT tinyxml2_development
)

## Headers

install(
FILES tinyxml2.h
TYPE INCLUDE
COMPONENT tinyxml2_development
)

## pkg-config

configure_file(cmake/tinyxml2.pc.in tinyxml2.pc.gen @ONLY)
file(GENERATE OUTPUT tinyxml2.pc INPUT "${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc.gen")
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc"
DESTINATION "${tinyxml2_INSTALL_PKGCONFIGDIR}"
COMPONENT tinyxml2_development
)
Loading

0 comments on commit 6ed85dc

Please sign in to comment.