From 1eeda1a22b986f125130bd3be2063190ab941ea4 Mon Sep 17 00:00:00 2001 From: The-EDev Date: Sun, 4 Apr 2021 07:47:14 +0300 Subject: [PATCH 1/7] mentioned crow_main in docs and edited mime_types generating script to include it. --- docs/getting_started/your_first_application.md | 6 +++++- docs/guides/proxies.md | 2 +- scripts/nginx_mime2cpp.py | 10 +++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/getting_started/your_first_application.md b/docs/getting_started/your_first_application.md index 4f81f9953..eeab55a0c 100644 --- a/docs/getting_started/your_first_application.md +++ b/docs/getting_started/your_first_application.md @@ -1,7 +1,11 @@ This page shows how you can get started with a simple hello world application. ##1. Include -Starting with an empty `main.cpp` file, add `#!cpp #include "crow.h"` or `#!cpp #include "crow_all.h"` if you're using the single header file. +Starting with an empty `main.cpp` file, add `#!cpp #CROW_MAIN` then `#!cpp #include "crow.h"` or `#!cpp #include "crow_all.h"` if you're using the single header file. + +!!! note + + If you're using multiple C++ source files make sure to have `#CROW_MAIN` defined only in your main source file. ##2. App declaration Next Create a `main()` and declare a `#!cpp crow::SimpleApp` inside, your code should look like this diff --git a/docs/guides/proxies.md b/docs/guides/proxies.md index ff43ef97e..2c446aeb7 100644 --- a/docs/guides/proxies.md +++ b/docs/guides/proxies.md @@ -37,7 +37,7 @@ If you want crow to run in a subdirectory (such as `domain.abc/crow`) you can us !!! note - If you're using an Arch Linux based OS. You will have to access `/etc/httpd/conf/httpd.conf` to enable modules and change configuration + If you're using an Arch Linux based OS. You will have to access `/etc/httpd/conf/httpd.conf` to enable modules and change configuration. ##Nginx diff --git a/scripts/nginx_mime2cpp.py b/scripts/nginx_mime2cpp.py index 6df50dab4..a6f61c43d 100755 --- a/scripts/nginx_mime2cpp.py +++ b/scripts/nginx_mime2cpp.py @@ -20,6 +20,8 @@ def main(): "#include ", "", "namespace crow {", + "", + "#ifdef CROW_MAIN" tabspace + "std::unordered_map mime_types {"]) with open(file_path, "r") as mtfile: @@ -40,7 +42,13 @@ def main(): outLines.extend(mime_line_to_cpp(splitLine)) outLines[-1] = outLines[-1][:-1] - outLines.extend([tabspace + "};", "}"]) + outLines.extend([ + tabspace + "};", + "#else", + "extern std::unordered_map mime_types;", + "#endif", + "}" + ]) with open(output_path, "w") as mtcppfile: mtcppfile.writelines(x + '\n' for x in outLines) From 111bef9debd42fc2d42f3765b38926aa237fa286 Mon Sep 17 00:00:00 2001 From: The-EDev Date: Sun, 4 Apr 2021 08:09:59 +0300 Subject: [PATCH 2/7] use actual ASIO port instead of the local port variable this is useful when using port 0 to have the OS provide a free port --- include/crow/http_server.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/crow/http_server.h b/include/crow/http_server.h index d7209330c..de2c5aab7 100644 --- a/include/crow/http_server.h +++ b/include/crow/http_server.h @@ -146,7 +146,7 @@ namespace crow }); } - CROW_LOG_INFO << server_name_ << " server is running at " << bindaddr_ <<":" << port_ + CROW_LOG_INFO << server_name_ << " server is running at " << bindaddr_ <<":" << acceptor_.local_endpoint().port() << " using " << concurrency_ << " threads"; CROW_LOG_INFO << "Call `app.loglevel(crow::LogLevel::Warning)` to hide Info level logs."; From 598f60b83e12c1c6cfc0de28c06773a9b8460f07 Mon Sep 17 00:00:00 2001 From: The-EDev Date: Sun, 4 Apr 2021 22:01:34 +0300 Subject: [PATCH 3/7] potential fix for coveralls not appearing in github status --- .coveralls.yml | 4 ++++ .drone.yml | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 000000000..6cd8da205 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,4 @@ +service_name: drone-io +gcov_options: \-lp +include: + - include diff --git a/.drone.yml b/.drone.yml index e3d0838fa..e248029ab 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,9 +15,10 @@ steps: commands: - export DEBIAN_FRONTEND=noninteractive + - export CI_BRANCH=$DRONE_REPO_BRANCH - apt-get -y update - apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git - - pip3 install mkdocs-material cpp-coveralls + - pip3 install mkdocs-material cpp-coveralls pyyaml - export CC=/usr/bin/gcc - export CXX=/usr/bin/g++ - mkdir build @@ -25,14 +26,13 @@ steps: - cmake .. - make -j4 && ctest -V -j4 - cd .. + - coveralls --verbose --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp - export CC=/usr/bin/clang - export CXX=/usr/bin/clang++ - mkdir build-clang - cd build-clang - cmake .. - make -j4 && ctest -V -j4 - - cd .. - - coveralls -i include --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp --gcov-options '\-lp' trigger: branch: @@ -100,9 +100,10 @@ steps: - export DRONE_BUILD_DIR=$PWD - export DEBIAN_FRONTEND=noninteractive - export DOXYFILE=$DRONE_BUILD_DIR/Doxyfile + - export CI_BRANCH=$DRONE_REPO_BRANCH - apt-get -y update - apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git - - pip3 install mkdocs-material cpp-coveralls + - pip3 install mkdocs-material cpp-coveralls pyyaml - export CC=/usr/bin/gcc - export CXX=/usr/bin/g++ - mkdir build @@ -110,6 +111,7 @@ steps: - cmake .. - make -j4 && ctest -V -j4 - cd .. + - coveralls --verbose --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp - export CC=/usr/bin/clang - export CXX=/usr/bin/clang++ - mkdir build-clang @@ -117,7 +119,6 @@ steps: - cmake .. - make -j4 && ctest -V -j4 - cd .. - - coveralls -i include --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp --gcov-options '\-lp' - chmod +x scripts/generateDocumentationAndDeploy.sh - ./scripts/generateDocumentationAndDeploy.sh From 553fae93bbb43c010b89321d7a0c9a9d1318aa63 Mon Sep 17 00:00:00 2001 From: The-EDev Date: Mon, 5 Apr 2021 07:18:45 +0300 Subject: [PATCH 4/7] fixed issue where "drone ignored failing make or ctest commands unless nothing else ran afterwards" --- .drone.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index e248029ab..598576f82 100644 --- a/.drone.yml +++ b/.drone.yml @@ -24,7 +24,8 @@ steps: - mkdir build - cd build - cmake .. - - make -j4 && ctest -V -j4 + - make -j4 + - ctest -V -j4 - cd .. - coveralls --verbose --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp - export CC=/usr/bin/clang @@ -32,7 +33,8 @@ steps: - mkdir build-clang - cd build-clang - cmake .. - - make -j4 && ctest -V -j4 + - make -j4 + - ctest -V -j4 trigger: branch: @@ -60,14 +62,16 @@ steps: - cd build - cmake --version - cmake .. - - make -j4 && ctest -V -j4 + - make -j4 + - ctest -V -j4 - cd .. - export CC=/usr/bin/clang - export CXX=/usr/bin/clang++ - mkdir build-clang - cd build-clang - cmake .. - - make -j4 && ctest -V -j4 + - make -j4 + - ctest -V -j4 trigger: branch: @@ -109,7 +113,8 @@ steps: - mkdir build - cd build - cmake .. - - make -j4 && ctest -V -j4 + - make -j4 + - ctest -V -j4 - cd .. - coveralls --verbose --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp - export CC=/usr/bin/clang @@ -117,7 +122,8 @@ steps: - mkdir build-clang - cd build-clang - cmake .. - - make -j4 && ctest -V -j4 + - make -j4 + - ctest -V -j4 - cd .. - chmod +x scripts/generateDocumentationAndDeploy.sh - ./scripts/generateDocumentationAndDeploy.sh @@ -148,14 +154,16 @@ steps: - cd build - cmake --version - cmake .. - - make -j4 && ctest -V -j4 + - make -j4 + - ctest -V -j4 - cd .. - export CC=/usr/bin/clang - export CXX=/usr/bin/clang++ - mkdir build-clang - cd build-clang - cmake .. - - make -j4 && ctest -V -j4 + - make -j4 + - ctest -V -j4 trigger: branch: From d569d121c0fe062f51e54b38bfc9176bd53bba26 Mon Sep 17 00:00:00 2001 From: The-EDev Date: Tue, 6 Apr 2021 10:39:35 +0300 Subject: [PATCH 5/7] fixed incorrect branch variable being used --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 598576f82..1d6789c4f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,7 @@ steps: commands: - export DEBIAN_FRONTEND=noninteractive - - export CI_BRANCH=$DRONE_REPO_BRANCH + - export CI_BRANCH=$DRONE_SOURCE_BRANCH - apt-get -y update - apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git - pip3 install mkdocs-material cpp-coveralls pyyaml From e592e6b4f2e449b6c0572862665ee9cdd374fec4 Mon Sep 17 00:00:00 2001 From: Ulrich Germann Date: Tue, 6 Apr 2021 11:17:51 +0000 Subject: [PATCH 6/7] Fix error in examples/CMakeLists.txt cmake 3.19 complained about Line 49: > CMake Error at examples/CMakeLists.txt:49 (target_link_libraries): > The keyword signature for target_link_libraries has already been used with > the target "basic_example". All uses of target_link_libraries with a > target must be either all-keyword or all-plain. > > The uses of the keyword signature are here: > > * examples/CMakeLists.txt:46 (target_link_libraries) The reason is the missing keyword PRIVATE/INTERFACE/PUBLIC in the offending line. This edit fixes this. --- examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index cd0eaaff6..aaece1996 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -46,7 +46,7 @@ else () target_link_libraries(basic_example PUBLIC ${REQUIRED_LIBRARIES}) if (Tcmalloc_FOUND) - target_link_libraries(basic_example ${Tcmalloc_LIBRARIES}) + target_link_libraries(basic_example PRIVATE ${Tcmalloc_LIBRARIES}) endif(Tcmalloc_FOUND) add_executable(example_with_all example_with_all.cpp) From 570ed2e04e0f2cb1a4dac56693d7b1beb338abc2 Mon Sep 17 00:00:00 2001 From: The-EDev Date: Wed, 7 Apr 2021 03:36:11 +0300 Subject: [PATCH 7/7] changed CI_BRANCH to TRAVIS_BRANCH I do not know why this works, but it worked on my test repository --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 1d6789c4f..bbf1597d1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,7 @@ steps: commands: - export DEBIAN_FRONTEND=noninteractive - - export CI_BRANCH=$DRONE_SOURCE_BRANCH + - export TRAVIS_BRANCH=$DRONE_SOURCE_BRANCH - apt-get -y update - apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git - pip3 install mkdocs-material cpp-coveralls pyyaml @@ -104,7 +104,7 @@ steps: - export DRONE_BUILD_DIR=$PWD - export DEBIAN_FRONTEND=noninteractive - export DOXYFILE=$DRONE_BUILD_DIR/Doxyfile - - export CI_BRANCH=$DRONE_REPO_BRANCH + - export TRAVIS_BRANCH=$DRONE_REPO_BRANCH - apt-get -y update - apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git - pip3 install mkdocs-material cpp-coveralls pyyaml