diff options
author | Trumeet <yuuta@yuuta.moe> | 2022-07-26 17:36:20 -0700 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2022-07-26 17:36:20 -0700 |
commit | 7099a86ca74fa637f26af38674f80fb8efd5f6fa (patch) | |
tree | 33315c65e82170476cf3c80d976dfa4d16a304a3 | |
parent | 8b07bf593e54dd876e30d0cb1c7c7226d0d1b1e2 (diff) | |
download | acron-7099a86ca74fa637f26af38674f80fb8efd5f6fa.tar acron-7099a86ca74fa637f26af38674f80fb8efd5f6fa.tar.gz acron-7099a86ca74fa637f26af38674f80fb8efd5f6fa.tar.bz2 acron-7099a86ca74fa637f26af38674f80fb8efd5f6fa.zip |
refactor(libacron/acronc/helloworld): move to separate directories
The corresponding CMakeLists.txt files are still rough.
-rw-r--r-- | client/acronc/.gitignore | 82 | ||||
-rw-r--r-- | client/acronc/CMakeLists.txt | 68 | ||||
-rw-r--r-- | client/acronc/README.md (renamed from client/libacron/apps/acronc/README.md) | 0 | ||||
-rw-r--r-- | client/acronc/async_dns.c (renamed from client/libacron/apps/acronc/async_dns.c) | 0 | ||||
-rw-r--r-- | client/acronc/client.c (renamed from client/libacron/apps/acronc/client.c) | 0 | ||||
-rw-r--r-- | client/acronc/client.h (renamed from client/libacron/apps/acronc/client.h) | 0 | ||||
-rw-r--r-- | client/acronc/common.h (renamed from client/libacron/apps/acronc/common.h) | 0 | ||||
-rw-r--r-- | client/acronc/config.c (renamed from client/libacron/apps/acronc/config.c) | 0 | ||||
-rw-r--r-- | client/acronc/config.h (renamed from client/libacron/apps/acronc/config.h) | 0 | ||||
-rw-r--r-- | client/acronc/handler.h (renamed from client/libacron/apps/acronc/handler.h) | 0 | ||||
-rw-r--r-- | client/acronc/handler_signal.c (renamed from client/libacron/apps/acronc/handler_signal.c) | 0 | ||||
-rw-r--r-- | client/acronc/handler_socket.c (renamed from client/libacron/apps/acronc/handler_socket.c) | 0 | ||||
-rw-r--r-- | client/acronc/handler_stdin.c (renamed from client/libacron/apps/acronc/handler_stdin.c) | 0 | ||||
-rw-r--r-- | client/acronc/helpers.c (renamed from client/libacron/apps/acronc/helpers.c) | 0 | ||||
-rw-r--r-- | client/acronc/helpers.h (renamed from client/libacron/apps/acronc/helpers.h) | 0 | ||||
-rw-r--r-- | client/acronc/log.c (renamed from client/libacron/apps/acronc/log.c) | 0 | ||||
-rw-r--r-- | client/acronc/log.h (renamed from client/libacron/apps/acronc/log.h) | 0 | ||||
-rw-r--r-- | client/acronc/main.c (renamed from client/libacron/apps/acronc/main.c) | 0 | ||||
-rw-r--r-- | client/helloworld/.gitignore | 82 | ||||
-rw-r--r-- | client/helloworld/CMakeLists.txt | 50 | ||||
-rw-r--r-- | client/helloworld/main.c (renamed from client/libacron/apps/helloworld/main.c) | 0 | ||||
-rw-r--r-- | client/helloworld/net.c (renamed from client/libacron/apps/helloworld/net.c) | 0 | ||||
-rw-r--r-- | client/helloworld/net.h (renamed from client/libacron/apps/helloworld/net.h) | 0 | ||||
-rw-r--r-- | client/libacron/CMakeLists.txt | 27 | ||||
-rw-r--r-- | client/libacron/README.md | 3 |
25 files changed, 283 insertions, 29 deletions
diff --git a/client/acronc/.gitignore b/client/acronc/.gitignore new file mode 100644 index 0000000..6741ba2 --- /dev/null +++ b/client/acronc/.gitignore @@ -0,0 +1,82 @@ +cmake-build-debug/ +cmake-build-release/ +json-c/ + +# https://raw.githubusercontent.com/github/gitignore/main/Global/JetBrains.gitignore +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser diff --git a/client/acronc/CMakeLists.txt b/client/acronc/CMakeLists.txt new file mode 100644 index 0000000..ec2b7fb --- /dev/null +++ b/client/acronc/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required(VERSION 3.22) +project(libac C) + +set(CMAKE_C_STANDARD 11) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) +endif() + +add_definitions(-D_POSIX_C_SOURCE=200809L) +IF(CMAKE_BUILD_TYPE MATCHES Debug) + add_definitions(-DDEBUG) +ENDIF(CMAKE_BUILD_TYPE MATCHES Debug) + +if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_C_FLAGS_DEBUG + "${CMAKE_C_FLAGS_DEBUG} -g3 -O0 -fsanitize=address") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG + "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -fvisibility=hidden") +elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + # TODO: MSVC ASAN + set(CMAKE_C_FLAGS_DEBUG + "${CMAKE_C_FLAGS_DEBUG} /DEBUG /Z7 /Od") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG + "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") +endif() + +add_subdirectory(../libacron ${CMAKE_BINARY_DIR}/libac) + +# helloworld +#add_executable(helloworld +# helloworld/main.c +# helloworld/net.c +# helloworld/net.h +# ) +#target_link_libraries(helloworld ${APPS_DEPS}) +#target_include_directories(helloworld PUBLIC "${PROJECT_BINARY_DIR}" include/) + +# acronc +add_executable(acronc + main.c + common.h + log.h + log.c + handler.h + handler_signal.c + config.c + config.h + client.c + client.h + handler_stdin.c + helpers.c + helpers.h + handler_socket.c + async_dns.c + ) +target_link_libraries(acronc ${APPS_DEPS} uv ac) +target_include_directories(acronc PUBLIC "${PROJECT_BINARY_DIR}" include/) + +install(TARGETS acronc + EXPORT ${PROJECT_NAME}-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/libac +) diff --git a/client/libacron/apps/acronc/README.md b/client/acronc/README.md index 87c9db0..87c9db0 100644 --- a/client/libacron/apps/acronc/README.md +++ b/client/acronc/README.md diff --git a/client/libacron/apps/acronc/async_dns.c b/client/acronc/async_dns.c index 2e221cf..2e221cf 100644 --- a/client/libacron/apps/acronc/async_dns.c +++ b/client/acronc/async_dns.c diff --git a/client/libacron/apps/acronc/client.c b/client/acronc/client.c index 5553d4c..5553d4c 100644 --- a/client/libacron/apps/acronc/client.c +++ b/client/acronc/client.c diff --git a/client/libacron/apps/acronc/client.h b/client/acronc/client.h index 438d7fd..438d7fd 100644 --- a/client/libacron/apps/acronc/client.h +++ b/client/acronc/client.h diff --git a/client/libacron/apps/acronc/common.h b/client/acronc/common.h index 0ca3b92..0ca3b92 100644 --- a/client/libacron/apps/acronc/common.h +++ b/client/acronc/common.h diff --git a/client/libacron/apps/acronc/config.c b/client/acronc/config.c index 046d931..046d931 100644 --- a/client/libacron/apps/acronc/config.c +++ b/client/acronc/config.c diff --git a/client/libacron/apps/acronc/config.h b/client/acronc/config.h index ee51f34..ee51f34 100644 --- a/client/libacron/apps/acronc/config.h +++ b/client/acronc/config.h diff --git a/client/libacron/apps/acronc/handler.h b/client/acronc/handler.h index 1a2ccfe..1a2ccfe 100644 --- a/client/libacron/apps/acronc/handler.h +++ b/client/acronc/handler.h diff --git a/client/libacron/apps/acronc/handler_signal.c b/client/acronc/handler_signal.c index 1d0ba7e..1d0ba7e 100644 --- a/client/libacron/apps/acronc/handler_signal.c +++ b/client/acronc/handler_signal.c diff --git a/client/libacron/apps/acronc/handler_socket.c b/client/acronc/handler_socket.c index ff8eefb..ff8eefb 100644 --- a/client/libacron/apps/acronc/handler_socket.c +++ b/client/acronc/handler_socket.c diff --git a/client/libacron/apps/acronc/handler_stdin.c b/client/acronc/handler_stdin.c index 3ac307d..3ac307d 100644 --- a/client/libacron/apps/acronc/handler_stdin.c +++ b/client/acronc/handler_stdin.c diff --git a/client/libacron/apps/acronc/helpers.c b/client/acronc/helpers.c index 9e141d4..9e141d4 100644 --- a/client/libacron/apps/acronc/helpers.c +++ b/client/acronc/helpers.c diff --git a/client/libacron/apps/acronc/helpers.h b/client/acronc/helpers.h index e983439..e983439 100644 --- a/client/libacron/apps/acronc/helpers.h +++ b/client/acronc/helpers.h diff --git a/client/libacron/apps/acronc/log.c b/client/acronc/log.c index 08f48b6..08f48b6 100644 --- a/client/libacron/apps/acronc/log.c +++ b/client/acronc/log.c diff --git a/client/libacron/apps/acronc/log.h b/client/acronc/log.h index 7bc9532..7bc9532 100644 --- a/client/libacron/apps/acronc/log.h +++ b/client/acronc/log.h diff --git a/client/libacron/apps/acronc/main.c b/client/acronc/main.c index 6e18ed2..6e18ed2 100644 --- a/client/libacron/apps/acronc/main.c +++ b/client/acronc/main.c diff --git a/client/helloworld/.gitignore b/client/helloworld/.gitignore new file mode 100644 index 0000000..6741ba2 --- /dev/null +++ b/client/helloworld/.gitignore @@ -0,0 +1,82 @@ +cmake-build-debug/ +cmake-build-release/ +json-c/ + +# https://raw.githubusercontent.com/github/gitignore/main/Global/JetBrains.gitignore +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser diff --git a/client/helloworld/CMakeLists.txt b/client/helloworld/CMakeLists.txt new file mode 100644 index 0000000..f36e020 --- /dev/null +++ b/client/helloworld/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 3.22) +project(libac C) + +set(CMAKE_C_STANDARD 11) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) +endif() + +add_definitions(-D_POSIX_C_SOURCE=200809L) +IF(CMAKE_BUILD_TYPE MATCHES Debug) + add_definitions(-DDEBUG) +ENDIF(CMAKE_BUILD_TYPE MATCHES Debug) + +if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_C_FLAGS_DEBUG + "${CMAKE_C_FLAGS_DEBUG} -g3 -O0 -fsanitize=address") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG + "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -fvisibility=hidden") +elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + # TODO: MSVC ASAN + set(CMAKE_C_FLAGS_DEBUG + "${CMAKE_C_FLAGS_DEBUG} /DEBUG /Z7 /Od") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG + "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") +endif() + +add_subdirectory(../libacron ${CMAKE_BINARY_DIR}/libac) + +# helloworld +if(WIN32) + set(APPS_DEPS ws2_32) +endif() +set(APPS_DEPS ${APPS_DEPS} ac) +add_executable(helloworld + main.c + net.c + net.h + ) +target_link_libraries(helloworld ${APPS_DEPS}) + +install(TARGETS helloworld + EXPORT ${PROJECT_NAME}-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/libac +) diff --git a/client/libacron/apps/helloworld/main.c b/client/helloworld/main.c index c112fcb..c112fcb 100644 --- a/client/libacron/apps/helloworld/main.c +++ b/client/helloworld/main.c diff --git a/client/libacron/apps/helloworld/net.c b/client/helloworld/net.c index 83192e0..83192e0 100644 --- a/client/libacron/apps/helloworld/net.c +++ b/client/helloworld/net.c diff --git a/client/libacron/apps/helloworld/net.h b/client/helloworld/net.h index 1a49709..1a49709 100644 --- a/client/libacron/apps/helloworld/net.h +++ b/client/helloworld/net.h diff --git a/client/libacron/CMakeLists.txt b/client/libacron/CMakeLists.txt index 57ce521..57da4af 100644 --- a/client/libacron/CMakeLists.txt +++ b/client/libacron/CMakeLists.txt @@ -89,32 +89,7 @@ target_link_libraries(ac ${LIBAC_DEPS}) target_include_directories(ac-static PUBLIC ${LIBAC_INCLUDES}) target_link_libraries(ac-static ${LIBAC_DEPS}) -# Apps -if(WIN32) - set(APPS_DEPS ws2_32) -endif() -set(APPS_DEPS ${APPS_DEPS} ac) - -# apps/helloworld -add_executable(helloworld - apps/helloworld/main.c - apps/helloworld/net.c - apps/helloworld/net.h - ) -target_link_libraries(helloworld ${APPS_DEPS}) -target_include_directories(helloworld PUBLIC "${PROJECT_BINARY_DIR}" include/) - -# apps/acronc -add_executable(acronc - apps/acronc/main.c - apps/acronc/common.h - apps/acronc/log.h - apps/acronc/log.c - apps/acronc/handler.h apps/acronc/handler_signal.c apps/acronc/config.c apps/acronc/config.h apps/acronc/client.c apps/acronc/client.h apps/acronc/handler_stdin.c apps/acronc/helpers.c apps/acronc/helpers.h apps/acronc/handler_socket.c apps/acronc/async_dns.c) -target_link_libraries(acronc ${APPS_DEPS} uv) -target_include_directories(acronc PUBLIC "${PROJECT_BINARY_DIR}" include/) - -install(TARGETS ac ac-static helloworld acronc +install(TARGETS ac ac-static EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/client/libacron/README.md b/client/libacron/README.md index 418e07b..4514e21 100644 --- a/client/libacron/README.md +++ b/client/libacron/README.md @@ -3,9 +3,6 @@ A client library written in C, based on [json-c](https://github.com/json-c/json-c) and [wic](https://github.com/cjhdev/wic). -This document is for client developers. For users who want a remote console to their Minecraft -server, they should consult [acronc(1)](apps/acronc), a ready-to-use Acron cli. - ## Building Requirements: |