From 6c357f1dc7efdb5e23bf16650e0d0166028d2db3 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Mon, 12 Jun 2017 10:32:20 +0100 Subject: [PATCH] Separate Tawashi and Kamokan. Unit tests are still a bit mixed up, but that should be simple to split once I have a separate repo for Tawashi. --- CMakeLists.txt | 1 + src/kamokan/CMakeLists.txt | 12 +--- src/kamokan_impl/CMakeLists.txt | 61 +++++++++++++++++++ .../error_response.cpp | 0 .../error_response.hpp | 0 .../index_response.cpp | 0 .../index_response.hpp | 0 src/{tawashi => kamokan_impl}/ini_file.cpp | 0 src/{tawashi => kamokan_impl}/ini_file.hpp | 0 .../kamokan_config.h.in | 0 .../list_highlight_langs.cpp | 0 .../list_highlight_langs.hpp | 0 .../num_to_token.cpp | 0 .../num_to_token.hpp | 0 .../pastie_response.cpp | 0 .../pastie_response.hpp | 0 .../pathname/pathname.cpp | 0 .../pathname/pathname.hpp | 0 .../pathname/stringpool.hpp | 0 .../pathname/stringpool.inl | 0 .../quick_submit_paste_response.cpp | 0 .../quick_submit_paste_response.hpp | 0 src/{tawashi => kamokan_impl}/response.cpp | 2 +- src/{tawashi => kamokan_impl}/response.hpp | 0 .../response_factory.cpp | 0 .../response_factory.hpp | 0 .../settings_bag.cpp | 0 .../settings_bag.hpp | 0 src/{tawashi => kamokan_impl}/storage.cpp | 3 +- src/{tawashi => kamokan_impl}/storage.hpp | 2 +- .../submit_paste_response.cpp | 2 +- .../submit_paste_response.hpp | 2 +- src/tawashi/CMakeLists.txt | 23 +------ test/simulation/CMakeLists.txt | 2 +- test/unit/CMakeLists.txt | 1 + 35 files changed, 74 insertions(+), 37 deletions(-) create mode 100644 src/kamokan_impl/CMakeLists.txt rename src/{tawashi => kamokan_impl}/error_response.cpp (100%) rename src/{tawashi => kamokan_impl}/error_response.hpp (100%) rename src/{tawashi => kamokan_impl}/index_response.cpp (100%) rename src/{tawashi => kamokan_impl}/index_response.hpp (100%) rename src/{tawashi => kamokan_impl}/ini_file.cpp (100%) rename src/{tawashi => kamokan_impl}/ini_file.hpp (100%) rename src/{kamokan => kamokan_impl}/kamokan_config.h.in (100%) rename src/{tawashi => kamokan_impl}/list_highlight_langs.cpp (100%) rename src/{tawashi => kamokan_impl}/list_highlight_langs.hpp (100%) rename src/{tawashi => kamokan_impl}/num_to_token.cpp (100%) rename src/{tawashi => kamokan_impl}/num_to_token.hpp (100%) rename src/{tawashi => kamokan_impl}/pastie_response.cpp (100%) rename src/{tawashi => kamokan_impl}/pastie_response.hpp (100%) rename src/{tawashi => kamokan_impl}/pathname/pathname.cpp (100%) rename src/{tawashi => kamokan_impl}/pathname/pathname.hpp (100%) rename src/{tawashi => kamokan_impl}/pathname/stringpool.hpp (100%) rename src/{tawashi => kamokan_impl}/pathname/stringpool.inl (100%) rename src/{tawashi => kamokan_impl}/quick_submit_paste_response.cpp (100%) rename src/{tawashi => kamokan_impl}/quick_submit_paste_response.hpp (100%) rename src/{tawashi => kamokan_impl}/response.cpp (99%) rename src/{tawashi => kamokan_impl}/response.hpp (100%) rename src/{tawashi => kamokan_impl}/response_factory.cpp (100%) rename src/{tawashi => kamokan_impl}/response_factory.hpp (100%) rename src/{tawashi => kamokan_impl}/settings_bag.cpp (100%) rename src/{tawashi => kamokan_impl}/settings_bag.hpp (100%) rename src/{tawashi => kamokan_impl}/storage.cpp (98%) rename src/{tawashi => kamokan_impl}/storage.hpp (98%) rename src/{tawashi => kamokan_impl}/submit_paste_response.cpp (99%) rename src/{tawashi => kamokan_impl}/submit_paste_response.hpp (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d05967..4dd4651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ add_subdirectory(lib/incredis) add_subdirectory(lib/mstch) add_subdirectory(lib/houdini) add_subdirectory(src/tawashi) +add_subdirectory(src/kamokan_impl) add_subdirectory(src/kamokan) install(DIRECTORY html/website/ DESTINATION html) diff --git a/src/kamokan/CMakeLists.txt b/src/kamokan/CMakeLists.txt index 7a8d9c2..e61387e 100644 --- a/src/kamokan/CMakeLists.txt +++ b/src/kamokan/CMakeLists.txt @@ -1,4 +1,4 @@ -project(kamokan VERSION 0.1.0 LANGUAGES CXX) +project(kamokan LANGUAGES CXX) set(KAMOKAN_CONFIG_PATH "etc" CACHE STRING "Path where config file will be located, absolute or relative to the install prefix") set(KAMOKAN_CONFIG_FILE "kamokan.ini" CACHE STRING "Filename of the config file in KAMOKAN_CONFIG_PATH") @@ -10,7 +10,7 @@ add_executable(${PROJECT_NAME} main.cpp ) target_link_libraries(${PROJECT_NAME} - PRIVATE tawashi + PRIVATE kamokan_impl #hack - add duckhandy to the project instead of picking from inside redis PRIVATE duckhandy ) @@ -20,16 +20,8 @@ set_target_properties( PROPERTIES SUFFIX .cgi ) -target_include_directories(${PROJECT_NAME} - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include -) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib/static ) - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/kamokan_config.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/include/kamokan_config.h" -) diff --git a/src/kamokan_impl/CMakeLists.txt b/src/kamokan_impl/CMakeLists.txt new file mode 100644 index 0000000..f5d2411 --- /dev/null +++ b/src/kamokan_impl/CMakeLists.txt @@ -0,0 +1,61 @@ +project(kamokan_impl VERSION 0.2.3 LANGUAGES CXX) + +find_package(SourceHighlight REQUIRED) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_library(${PROJECT_NAME} STATIC + response.cpp + submit_paste_response.cpp + num_to_token.cpp + index_response.cpp + pastie_response.cpp + ini_file.cpp + pathname/pathname.cpp + response_factory.cpp + list_highlight_langs.cpp + settings_bag.cpp + error_response.cpp + quick_submit_paste_response.cpp + storage.cpp +) + +target_include_directories(${PROJECT_NAME} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/kakoune + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/mstch/include + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} +) +target_include_directories(${PROJECT_NAME} SYSTEM + PUBLIC ${Boost_INCLUDE_DIRS} + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/better-enums + PRIVATE ${SourceHighlight_INCLUDE_DIR} + PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/utf8_v2_3_4/source + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/spdlog/include + PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include +) +target_link_libraries(${PROJECT_NAME} + PRIVATE ${Boost_LIBRARIES} + PRIVATE incredis + PRIVATE ${SourceHighlight_LIBRARIES} + PUBLIC mstch + PRIVATE pthread + PUBLIC tawashi +) +target_compile_definitions(${PROJECT_NAME} + PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1 + PUBLIC $<$:SPDLOG_DEBUG_ON> + PUBLIC $<$:SPDLOG_TRACE_ON> + PUBLIC $<$:tawashi_virtual_testing=virtual> + PUBLIC $<$>:tawashi_virtual_testing=> + PUBLIC $<$:KAMOKAN_WITH_TESTING> +) +target_compile_options(${PROJECT_NAME} + PRIVATE -fdiagnostics-color=always +) + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/kamokan_config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/include/kamokan_config.h" +) diff --git a/src/tawashi/error_response.cpp b/src/kamokan_impl/error_response.cpp similarity index 100% rename from src/tawashi/error_response.cpp rename to src/kamokan_impl/error_response.cpp diff --git a/src/tawashi/error_response.hpp b/src/kamokan_impl/error_response.hpp similarity index 100% rename from src/tawashi/error_response.hpp rename to src/kamokan_impl/error_response.hpp diff --git a/src/tawashi/index_response.cpp b/src/kamokan_impl/index_response.cpp similarity index 100% rename from src/tawashi/index_response.cpp rename to src/kamokan_impl/index_response.cpp diff --git a/src/tawashi/index_response.hpp b/src/kamokan_impl/index_response.hpp similarity index 100% rename from src/tawashi/index_response.hpp rename to src/kamokan_impl/index_response.hpp diff --git a/src/tawashi/ini_file.cpp b/src/kamokan_impl/ini_file.cpp similarity index 100% rename from src/tawashi/ini_file.cpp rename to src/kamokan_impl/ini_file.cpp diff --git a/src/tawashi/ini_file.hpp b/src/kamokan_impl/ini_file.hpp similarity index 100% rename from src/tawashi/ini_file.hpp rename to src/kamokan_impl/ini_file.hpp diff --git a/src/kamokan/kamokan_config.h.in b/src/kamokan_impl/kamokan_config.h.in similarity index 100% rename from src/kamokan/kamokan_config.h.in rename to src/kamokan_impl/kamokan_config.h.in diff --git a/src/tawashi/list_highlight_langs.cpp b/src/kamokan_impl/list_highlight_langs.cpp similarity index 100% rename from src/tawashi/list_highlight_langs.cpp rename to src/kamokan_impl/list_highlight_langs.cpp diff --git a/src/tawashi/list_highlight_langs.hpp b/src/kamokan_impl/list_highlight_langs.hpp similarity index 100% rename from src/tawashi/list_highlight_langs.hpp rename to src/kamokan_impl/list_highlight_langs.hpp diff --git a/src/tawashi/num_to_token.cpp b/src/kamokan_impl/num_to_token.cpp similarity index 100% rename from src/tawashi/num_to_token.cpp rename to src/kamokan_impl/num_to_token.cpp diff --git a/src/tawashi/num_to_token.hpp b/src/kamokan_impl/num_to_token.hpp similarity index 100% rename from src/tawashi/num_to_token.hpp rename to src/kamokan_impl/num_to_token.hpp diff --git a/src/tawashi/pastie_response.cpp b/src/kamokan_impl/pastie_response.cpp similarity index 100% rename from src/tawashi/pastie_response.cpp rename to src/kamokan_impl/pastie_response.cpp diff --git a/src/tawashi/pastie_response.hpp b/src/kamokan_impl/pastie_response.hpp similarity index 100% rename from src/tawashi/pastie_response.hpp rename to src/kamokan_impl/pastie_response.hpp diff --git a/src/tawashi/pathname/pathname.cpp b/src/kamokan_impl/pathname/pathname.cpp similarity index 100% rename from src/tawashi/pathname/pathname.cpp rename to src/kamokan_impl/pathname/pathname.cpp diff --git a/src/tawashi/pathname/pathname.hpp b/src/kamokan_impl/pathname/pathname.hpp similarity index 100% rename from src/tawashi/pathname/pathname.hpp rename to src/kamokan_impl/pathname/pathname.hpp diff --git a/src/tawashi/pathname/stringpool.hpp b/src/kamokan_impl/pathname/stringpool.hpp similarity index 100% rename from src/tawashi/pathname/stringpool.hpp rename to src/kamokan_impl/pathname/stringpool.hpp diff --git a/src/tawashi/pathname/stringpool.inl b/src/kamokan_impl/pathname/stringpool.inl similarity index 100% rename from src/tawashi/pathname/stringpool.inl rename to src/kamokan_impl/pathname/stringpool.inl diff --git a/src/tawashi/quick_submit_paste_response.cpp b/src/kamokan_impl/quick_submit_paste_response.cpp similarity index 100% rename from src/tawashi/quick_submit_paste_response.cpp rename to src/kamokan_impl/quick_submit_paste_response.cpp diff --git a/src/tawashi/quick_submit_paste_response.hpp b/src/kamokan_impl/quick_submit_paste_response.hpp similarity index 100% rename from src/tawashi/quick_submit_paste_response.hpp rename to src/kamokan_impl/quick_submit_paste_response.hpp diff --git a/src/tawashi/response.cpp b/src/kamokan_impl/response.cpp similarity index 99% rename from src/tawashi/response.cpp rename to src/kamokan_impl/response.cpp index e9ebb85..2d979ae 100644 --- a/src/tawashi/response.cpp +++ b/src/kamokan_impl/response.cpp @@ -23,7 +23,7 @@ #include "list_highlight_langs.hpp" #include "cgi_env.hpp" #include "num_conv.hpp" -#include "tawashi_config.h" +#include "kamokan_config.h" #include #include #include diff --git a/src/tawashi/response.hpp b/src/kamokan_impl/response.hpp similarity index 100% rename from src/tawashi/response.hpp rename to src/kamokan_impl/response.hpp diff --git a/src/tawashi/response_factory.cpp b/src/kamokan_impl/response_factory.cpp similarity index 100% rename from src/tawashi/response_factory.cpp rename to src/kamokan_impl/response_factory.cpp diff --git a/src/tawashi/response_factory.hpp b/src/kamokan_impl/response_factory.hpp similarity index 100% rename from src/tawashi/response_factory.hpp rename to src/kamokan_impl/response_factory.hpp diff --git a/src/tawashi/settings_bag.cpp b/src/kamokan_impl/settings_bag.cpp similarity index 100% rename from src/tawashi/settings_bag.cpp rename to src/kamokan_impl/settings_bag.cpp diff --git a/src/tawashi/settings_bag.hpp b/src/kamokan_impl/settings_bag.hpp similarity index 100% rename from src/tawashi/settings_bag.hpp rename to src/kamokan_impl/settings_bag.hpp diff --git a/src/tawashi/storage.cpp b/src/kamokan_impl/storage.cpp similarity index 98% rename from src/tawashi/storage.cpp rename to src/kamokan_impl/storage.cpp index 9a4d0d1..3e02837 100644 --- a/src/tawashi/storage.cpp +++ b/src/kamokan_impl/storage.cpp @@ -19,7 +19,6 @@ #include "settings_bag.hpp" #include "incredis/incredis.hpp" #include "num_to_token.hpp" -#include "tawashi_config.h" #include "duckhandy/stringize.h" #include "spdlog.hpp" #include "truncated_string.hpp" @@ -151,7 +150,7 @@ namespace tawashi { return pastie; } -#if defined(TAWASHI_WITH_TESTING) +#if defined(KAMOKAN_WITH_TESTING) const SettingsBag& Storage::settings() const { return *m_settings; } diff --git a/src/tawashi/storage.hpp b/src/kamokan_impl/storage.hpp similarity index 98% rename from src/tawashi/storage.hpp rename to src/kamokan_impl/storage.hpp index 93c13cd..f0c11e4 100644 --- a/src/tawashi/storage.hpp +++ b/src/kamokan_impl/storage.hpp @@ -54,7 +54,7 @@ namespace tawashi { tawashi_virtual_testing boost::optional retrieve_pastie (const boost::string_view& parToken) const; -#if defined(TAWASHI_WITH_TESTING) +#if defined(KAMOKAN_WITH_TESTING) const SettingsBag& settings() const; #endif diff --git a/src/tawashi/submit_paste_response.cpp b/src/kamokan_impl/submit_paste_response.cpp similarity index 99% rename from src/tawashi/submit_paste_response.cpp rename to src/kamokan_impl/submit_paste_response.cpp index 57705c1..376ee5d 100644 --- a/src/tawashi/submit_paste_response.cpp +++ b/src/kamokan_impl/submit_paste_response.cpp @@ -73,7 +73,7 @@ namespace tawashi { } } //unnamed namespace -#if defined(TAWASHI_WITH_TESTING) +#if defined(KAMOKAN_WITH_TESTING) SubmitPasteResponse::SubmitPasteResponse ( const Kakoune::SafePtr& parSettings, std::ostream* parStreamOut, diff --git a/src/tawashi/submit_paste_response.hpp b/src/kamokan_impl/submit_paste_response.hpp similarity index 98% rename from src/tawashi/submit_paste_response.hpp rename to src/kamokan_impl/submit_paste_response.hpp index a13a809..9de9c3e 100644 --- a/src/tawashi/submit_paste_response.hpp +++ b/src/kamokan_impl/submit_paste_response.hpp @@ -27,7 +27,7 @@ namespace tawashi { class SubmitPasteResponse : public Response { public: -#if defined(TAWASHI_WITH_TESTING) +#if defined(KAMOKAN_WITH_TESTING) SubmitPasteResponse ( const Kakoune::SafePtr& parSettings, std::ostream* parStreamOut, diff --git a/src/tawashi/CMakeLists.txt b/src/tawashi/CMakeLists.txt index cc551af..767fd45 100644 --- a/src/tawashi/CMakeLists.txt +++ b/src/tawashi/CMakeLists.txt @@ -2,37 +2,23 @@ project(tawashi VERSION 0.2.3 LANGUAGES CXX C) option(TAWASHI_WITH_IP_LOGGING "Enable code in Tawashi that may result in users IPs being stored in the DB or in logs" ON) -find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options filesystem system) -find_package(SourceHighlight REQUIRED) +find_package(Boost 1.53.0 REQUIRED) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_library(${PROJECT_NAME} STATIC +add_library(${PROJECT_NAME} split_get_vars.cpp - response.cpp - submit_paste_response.cpp cgi_environment_vars.cpp cgi_env.cpp - num_to_token.cpp cgi_post.cpp escapist.cpp - index_response.cpp - pastie_response.cpp - ini_file.cpp - pathname/pathname.cpp - response_factory.cpp - list_highlight_langs.cpp - settings_bag.cpp sanitized_utf8.cpp tiger.c - error_response.cpp tawashi_exception.cpp http_header.cpp - quick_submit_paste_response.cpp ip_utils.cpp mime_split.cpp - storage.cpp truncated_string.cpp ) @@ -51,11 +37,8 @@ target_include_directories(${PROJECT_NAME} SYSTEM ) target_link_libraries(${PROJECT_NAME} PRIVATE ${Boost_LIBRARIES} - PRIVATE incredis - PRIVATE ${SourceHighlight_LIBRARIES} - PUBLIC mstch PRIVATE houdini - PRIVATE pthread + PRIVATE duckhandy ) target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1 diff --git a/test/simulation/CMakeLists.txt b/test/simulation/CMakeLists.txt index 9532a29..881722f 100644 --- a/test/simulation/CMakeLists.txt +++ b/test/simulation/CMakeLists.txt @@ -19,7 +19,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include ) target_link_libraries(${PROJECT_NAME} - PRIVATE tawashi + PRIVATE kamokan_impl PRIVATE duckhandy ) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index c9c9e7f..e7668aa 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -26,6 +26,7 @@ target_include_directories(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} PRIVATE tawashi PRIVATE duckhandy + PRIVATE kamokan_impl PRIVATE ${GLIB_LIBRARIES} )