diff --git a/.travis.yml b/.travis.yml index 7ae7cfec..5aa66c2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,28 @@ env: - LINKING="static" before_install: - eval "${MATRIX_EVAL}" + # Installing iwyu manually because clang and iwyu paths won't match on Ubuntu otherwise. + - if [ "$IWYU" = "iwyu" ]; then + CLANG_VERSION=`clang --version | grep version | cut -f3 -d' ' | cut -f1 -d'-'` ; + CLANG_PKG_VERSION=`echo $CLANG_VERSION | cut -f1,2 -d'.'` + CLANG_PREFIX_PATH="/usr/local/clang-${CLANG_VERSION}/lib/clang/${CLANG_VERSION}" ; + CLANG_BIN_PATH="/usr/local/clang-${CLANG_VERSION}/bin" ; + git clone https://github.com/include-what-you-use/include-what-you-use.git ; + cd include-what-you-use ; + echo "$CLANG_PKG_VERSION" | grep '\.[0-9]$' ; + if [ $? -eq 0 ]; then + git checkout clang_${CLANG_PKG_VERSION} ; + else + git checkout clang_${CLANG_PKG_VERSION}.0 ; + fi; + cd .. ; + mkdir build_iwyu ; + cd build_iwyu ; + cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=$CLANG_PREFIX_PATH -DCMAKE_C_COMPILER=$CLANG_BIN_PATH/clang -DCMAKE_CXX_COMPILER=$CLANG_BIN_PATH/clang++ ../include-what-you-use ; + make ; + sudo make install ; + cd .. ; + fi - export LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/lib" - export PATH=$PATH:/usr/local/lib - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib @@ -37,7 +59,8 @@ install: - ./bootstrap - mkdir build - cd build - - if [ "$LINKING" = "static" ]; then + - | + if [ "$LINKING" = "static" ]; then ../configure --enable-static --disable-fastopen; elif [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ]; then ../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen; @@ -45,13 +68,23 @@ install: ../configure --enable-debug --disable-shared --disable-fastopen; elif [ "$VALGRIND" = "valgrind" ]; then ../configure --enable-debug --disable-fastopen --disable-valgrind-helgrind --disable-valgrind-drd --disable-valgrind-sgcheck; + elif [ "$IWYU" = "iwyu" ]; then + ../configure --disable-examples; else ../configure --disable-fastopen; fi - - make + # Make or run iwyu. If running iwyu, check for the result code to be 2 (IWYU always returns an error code, if it is 2, no corrections are necessary). + - | + if [ "$IWYU" = "iwyu" ]; then + make -k CXX='/usr/local/bin/include-what-you-use -Xiwyu --mapping_file=${top_builddir}/../custom_iwyu.imp' CXXFLAGS="-isystem ${CLANG_PREFIX_PATH}/include -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT $CXXFLAGS" ; + if [ $? -ne 2 ]; then + return 1; + fi + else + make; + fi script: - - make check - - cat test/test-suite.log + - if [ "$IWYU" != "iwyu" ]; then make check; cat test/test-suite.log; fi - if [ "$VALGRIND" = "valgrind" ]; then make check-valgrind; fi; - if [ "$VALGRIND" = "valgrind" ]; then cat test/test-suite-memcheck.log; fi; - if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ../src/; cppcheck --error-exitcode=1 .; cd ../build; fi @@ -309,3 +342,17 @@ matrix: - clang-9 env: - MATRIX_EVAL="CC=clang-9 && CXX=clang++-9" + - os: linux + compiler: clang + addons: + apt: + sources: + - llvm-toolchain-xenial-7 + - ubuntu-toolchain-r-test + packages: + - iwyu + - cmake + - llvm-dev + - libclang-dev + env: + - MATRIX_EVAL="IWYU=iwyu" diff --git a/appveyor.yml b/appveyor.yml index 4fc56074..c86df7e5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,13 +1,5 @@ platform: x64 -branches: - except: - - /.*travis.*/ -skip_commits: - message: /travis/ - files: - - .travis.yml - environment: matrix: - compiler: msys2 diff --git a/custom_iwyu.imp b/custom_iwyu.imp new file mode 100644 index 00000000..e814a310 --- /dev/null +++ b/custom_iwyu.imp @@ -0,0 +1,17 @@ +[ + { include: ["\"microhttpd.h\"", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + + { symbol: ["std::exception", "private", "", "public"]}, + { symbol: ["std::shared_ptr", "private", "", "public"]}, + { symbol: ["std::uint16_t", "private", "", "public"]}, + { symbol: ["std::uint64_t", "private", "", "public"]}, + { symbol: ["std::istringstream", "private", "", "public"]}, + { symbol: ["std::stringstream", "private", "", "public"]}, + { symbol: ["std::ifstream", "private", "", "public"]}, + + { symbol: ["uint16_t", "private", "", "public"]}, + { symbol: ["uint64_t", "private", "", "public"]}, + + { symbol: ["MHD_Connection", "private", "", "public"]}, +] diff --git a/src/basic_auth_fail_response.cpp b/src/basic_auth_fail_response.cpp index 500fceb6..49d9f5a9 100644 --- a/src/basic_auth_fail_response.cpp +++ b/src/basic_auth_fail_response.cpp @@ -19,6 +19,10 @@ */ #include "httpserver/basic_auth_fail_response.hpp" +#include + +struct MHD_Connection; +struct MHD_Response; using namespace std; diff --git a/src/deferred_response.cpp b/src/deferred_response.cpp index 08033c80..f3d44527 100644 --- a/src/deferred_response.cpp +++ b/src/deferred_response.cpp @@ -19,6 +19,9 @@ */ #include "httpserver/deferred_response.hpp" +#include + +struct MHD_Response; using namespace std; diff --git a/src/details/http_endpoint.cpp b/src/details/http_endpoint.cpp index be76ddde..584fb507 100644 --- a/src/details/http_endpoint.cpp +++ b/src/details/http_endpoint.cpp @@ -18,12 +18,18 @@ USA */ +#include +#include +#include +#include +#include #include +#include +#include +#include #include "httpserver/details/http_endpoint.hpp" - #include "httpserver/http_utils.hpp" -#include "httpserver/string_utilities.hpp" using namespace std; diff --git a/src/digest_auth_fail_response.cpp b/src/digest_auth_fail_response.cpp index d2fd5263..ca95526d 100644 --- a/src/digest_auth_fail_response.cpp +++ b/src/digest_auth_fail_response.cpp @@ -19,6 +19,10 @@ */ #include "httpserver/digest_auth_fail_response.hpp" +#include + +struct MHD_Connection; +struct MHD_Response; using namespace std; diff --git a/src/file_response.cpp b/src/file_response.cpp index 1503e4bd..66d13a1c 100644 --- a/src/file_response.cpp +++ b/src/file_response.cpp @@ -19,8 +19,12 @@ */ #include "httpserver/file_response.hpp" - #include +#include +#include +#include + +struct MHD_Response; using namespace std; diff --git a/src/http_request.cpp b/src/http_request.cpp index be342c7c..d7d8e2af 100644 --- a/src/http_request.cpp +++ b/src/http_request.cpp @@ -20,9 +20,9 @@ */ #include "httpserver/http_request.hpp" - +#include +#include #include - #include "httpserver/http_utils.hpp" #include "httpserver/string_utilities.hpp" diff --git a/src/http_resource.cpp b/src/http_resource.cpp index 0fc6402a..46bdb0de 100644 --- a/src/http_resource.cpp +++ b/src/http_resource.cpp @@ -19,15 +19,10 @@ */ #include "httpserver/http_resource.hpp" - -#include - -#include "httpserver/http_request.hpp" -#include "httpserver/http_response.hpp" -#include "httpserver/http_utils.hpp" +#include #include "httpserver/string_response.hpp" -#include "httpserver/string_utilities.hpp" -#include "httpserver/webserver.hpp" + +namespace httpserver { class http_response; } using namespace std; diff --git a/src/http_response.cpp b/src/http_response.cpp index c502f2ac..2d261e3d 100644 --- a/src/http_response.cpp +++ b/src/http_response.cpp @@ -19,16 +19,10 @@ */ #include "httpserver/http_response.hpp" - -#include -#include -#include -#include +#include #include -#include - +#include #include "httpserver/http_utils.hpp" -#include "httpserver/webserver.hpp" using namespace std; diff --git a/src/http_utils.cpp b/src/http_utils.cpp index c9d3aa66..caefabc5 100644 --- a/src/http_utils.cpp +++ b/src/http_utils.cpp @@ -24,9 +24,6 @@ #include #include #else // WIN32 check -#if defined(__FreeBSD__) -#include -#endif // FreeBSD #include #include #include @@ -36,10 +33,10 @@ #include #include -#include -#include #include -#include +#include +#include +#include #include #include #include diff --git a/src/httpserver/basic_auth_fail_response.hpp b/src/httpserver/basic_auth_fail_response.hpp index c7e2d476..a28fa3d9 100644 --- a/src/httpserver/basic_auth_fail_response.hpp +++ b/src/httpserver/basic_auth_fail_response.hpp @@ -25,8 +25,13 @@ #ifndef _BASIC_AUTH_FAIL_RESPONSE_HPP_ #define _BASIC_AUTH_FAIL_RESPONSE_HPP_ +#include +#include "http_utils.hpp" #include "httpserver/string_response.hpp" +struct MHD_Connection; +struct MHD_Response; + namespace httpserver { diff --git a/src/httpserver/deferred_response.hpp b/src/httpserver/deferred_response.hpp index 2193f960..9e4601e2 100644 --- a/src/httpserver/deferred_response.hpp +++ b/src/httpserver/deferred_response.hpp @@ -25,10 +25,16 @@ #ifndef _DEFERRED_RESPONSE_HPP_ #define _DEFERRED_RESPONSE_HPP_ +#include +#include +#include #include - +#include +#include "http_utils.hpp" #include "httpserver/string_response.hpp" +struct MHD_Response; + namespace httpserver { diff --git a/src/httpserver/digest_auth_fail_response.hpp b/src/httpserver/digest_auth_fail_response.hpp index 292f477b..50abcee2 100644 --- a/src/httpserver/digest_auth_fail_response.hpp +++ b/src/httpserver/digest_auth_fail_response.hpp @@ -25,8 +25,13 @@ #ifndef _DIGEST_AUTH_FAIL_RESPONSE_HPP_ #define _DIGEST_AUTH_FAIL_RESPONSE_HPP_ +#include +#include "http_utils.hpp" #include "httpserver/string_response.hpp" +struct MHD_Connection; +struct MHD_Response; + namespace httpserver { diff --git a/src/httpserver/file_response.hpp b/src/httpserver/file_response.hpp index cb80c114..0c9386fb 100644 --- a/src/httpserver/file_response.hpp +++ b/src/httpserver/file_response.hpp @@ -25,8 +25,12 @@ #ifndef _FILE_RESPONSE_HPP_ #define _FILE_RESPONSE_HPP_ +#include +#include "http_utils.hpp" #include "httpserver/http_response.hpp" +struct MHD_Response; + namespace httpserver { diff --git a/src/httpserver/http_request.hpp b/src/httpserver/http_request.hpp index 62e52751..6aacbfe6 100644 --- a/src/httpserver/http_request.hpp +++ b/src/httpserver/http_request.hpp @@ -25,6 +25,10 @@ #ifndef _HTTP_REQUEST_HPP_ #define _HTTP_REQUEST_HPP_ +#include + +#include +#include #include #include #include @@ -38,14 +42,6 @@ struct MHD_Connection; namespace httpserver { -class webserver; - -namespace http -{ - class header_comparator; - class arg_comparator; -}; - /** * Class representing an abstraction for an Http Request. It is used from classes using these apis to receive information through http protocol. **/ diff --git a/src/httpserver/http_resource.hpp b/src/httpserver/http_resource.hpp index 7841b96b..04f67cb8 100644 --- a/src/httpserver/http_resource.hpp +++ b/src/httpserver/http_resource.hpp @@ -28,24 +28,18 @@ #ifdef DEBUG #include #endif + #include #include #include +#include -#include "httpserver/http_response.hpp" - -namespace httpserver -{ +namespace httpserver { class http_request; } +namespace httpserver { class http_response; } -class webserver; -class http_request; +namespace httpserver { -namespace details -{ - -std::shared_ptr empty_render(const http_request& r); - -}; +namespace details { std::shared_ptr empty_render(const http_request& r); }; /** * Class representing a callable http resource. diff --git a/src/httpserver/http_response.hpp b/src/httpserver/http_response.hpp index 33c1df42..1f3f0971 100644 --- a/src/httpserver/http_response.hpp +++ b/src/httpserver/http_response.hpp @@ -27,11 +27,7 @@ #include #include -#include #include -#include -#include - #include "httpserver/http_utils.hpp" struct MHD_Connection; diff --git a/src/httpserver/http_utils.hpp b/src/httpserver/http_utils.hpp index a8121977..e2aa0339 100644 --- a/src/httpserver/http_utils.hpp +++ b/src/httpserver/http_utils.hpp @@ -43,9 +43,14 @@ #endif #include +#include + +#if !defined(__MINGW32__) +#include +#endif + #include #include -#include #include #include #include diff --git a/src/httpserver/string_response.hpp b/src/httpserver/string_response.hpp index 1c2183d0..43e7580d 100644 --- a/src/httpserver/string_response.hpp +++ b/src/httpserver/string_response.hpp @@ -25,8 +25,13 @@ #ifndef _STRING_RESPONSE_HPP_ #define _STRING_RESPONSE_HPP_ +#include +#include +#include "http_utils.hpp" #include "httpserver/http_response.hpp" +struct MHD_Response; + namespace httpserver { diff --git a/src/httpserver/webserver.hpp b/src/httpserver/webserver.hpp index c1ca06de..02d626c5 100644 --- a/src/httpserver/webserver.hpp +++ b/src/httpserver/webserver.hpp @@ -30,35 +30,32 @@ #define NOT_METHOD_ERROR "Method not Acceptable" #define GENERIC_ERROR "Internal Error" +#include #include +#include +#include #include -#include -#include + +#if !defined(__MINGW32__) +#include +#endif + #include #include #include -#include #include -#include -#include +#include "http_utils.hpp" #include "httpserver/create_webserver.hpp" #include "httpserver/details/http_endpoint.hpp" -#include "httpserver/http_response.hpp" -namespace httpserver { +namespace httpserver { class http_resource; } +namespace httpserver { class http_response; } +namespace httpserver { namespace details { struct modded_request; } } -class http_resource; -class create_webserver; +struct MHD_Connection; -namespace http { -struct ip_representation; -struct httpserver_ska; -}; - -namespace details { - struct modded_request; -} +namespace httpserver { /** * Class representing the webserver. Main class of the apis. diff --git a/src/string_response.cpp b/src/string_response.cpp index 7720d61b..75a557f8 100644 --- a/src/string_response.cpp +++ b/src/string_response.cpp @@ -19,6 +19,10 @@ */ #include "httpserver/string_response.hpp" +#include +#include + +struct MHD_Response; using namespace std; diff --git a/src/string_utilities.cpp b/src/string_utilities.cpp index c557fe06..a3937f2e 100644 --- a/src/string_utilities.cpp +++ b/src/string_utilities.cpp @@ -22,9 +22,6 @@ #include #include -#include -#include -#include #include #include #include diff --git a/src/webserver.cpp b/src/webserver.cpp index 6b7dd47f..38542f2a 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -31,26 +31,16 @@ #if defined(__CYGWIN__) #include #endif -#include +#include #include #endif #include -#include -#include #include #include -#include #include #include #include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -67,7 +57,8 @@ #include "httpserver/http_response.hpp" #include "httpserver/http_utils.hpp" #include "httpserver/string_response.hpp" -#include "httpserver/string_utilities.hpp" + +struct MHD_Connection; #define _REENTRANT 1