Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24m04a #23

Merged
merged 28 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ libexample.json
test

*.log
*.xml
*.xml

.xmake
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fail_fast: false
repos:
- repo: https://github.com/pocc/pre-commit-hooks
rev: master
hooks:
- id: clang-format
- id: cppcheck
108 changes: 27 additions & 81 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Author: Max Qian
# License: GPL3

cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.20)

project(Lithium)
enable_language(C CXX)
Expand Down Expand Up @@ -87,13 +87,26 @@ endif(APPLE)
# Lithium includes

include_directories(${CMAKE_SOURCE_DIR}/libs/)
include_directories(${CMAKE_SOURCE_DIR}/driverlibs/)
include_directories(${lithium_src_dir})
include_directories(${lithium_module_dir})
include_directories(${lithium_src_dir})
include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp)
include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-swagger)
include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-websocket)

find_package(OpenSSL REQUIRED)
if(OpenSSL_FOUND)
message("-- Found OpenSSL ${OPENSSL_VERSION}: ${OPENSSL_LIBRARIES}")
else()
message("-- OpenSSL Not Found")
endif()

find_package(CFITSIO REQUIRED)
find_package(ZLIB REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(fmt REQUIRED)

#################################################################################
#
# Subdirectories of Lithium
Expand All @@ -116,6 +129,10 @@ add_subdirectory(modules)

add_subdirectory(driver)

add_subdirectory(${lithium_src_dir}/carbon)
add_subdirectory(${lithium_src_dir}/config)
add_subdirectory(${lithium_src_dir}/server)

#################################################################################
#
# General defines for compatibility across different platforms
Expand Down Expand Up @@ -179,48 +196,28 @@ set(component_module

${lithium_component_dir}/addons.cpp
${lithium_component_dir}/compiler.cpp
${lithium_component_dir}/finder.cpp
${lithium_component_dir}/loader.cpp
${lithium_component_dir}/manager.cpp
${lithium_component_dir}/sandbox.cpp
${lithium_component_dir}/sort.cpp
)

set(config_module
${lithium_src_dir}/config/configor.cpp
${lithium_src_dir}/config/HubsConfig.cpp
)

if (ENABLE_DEBUG_FLAG)
set(debug_module
${lithium_src_dir}/debug/terminal.cpp
)
else()
set(debug_module
${lithium_src_dir}/debug/terminal.cpp
)
endif()

if (ENABLE_ASYNC_FLAG)
set(server_module
${lithium_src_dir}/websocket/Hub.cpp
${lithium_src_dir}/websocket/Connection.cpp
${lithium_src_dir}/websocket/Registry.cpp
${lithium_src_dir}/websocket/Session.cpp
)
else()
set(server_module
${lithium_src_dir}/websocket/WsServer.cpp
${lithium_src_dir}/websocket/WsHub.cpp
${lithium_src_dir}/websocket/WsInstance.cpp
)
endif()

set(script_module
${lithium_src_dir}/script/manager.cpp
${lithium_src_dir}/script/custom/sys.cpp
${lithium_src_dir}/script/custom/config.cpp

${lithium_src_dir}/script/sheller.cpp

${lithium_src_dir}/script/carbon.cpp
)

set(task_module
Expand All @@ -235,36 +232,25 @@ set(task_module
)

set(Lithium_module
${lithium_src_dir}/AppComponent.hpp
${lithium_src_dir}/ErrorHandler.cpp
${lithium_src_dir}/LithiumApp.cpp
)

find_package(OpenSSL REQUIRED)
if(OpenSSL_FOUND)
message("-- Found OpenSSL ${OPENSSL_VERSION}: ${OPENSSL_LIBRARIES}")
else()
message("-- OpenSSL Not Found")
endif()

find_package(CFITSIO REQUIRED)
find_package(ZLIB REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(fmt REQUIRED)

#################################################################################
# Main

add_library(lithium_server-library STATIC ${component_module} ${config_module} ${debug_module} ${module_module} ${device_module} ${task_module} ${server_module} ${script_module} ${Lithium_module})
add_executable(lithium_server ${lithium_src_dir}/App.cpp)
add_library(lithium_server-library STATIC ${component_module} ${config_module} ${debug_module} ${module_module} ${device_module} ${task_module} ${script_module} ${Lithium_module})
target_link_libraries(lithium_server-library loguru)
add_executable(lithium_server ${lithium_src_dir}/app.cpp)
target_link_directories(lithium_server PUBLIC ${CMAKE_BINARY_DIR}/libs)

target_link_libraries(lithium_server lithium_server-library)
target_link_libraries(lithium_server lithium_webserver)
target_link_libraries(lithium_server oatpp-websocket oatpp-swagger oatpp-openssl oatpp-zlib oatpp)
target_link_libraries(lithium_server loguru)
target_link_libraries(lithium_server libzippp)
target_link_libraries(lithium_server atomstatic)
target_link_libraries(lithium_server-library fmt::fmt)
target_link_libraries(lithium_server carbon)
target_link_libraries(lithium_server fmt::fmt)

target_compile_definitions(lithium_server PRIVATE LOGURU_DEBUG_LOGGING)

Expand Down Expand Up @@ -293,43 +279,3 @@ set_target_properties(
PROPERTIES
OUTPUT_NAME lithium_server
)

#################################################################################
# Hello Element Astro Launcher

add_library(heal-library STATIC
${lithium_src_dir}/auth/AuthHandler.cpp
${lithium_src_dir}/auth/AuthHandler.hpp
${lithium_src_dir}/auth/JWT.cpp
${lithium_src_dir}/auth/JWT.hpp
${lithium_src_dir}/controller/StaticController.hpp
${lithium_src_dir}/controller/StoryController.hpp
${lithium_src_dir}/controller/AuthController.hpp
${lithium_src_dir}/database/model/StoryModel.hpp
${lithium_src_dir}/database/model/UserModel.hpp
${lithium_src_dir}/database/StoryDb.hpp
${lithium_src_dir}/database/UserDb.hpp
${lithium_src_dir}/data/AuthDto.hpp
${lithium_src_dir}/data/PageDto.hpp
${lithium_src_dir}/data/SignInDto.hpp
${lithium_src_dir}/data/SignUpDto.hpp
${lithium_src_dir}/data/StatusDto.hpp
${lithium_src_dir}/data/StoryDto.hpp
${lithium_src_dir}/interceptor/AuthInterceptor.cpp
${lithium_src_dir}/interceptor/AuthInterceptor.hpp
${lithium_src_dir}/service/AuthService.cpp
${lithium_src_dir}/service/AuthService.hpp
${lithium_src_dir}/service/StoryService.cpp
${lithium_src_dir}/service/StoryService.hpp
${lithium_src_dir}/LauncherComponent.hpp
${lithium_src_dir}/components/DatabaseComponent.hpp
${lithium_src_dir}/components/SwaggerComponent.hpp
${lithium_src_dir}/ErrorHandler.cpp
${lithium_src_dir}/ErrorHandler.hpp
)

target_include_directories(heal-library PUBLIC ${lithium_src_dir})

add_executable(heal ${lithium_src_dir}/Launcher.cpp)
target_link_libraries(heal heal-library)
target_link_libraries(heal oatpp-websocket oatpp-swagger oatpp-openssl oatpp-zlib oatpp-sqlite oatpp)
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Lithium
# Lithium

<p align="center">
<img src="https://img.shields.io/badge/dialect-C%2B%2B20-blue">
Expand Down Expand Up @@ -72,14 +72,18 @@ pacman -S mingw-w64-x86_64-libzip
pacman -S mingw-w64-x86_64-zlib
pacman -S mingw-w64-x86_64-fmt
pacman -S mingw-w64-x86_64-libnova
pacman -S mingw-w64-x86_64-gsl

# for test
pacman -S mingw-w64-x86_64-gtest
```

#### On Ubuntu or other similar Linux platforms (No INDI needed)

```shell
sudo apt-get update && sudo apt-get upgrade -y
sudo apt install gcc g++ cmake
sudo apt install libcfitsio-dev zlib1g-dev libssl-dev libzip-dev libnova-dev libfmt-dev libudev-dev libuv1-dev
sudo apt install libcfitsio-dev zlib1g-dev libssl-dev libzip-dev libnova-dev libfmt-dev libudev-dev
```

Alternatively, you can directly run the provided script according to your platform:
Expand All @@ -96,10 +100,18 @@ Unfortunately, the newest GCC and CMake are not available on Github Codespace, s
```shell
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install gcc-13 # GCC13 is the best choice
sudo apt-get install gcc-13 g++-13 # GCC13 is the best choice, clang is alse OK

wget https://cmake.org/files/v3.28/cmake-3.28.0-rc5.tar.gz
tar -zxvf cmake-3.28.0-rc5.tar.gz
./bootstrap && make && sudo make install

#install newest clang-format
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo nano /etc/apt/sources.list
#deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
#deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
sudo apt install -y clang-format-17
```

Build the code:
Expand All @@ -116,7 +128,7 @@ Everything is very simple. The entire process is straightforward.

Here is a poem adapted from a quote :

```
```txt
Learning requires not mere imagination,
Nor can it be attained through mediocre dedication.
It is through diligent accumulation,
Expand Down Expand Up @@ -196,6 +208,11 @@ pacman -S mingw-w64-x86_64-fmt
pacman -S mingw-w64-x86_64-libnova
# 如果想用make构建
pacman -S make # 注意添加对应的目录,否则会当场爆炸

pacman -S mingw-w64-x86_64-gsl

# 测试用
pacman -S mingw-w64-x86_64-gtest
```

#### Ubuntu/Debian/Other Linux
Expand Down
6 changes: 4 additions & 2 deletions STYLE_OF_CODE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# C++ Naming Conventions
# Style of Code

## C++ Naming Conventions

## Variable Naming

Expand Down Expand Up @@ -109,7 +111,7 @@

Good naming conventions improve code readability and maintainability, making it easier for others to understand and use your code.

# C++命名规则
## C++命名规则

## 变量命名

Expand Down
File renamed without changes.
Empty file.
Loading
Loading