From 5bc988b093cbe13d71862fff888358f00ce0e414 Mon Sep 17 00:00:00 2001 From: Adam Gu Date: Tue, 10 Apr 2018 17:34:00 +0800 Subject: [PATCH] Refine folder structure; add rapidjson as submodule. --- .gitmodules | 3 ++ CMakeLists.txt | 40 ++++++++++++++++--- .../rest_book_client}/CMakeLists.txt | 0 .../rest_book_client}/main.cc | 0 .../rest_book_server}/CMakeLists.txt | 0 .../rest_book_server}/book_services.cc | 0 .../rest_book_server}/book_services.h | 0 .../rest_book_server}/main.cc | 0 .../soap_calc_client}/CMakeLists.txt | 0 .../soap_calc_client}/calc_client.cc | 0 .../soap_calc_client}/calc_client.h | 0 .../soap_calc_client}/calculator.wsdl | 0 .../soap_calc_client}/main.cc | 0 .../soap_calc_server}/CMakeLists.txt | 0 .../soap_calc_server}/calc_service.cc | 0 .../soap_calc_server}/calc_service.h | 0 .../soap_calc_server}/main.cc | 0 src/CMakeLists.txt | 23 ----------- third_party/README.txt | 4 ++ {src => third_party}/gtest/CMakeLists.txt | 0 {src => third_party}/gtest/gtest-all.cc | 0 .../gtest/gtest-death-test.cc | 0 {src => third_party}/gtest/gtest-death-test.h | 0 {src => third_party}/gtest/gtest-filepath.cc | 0 .../gtest/gtest-internal-inl.h | 0 {src => third_party}/gtest/gtest-message.h | 0 {src => third_party}/gtest/gtest-param-test.h | 0 .../gtest/gtest-param-test.h.pump | 0 {src => third_party}/gtest/gtest-port.cc | 0 {src => third_party}/gtest/gtest-printers.cc | 0 {src => third_party}/gtest/gtest-printers.h | 0 {src => third_party}/gtest/gtest-spi.h | 0 {src => third_party}/gtest/gtest-test-part.cc | 0 {src => third_party}/gtest/gtest-test-part.h | 0 .../gtest/gtest-typed-test.cc | 0 {src => third_party}/gtest/gtest-typed-test.h | 0 {src => third_party}/gtest/gtest.cc | 0 {src => third_party}/gtest/gtest.h | 0 {src => third_party}/gtest/gtest_main.cc | 0 {src => third_party}/gtest/gtest_pred_impl.h | 0 {src => third_party}/gtest/gtest_prod.h | 0 .../internal/gtest-death-test-internal.h | 0 .../gtest/internal/gtest-filepath.h | 0 .../gtest/internal/gtest-internal.h | 0 .../gtest/internal/gtest-linked_ptr.h | 0 .../internal/gtest-param-util-generated.h | 0 .../gtest-param-util-generated.h.pump | 0 .../gtest/internal/gtest-param-util.h | 0 .../gtest/internal/gtest-port.h | 0 .../gtest/internal/gtest-string.h | 0 .../gtest/internal/gtest-tuple.h | 0 .../gtest/internal/gtest-tuple.h.pump | 0 .../gtest/internal/gtest-type-util.h | 0 .../gtest/internal/gtest-type-util.h.pump | 0 {src => third_party}/pugixml/CMakeLists.txt | 0 {src => third_party}/pugixml/pugiconfig.hpp | 0 {src => third_party}/pugixml/pugixml.cpp | 0 {src => third_party}/pugixml/pugixml.hpp | 0 third_party/rapidjson | 1 + .../CMakeLists.txt | 0 .../rest_service_manager_test.cc | 0 61 files changed, 43 insertions(+), 28 deletions(-) create mode 100644 .gitmodules rename {src/demo/rest/book_client => example/rest_book_client}/CMakeLists.txt (100%) rename {src/demo/rest/book_client => example/rest_book_client}/main.cc (100%) rename {src/demo/rest/book_server => example/rest_book_server}/CMakeLists.txt (100%) rename {src/demo/rest/book_server => example/rest_book_server}/book_services.cc (100%) rename {src/demo/rest/book_server => example/rest_book_server}/book_services.h (100%) rename {src/demo/rest/book_server => example/rest_book_server}/main.cc (100%) rename {src/demo/soap/calc_client => example/soap_calc_client}/CMakeLists.txt (100%) rename {src/demo/soap/calc_client => example/soap_calc_client}/calc_client.cc (100%) rename {src/demo/soap/calc_client => example/soap_calc_client}/calc_client.h (100%) rename {src/demo/soap/calc_client => example/soap_calc_client}/calculator.wsdl (100%) rename {src/demo/soap/calc_client => example/soap_calc_client}/main.cc (100%) rename {src/demo/soap/calc_server => example/soap_calc_server}/CMakeLists.txt (100%) rename {src/demo/soap/calc_server => example/soap_calc_server}/calc_service.cc (100%) rename {src/demo/soap/calc_server => example/soap_calc_server}/calc_service.h (100%) rename {src/demo/soap/calc_server => example/soap_calc_server}/main.cc (100%) delete mode 100644 src/CMakeLists.txt create mode 100644 third_party/README.txt rename {src => third_party}/gtest/CMakeLists.txt (100%) rename {src => third_party}/gtest/gtest-all.cc (100%) rename {src => third_party}/gtest/gtest-death-test.cc (100%) rename {src => third_party}/gtest/gtest-death-test.h (100%) rename {src => third_party}/gtest/gtest-filepath.cc (100%) rename {src => third_party}/gtest/gtest-internal-inl.h (100%) rename {src => third_party}/gtest/gtest-message.h (100%) rename {src => third_party}/gtest/gtest-param-test.h (100%) rename {src => third_party}/gtest/gtest-param-test.h.pump (100%) rename {src => third_party}/gtest/gtest-port.cc (100%) rename {src => third_party}/gtest/gtest-printers.cc (100%) rename {src => third_party}/gtest/gtest-printers.h (100%) rename {src => third_party}/gtest/gtest-spi.h (100%) rename {src => third_party}/gtest/gtest-test-part.cc (100%) rename {src => third_party}/gtest/gtest-test-part.h (100%) rename {src => third_party}/gtest/gtest-typed-test.cc (100%) rename {src => third_party}/gtest/gtest-typed-test.h (100%) rename {src => third_party}/gtest/gtest.cc (100%) rename {src => third_party}/gtest/gtest.h (100%) rename {src => third_party}/gtest/gtest_main.cc (100%) rename {src => third_party}/gtest/gtest_pred_impl.h (100%) rename {src => third_party}/gtest/gtest_prod.h (100%) rename {src => third_party}/gtest/internal/gtest-death-test-internal.h (100%) rename {src => third_party}/gtest/internal/gtest-filepath.h (100%) rename {src => third_party}/gtest/internal/gtest-internal.h (100%) rename {src => third_party}/gtest/internal/gtest-linked_ptr.h (100%) rename {src => third_party}/gtest/internal/gtest-param-util-generated.h (100%) rename {src => third_party}/gtest/internal/gtest-param-util-generated.h.pump (100%) rename {src => third_party}/gtest/internal/gtest-param-util.h (100%) rename {src => third_party}/gtest/internal/gtest-port.h (100%) rename {src => third_party}/gtest/internal/gtest-string.h (100%) rename {src => third_party}/gtest/internal/gtest-tuple.h (100%) rename {src => third_party}/gtest/internal/gtest-tuple.h.pump (100%) rename {src => third_party}/gtest/internal/gtest-type-util.h (100%) rename {src => third_party}/gtest/internal/gtest-type-util.h.pump (100%) rename {src => third_party}/pugixml/CMakeLists.txt (100%) rename {src => third_party}/pugixml/pugiconfig.hpp (100%) rename {src => third_party}/pugixml/pugixml.cpp (100%) rename {src => third_party}/pugixml/pugixml.hpp (100%) create mode 160000 third_party/rapidjson rename {src/webcc_unittest => unittest}/CMakeLists.txt (100%) rename {src/webcc_unittest => unittest}/rest_service_manager_test.cc (100%) diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ff65b1d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "third_party/rapidjson"] + path = third_party/rapidjson + url = https://github.com/Tencent/rapidjson diff --git a/CMakeLists.txt b/CMakeLists.txt index 7848473..ed54b51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,16 @@ cmake_minimum_required(VERSION 3.1.0) project(webcc) -option(WEBCC_ENABLE_SOAP "Enable SOAP support (need PugiXml)?" ON) -option(WEBCC_ENABLE_UT "Enable unit test?" ON) -option(WEBCC_ENABLE_DEMO "Enable demo programs?" ON) +option(WEBCC_ENABLE_SOAP "Enable SOAP support (need pugixml)?" ON) +option(WEBCC_BUILD_UNITTEST "Build unit test?" ON) +option(WEBCC_BUILD_REST_EXAMPLE "Build REST example?" ON) +option(WEBCC_BUILD_SOAP_EXAMPLE "Build SOAP example?" ON) if(WEBCC_ENABLE_SOAP) add_definitions(-DWEBCC_ENABLE_SOAP) endif() -if(WEBCC_ENABLE_UT) +if(WEBCC_BUILD_UNITTEST) enable_testing() endif() @@ -77,6 +78,35 @@ if(Boost_FOUND) message(STATUS ${Boost_LIBRARIES}) endif() +# For including its own headers as "webcc/http_client.h". include_directories(${PROJECT_SOURCE_DIR}/src) -add_subdirectory(src) +# SOAP support needs pugixml to parse and create XML. +if(WEBCC_ENABLE_SOAP) + add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/pugixml) + + # For including pugixml as "pugixml/pugixml.hpp". + # TODO: Remove "pugixml" prefix? + include_directories(${PROJECT_SOURCE_DIR}/third_party) +endif() + +add_subdirectory(src/webcc) + +if(WEBCC_BUILD_REST_EXAMPLE) + # REST example needs rapidjson to parse and create JSON. + # rapidjson is included as a Git submodule. + include_directories(${PROJECT_SOURCE_DIR}/third_party/rapidjson/include) + + add_subdirectory(${PROJECT_SOURCE_DIR}/example/rest_book_server) + add_subdirectory(${PROJECT_SOURCE_DIR}/example/rest_book_client) +endif() + +if(WEBCC_BUILD_SOAP_EXAMPLE) + add_subdirectory(${PROJECT_SOURCE_DIR}/example/soap_calc_server) + add_subdirectory(${PROJECT_SOURCE_DIR}/example/soap_calc_client) +endif() + +if(WEBCC_BUILD_UNITTEST) + add_subdirectory(third_party/gtest) + add_subdirectory(unittest) +endif() diff --git a/src/demo/rest/book_client/CMakeLists.txt b/example/rest_book_client/CMakeLists.txt similarity index 100% rename from src/demo/rest/book_client/CMakeLists.txt rename to example/rest_book_client/CMakeLists.txt diff --git a/src/demo/rest/book_client/main.cc b/example/rest_book_client/main.cc similarity index 100% rename from src/demo/rest/book_client/main.cc rename to example/rest_book_client/main.cc diff --git a/src/demo/rest/book_server/CMakeLists.txt b/example/rest_book_server/CMakeLists.txt similarity index 100% rename from src/demo/rest/book_server/CMakeLists.txt rename to example/rest_book_server/CMakeLists.txt diff --git a/src/demo/rest/book_server/book_services.cc b/example/rest_book_server/book_services.cc similarity index 100% rename from src/demo/rest/book_server/book_services.cc rename to example/rest_book_server/book_services.cc diff --git a/src/demo/rest/book_server/book_services.h b/example/rest_book_server/book_services.h similarity index 100% rename from src/demo/rest/book_server/book_services.h rename to example/rest_book_server/book_services.h diff --git a/src/demo/rest/book_server/main.cc b/example/rest_book_server/main.cc similarity index 100% rename from src/demo/rest/book_server/main.cc rename to example/rest_book_server/main.cc diff --git a/src/demo/soap/calc_client/CMakeLists.txt b/example/soap_calc_client/CMakeLists.txt similarity index 100% rename from src/demo/soap/calc_client/CMakeLists.txt rename to example/soap_calc_client/CMakeLists.txt diff --git a/src/demo/soap/calc_client/calc_client.cc b/example/soap_calc_client/calc_client.cc similarity index 100% rename from src/demo/soap/calc_client/calc_client.cc rename to example/soap_calc_client/calc_client.cc diff --git a/src/demo/soap/calc_client/calc_client.h b/example/soap_calc_client/calc_client.h similarity index 100% rename from src/demo/soap/calc_client/calc_client.h rename to example/soap_calc_client/calc_client.h diff --git a/src/demo/soap/calc_client/calculator.wsdl b/example/soap_calc_client/calculator.wsdl similarity index 100% rename from src/demo/soap/calc_client/calculator.wsdl rename to example/soap_calc_client/calculator.wsdl diff --git a/src/demo/soap/calc_client/main.cc b/example/soap_calc_client/main.cc similarity index 100% rename from src/demo/soap/calc_client/main.cc rename to example/soap_calc_client/main.cc diff --git a/src/demo/soap/calc_server/CMakeLists.txt b/example/soap_calc_server/CMakeLists.txt similarity index 100% rename from src/demo/soap/calc_server/CMakeLists.txt rename to example/soap_calc_server/CMakeLists.txt diff --git a/src/demo/soap/calc_server/calc_service.cc b/example/soap_calc_server/calc_service.cc similarity index 100% rename from src/demo/soap/calc_server/calc_service.cc rename to example/soap_calc_server/calc_service.cc diff --git a/src/demo/soap/calc_server/calc_service.h b/example/soap_calc_server/calc_service.h similarity index 100% rename from src/demo/soap/calc_server/calc_service.h rename to example/soap_calc_server/calc_service.h diff --git a/src/demo/soap/calc_server/main.cc b/example/soap_calc_server/main.cc similarity index 100% rename from src/demo/soap/calc_server/main.cc rename to example/soap_calc_server/main.cc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 5ce4f6d..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -if(UNIX) - add_definitions(-std=c++11) -endif() - -if(WEBCC_ENABLE_UT) - add_subdirectory(gtest) - add_subdirectory(webcc_unittest) -endif() - -if(WEBCC_ENABLE_SOAP) - add_subdirectory(pugixml) -endif() - -add_subdirectory(webcc) - -if(WEBCC_ENABLE_DEMO) - if(WEBCC_ENABLE_SOAP) - add_subdirectory(demo/soap/calc_client) - add_subdirectory(demo/soap/calc_server) - endif() - add_subdirectory(demo/rest/book_client) - add_subdirectory(demo/rest/book_server) -endif() diff --git a/third_party/README.txt b/third_party/README.txt new file mode 100644 index 0000000..e7f5a96 --- /dev/null +++ b/third_party/README.txt @@ -0,0 +1,4 @@ +Rapidjson is included as a Git submodule because it's a header-only library and easy to integrate. +Pugixml is not a Git submodule because its Git repo is not well structured. It does have a CMakeLists.txt but it's difficult to integrate. + +TODO: Use Git submodule for gtest? \ No newline at end of file diff --git a/src/gtest/CMakeLists.txt b/third_party/gtest/CMakeLists.txt similarity index 100% rename from src/gtest/CMakeLists.txt rename to third_party/gtest/CMakeLists.txt diff --git a/src/gtest/gtest-all.cc b/third_party/gtest/gtest-all.cc similarity index 100% rename from src/gtest/gtest-all.cc rename to third_party/gtest/gtest-all.cc diff --git a/src/gtest/gtest-death-test.cc b/third_party/gtest/gtest-death-test.cc similarity index 100% rename from src/gtest/gtest-death-test.cc rename to third_party/gtest/gtest-death-test.cc diff --git a/src/gtest/gtest-death-test.h b/third_party/gtest/gtest-death-test.h similarity index 100% rename from src/gtest/gtest-death-test.h rename to third_party/gtest/gtest-death-test.h diff --git a/src/gtest/gtest-filepath.cc b/third_party/gtest/gtest-filepath.cc similarity index 100% rename from src/gtest/gtest-filepath.cc rename to third_party/gtest/gtest-filepath.cc diff --git a/src/gtest/gtest-internal-inl.h b/third_party/gtest/gtest-internal-inl.h similarity index 100% rename from src/gtest/gtest-internal-inl.h rename to third_party/gtest/gtest-internal-inl.h diff --git a/src/gtest/gtest-message.h b/third_party/gtest/gtest-message.h similarity index 100% rename from src/gtest/gtest-message.h rename to third_party/gtest/gtest-message.h diff --git a/src/gtest/gtest-param-test.h b/third_party/gtest/gtest-param-test.h similarity index 100% rename from src/gtest/gtest-param-test.h rename to third_party/gtest/gtest-param-test.h diff --git a/src/gtest/gtest-param-test.h.pump b/third_party/gtest/gtest-param-test.h.pump similarity index 100% rename from src/gtest/gtest-param-test.h.pump rename to third_party/gtest/gtest-param-test.h.pump diff --git a/src/gtest/gtest-port.cc b/third_party/gtest/gtest-port.cc similarity index 100% rename from src/gtest/gtest-port.cc rename to third_party/gtest/gtest-port.cc diff --git a/src/gtest/gtest-printers.cc b/third_party/gtest/gtest-printers.cc similarity index 100% rename from src/gtest/gtest-printers.cc rename to third_party/gtest/gtest-printers.cc diff --git a/src/gtest/gtest-printers.h b/third_party/gtest/gtest-printers.h similarity index 100% rename from src/gtest/gtest-printers.h rename to third_party/gtest/gtest-printers.h diff --git a/src/gtest/gtest-spi.h b/third_party/gtest/gtest-spi.h similarity index 100% rename from src/gtest/gtest-spi.h rename to third_party/gtest/gtest-spi.h diff --git a/src/gtest/gtest-test-part.cc b/third_party/gtest/gtest-test-part.cc similarity index 100% rename from src/gtest/gtest-test-part.cc rename to third_party/gtest/gtest-test-part.cc diff --git a/src/gtest/gtest-test-part.h b/third_party/gtest/gtest-test-part.h similarity index 100% rename from src/gtest/gtest-test-part.h rename to third_party/gtest/gtest-test-part.h diff --git a/src/gtest/gtest-typed-test.cc b/third_party/gtest/gtest-typed-test.cc similarity index 100% rename from src/gtest/gtest-typed-test.cc rename to third_party/gtest/gtest-typed-test.cc diff --git a/src/gtest/gtest-typed-test.h b/third_party/gtest/gtest-typed-test.h similarity index 100% rename from src/gtest/gtest-typed-test.h rename to third_party/gtest/gtest-typed-test.h diff --git a/src/gtest/gtest.cc b/third_party/gtest/gtest.cc similarity index 100% rename from src/gtest/gtest.cc rename to third_party/gtest/gtest.cc diff --git a/src/gtest/gtest.h b/third_party/gtest/gtest.h similarity index 100% rename from src/gtest/gtest.h rename to third_party/gtest/gtest.h diff --git a/src/gtest/gtest_main.cc b/third_party/gtest/gtest_main.cc similarity index 100% rename from src/gtest/gtest_main.cc rename to third_party/gtest/gtest_main.cc diff --git a/src/gtest/gtest_pred_impl.h b/third_party/gtest/gtest_pred_impl.h similarity index 100% rename from src/gtest/gtest_pred_impl.h rename to third_party/gtest/gtest_pred_impl.h diff --git a/src/gtest/gtest_prod.h b/third_party/gtest/gtest_prod.h similarity index 100% rename from src/gtest/gtest_prod.h rename to third_party/gtest/gtest_prod.h diff --git a/src/gtest/internal/gtest-death-test-internal.h b/third_party/gtest/internal/gtest-death-test-internal.h similarity index 100% rename from src/gtest/internal/gtest-death-test-internal.h rename to third_party/gtest/internal/gtest-death-test-internal.h diff --git a/src/gtest/internal/gtest-filepath.h b/third_party/gtest/internal/gtest-filepath.h similarity index 100% rename from src/gtest/internal/gtest-filepath.h rename to third_party/gtest/internal/gtest-filepath.h diff --git a/src/gtest/internal/gtest-internal.h b/third_party/gtest/internal/gtest-internal.h similarity index 100% rename from src/gtest/internal/gtest-internal.h rename to third_party/gtest/internal/gtest-internal.h diff --git a/src/gtest/internal/gtest-linked_ptr.h b/third_party/gtest/internal/gtest-linked_ptr.h similarity index 100% rename from src/gtest/internal/gtest-linked_ptr.h rename to third_party/gtest/internal/gtest-linked_ptr.h diff --git a/src/gtest/internal/gtest-param-util-generated.h b/third_party/gtest/internal/gtest-param-util-generated.h similarity index 100% rename from src/gtest/internal/gtest-param-util-generated.h rename to third_party/gtest/internal/gtest-param-util-generated.h diff --git a/src/gtest/internal/gtest-param-util-generated.h.pump b/third_party/gtest/internal/gtest-param-util-generated.h.pump similarity index 100% rename from src/gtest/internal/gtest-param-util-generated.h.pump rename to third_party/gtest/internal/gtest-param-util-generated.h.pump diff --git a/src/gtest/internal/gtest-param-util.h b/third_party/gtest/internal/gtest-param-util.h similarity index 100% rename from src/gtest/internal/gtest-param-util.h rename to third_party/gtest/internal/gtest-param-util.h diff --git a/src/gtest/internal/gtest-port.h b/third_party/gtest/internal/gtest-port.h similarity index 100% rename from src/gtest/internal/gtest-port.h rename to third_party/gtest/internal/gtest-port.h diff --git a/src/gtest/internal/gtest-string.h b/third_party/gtest/internal/gtest-string.h similarity index 100% rename from src/gtest/internal/gtest-string.h rename to third_party/gtest/internal/gtest-string.h diff --git a/src/gtest/internal/gtest-tuple.h b/third_party/gtest/internal/gtest-tuple.h similarity index 100% rename from src/gtest/internal/gtest-tuple.h rename to third_party/gtest/internal/gtest-tuple.h diff --git a/src/gtest/internal/gtest-tuple.h.pump b/third_party/gtest/internal/gtest-tuple.h.pump similarity index 100% rename from src/gtest/internal/gtest-tuple.h.pump rename to third_party/gtest/internal/gtest-tuple.h.pump diff --git a/src/gtest/internal/gtest-type-util.h b/third_party/gtest/internal/gtest-type-util.h similarity index 100% rename from src/gtest/internal/gtest-type-util.h rename to third_party/gtest/internal/gtest-type-util.h diff --git a/src/gtest/internal/gtest-type-util.h.pump b/third_party/gtest/internal/gtest-type-util.h.pump similarity index 100% rename from src/gtest/internal/gtest-type-util.h.pump rename to third_party/gtest/internal/gtest-type-util.h.pump diff --git a/src/pugixml/CMakeLists.txt b/third_party/pugixml/CMakeLists.txt similarity index 100% rename from src/pugixml/CMakeLists.txt rename to third_party/pugixml/CMakeLists.txt diff --git a/src/pugixml/pugiconfig.hpp b/third_party/pugixml/pugiconfig.hpp similarity index 100% rename from src/pugixml/pugiconfig.hpp rename to third_party/pugixml/pugiconfig.hpp diff --git a/src/pugixml/pugixml.cpp b/third_party/pugixml/pugixml.cpp similarity index 100% rename from src/pugixml/pugixml.cpp rename to third_party/pugixml/pugixml.cpp diff --git a/src/pugixml/pugixml.hpp b/third_party/pugixml/pugixml.hpp similarity index 100% rename from src/pugixml/pugixml.hpp rename to third_party/pugixml/pugixml.hpp diff --git a/third_party/rapidjson b/third_party/rapidjson new file mode 160000 index 0000000..8022a5f --- /dev/null +++ b/third_party/rapidjson @@ -0,0 +1 @@ +Subproject commit 8022a5f79c7490e2a9dd5934ac9c77b6d5555a6d diff --git a/src/webcc_unittest/CMakeLists.txt b/unittest/CMakeLists.txt similarity index 100% rename from src/webcc_unittest/CMakeLists.txt rename to unittest/CMakeLists.txt diff --git a/src/webcc_unittest/rest_service_manager_test.cc b/unittest/rest_service_manager_test.cc similarity index 100% rename from src/webcc_unittest/rest_service_manager_test.cc rename to unittest/rest_service_manager_test.cc