From dd5c97d633da95609e2950a47492ccae2af5a536 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 1 May 2023 15:16:13 +0300 Subject: [PATCH 1/7] add minimal ci --- .github/workflows/ci.yml | 53 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7a67001 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: Cpp + +on: + push: + branches: [ "dev", "main" ] + pull_request: + branches: [ "dev", "main" ] + +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Installing + run: | + sudo apt update + git clone https://github.com/google/googletest.git -b release-1.11.0 + cd googletest + mkdir build + cd build + cmake .. -DBUILD_GMOCK=OFF + make + sudo make install + cd ../.. + - name: Building + run: | + mkdir build + cd build + cmake .. + make + # - name: Testing + # run: | + # ./build/tests/test_parser + linters: + runs-on: ubuntu-latest + needs: [build] + steps: + - uses: actions/checkout@v3 + - name: Installing + run: | + sudo apt update + sudo apt install cppcheck + pip install cpplint + - name: Cppcheck + run: | + cppcheck --language=c++ ./src/main.cpp + - name: Cpplint + run: | + cpplint --filter=-legal/copyright,-readability/casting,-whitespace/tab,-build/include_subdir --linelength=110 ./src/main.cpp \ No newline at end of file diff --git a/.gitignore b/.gitignore index 29e77ea..870ca9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /cmake-build-debug/ /build/ +.vscode .idea CMakeUserPresets.json -- GitLab From 00a32a991a414ce6ec5360c3b00f29621a517f63 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 1 May 2023 16:07:35 +0300 Subject: [PATCH 2/7] add boost to ci --- .github/workflows/ci.yml | 7 +++++++ CMakeLists.txt | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a67001..2e069cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,13 @@ jobs: - name: Installing run: | sudo apt update + wget https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.tar.gz + tar xvf boost_1_82_0.tar.gz + cd boost_1_82_0 + ./bootstrap.sh --prefix=/usr/ + sudo ./b2 install + cd .. + git clone https://github.com/google/googletest.git -b release-1.11.0 cd googletest mkdir build diff --git a/CMakeLists.txt b/CMakeLists.txt index bdb1810..41ba7c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,10 @@ set(CMAKE_CXX_STANDARD 17) -cmake_minimum_required(VERSION 3.19) +cmake_minimum_required(VERSION 3.7) set(CMAKE_PREFIX_PATH build) project(SourcedOut CXX) -find_package(antlr4-runtime REQUIRED) +# find_package(antlr4-runtime REQUIRED) find_package(Boost 1.8.1 REQUIRED) -find_package(libpqxx REQUIRED) +# find_package(libpqxx REQUIRED) find_package(GTest REQUIRED) message(STATUS ${Boost_LIBRARIES}) add_executable(${PROJECT_NAME} src/main.cpp) -- GitLab From a3fecdaadf6293e166032ed8671a70af76c934b6 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 1 May 2023 18:25:08 +0300 Subject: [PATCH 3/7] create docker container --- .github/workflows/ci.yml | 26 +-- Dockerfile | 28 +++ src/main.cpp | 477 +++++++++++++++++---------------------- 3 files changed, 240 insertions(+), 291 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e069cd..3859e29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,26 +13,9 @@ defaults: jobs: build: runs-on: ubuntu-latest + container: raiden454/sourced-out steps: - uses: actions/checkout@v3 - - name: Installing - run: | - sudo apt update - wget https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.tar.gz - tar xvf boost_1_82_0.tar.gz - cd boost_1_82_0 - ./bootstrap.sh --prefix=/usr/ - sudo ./b2 install - cd .. - - git clone https://github.com/google/googletest.git -b release-1.11.0 - cd googletest - mkdir build - cd build - cmake .. -DBUILD_GMOCK=OFF - make - sudo make install - cd ../.. - name: Building run: | mkdir build @@ -44,14 +27,9 @@ jobs: # ./build/tests/test_parser linters: runs-on: ubuntu-latest + container: raiden454/sourced-out needs: [build] steps: - - uses: actions/checkout@v3 - - name: Installing - run: | - sudo apt update - sudo apt install cppcheck - pip install cpplint - name: Cppcheck run: | cppcheck --language=c++ ./src/main.cpp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cdea2e8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:20.04 AS base + +ENV TZ=Europe/Moscow +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt update -y +RUN apt install -y gcc +RUN apt install -y libpqxx-dev +RUN apt install -y clang-tidy +RUN apt install -y python3-pip +RUN apt install -y cppcheck +RUN apt install -y cmake +RUN apt install -y libboost-all-dev +RUN apt install -y git +RUN apt-get update -y +RUN apt install -y xvfb +RUN pip install gcovr +RUN pip install cpplint + +RUN git clone https://github.com/google/googletest.git -b release-1.11.0 +WORKDIR googletest/build +RUN cmake .. -DBUILD_GMOCK=OFF +RUN make +RUN make install + +WORKDIR /project + +COPY . . \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index a222488..cbd2bd5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,8 @@ +#include #include #include #include -#include #include #include #include @@ -10,312 +10,255 @@ #include #include -namespace beast = boost::beast; // from -namespace http = beast::http; // from -namespace net = boost::asio; // from -using tcp = boost::asio::ip::tcp; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Return a reasonable mime type based on the extension of a file. -beast::string_view -mime_type(beast::string_view path) -{ - using beast::iequals; - auto const ext = [&path] - { - auto const pos = path.rfind("."); - if(pos == beast::string_view::npos) - return beast::string_view{}; - return path.substr(pos); - }(); - if(iequals(ext, ".htm")) return "text/html"; - if(iequals(ext, ".html")) return "text/html"; - if(iequals(ext, ".php")) return "text/html"; - if(iequals(ext, ".css")) return "text/css"; - if(iequals(ext, ".txt")) return "text/plain"; - if(iequals(ext, ".js")) return "application/javascript"; - if(iequals(ext, ".json")) return "application/json"; - if(iequals(ext, ".xml")) return "application/xml"; - if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; - if(iequals(ext, ".flv")) return "video/x-flv"; - if(iequals(ext, ".png")) return "image/png"; - if(iequals(ext, ".jpe")) return "image/jpeg"; - if(iequals(ext, ".jpeg")) return "image/jpeg"; - if(iequals(ext, ".jpg")) return "image/jpeg"; - if(iequals(ext, ".gif")) return "image/gif"; - if(iequals(ext, ".bmp")) return "image/bmp"; - if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; - if(iequals(ext, ".tiff")) return "image/tiff"; - if(iequals(ext, ".tif")) return "image/tiff"; - if(iequals(ext, ".svg")) return "image/svg+xml"; - if(iequals(ext, ".svgz")) return "image/svg+xml"; - return "application/text"; +beast::string_view mime_type(beast::string_view path) { + using beast::iequals; + auto const ext = [&path] { + auto const pos = path.rfind("."); + if (pos == beast::string_view::npos) return beast::string_view{}; + return path.substr(pos); + }(); + if (iequals(ext, ".htm")) return "text/html"; + if (iequals(ext, ".html")) return "text/html"; + if (iequals(ext, ".php")) return "text/html"; + if (iequals(ext, ".css")) return "text/css"; + if (iequals(ext, ".txt")) return "text/plain"; + if (iequals(ext, ".js")) return "application/javascript"; + if (iequals(ext, ".json")) return "application/json"; + if (iequals(ext, ".xml")) return "application/xml"; + if (iequals(ext, ".swf")) return "application/x-shockwave-flash"; + if (iequals(ext, ".flv")) return "video/x-flv"; + if (iequals(ext, ".png")) return "image/png"; + if (iequals(ext, ".jpe")) return "image/jpeg"; + if (iequals(ext, ".jpeg")) return "image/jpeg"; + if (iequals(ext, ".jpg")) return "image/jpeg"; + if (iequals(ext, ".gif")) return "image/gif"; + if (iequals(ext, ".bmp")) return "image/bmp"; + if (iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; + if (iequals(ext, ".tiff")) return "image/tiff"; + if (iequals(ext, ".tif")) return "image/tiff"; + if (iequals(ext, ".svg")) return "image/svg+xml"; + if (iequals(ext, ".svgz")) return "image/svg+xml"; + return "application/text"; } // Append an HTTP rel-path to a local filesystem path. // The returned path is normalized for the platform. -std::string -path_cat( - beast::string_view base, - beast::string_view path) -{ - if (base.empty()) - return std::string(path); - std::string result(base); +std::string path_cat(beast::string_view base, beast::string_view path) { + if (base.empty()) return std::string(path); + std::string result(base); #ifdef BOOST_MSVC - char constexpr path_separator = '\\'; - if(result.back() == path_separator) - result.resize(result.size() - 1); - result.append(path.data(), path.size()); - for(auto& c : result) - if(c == '/') - c = path_separator; + char constexpr path_separator = '\\'; + if (result.back() == path_separator) result.resize(result.size() - 1); + result.append(path.data(), path.size()); + for (auto& c : result) + if (c == '/') c = path_separator; #else - char constexpr path_separator = '/'; - if(result.back() == path_separator) - result.resize(result.size() - 1); - result.append(path.data(), path.size()); + char constexpr path_separator = '/'; + if (result.back() == path_separator) result.resize(result.size() - 1); + result.append(path.data(), path.size()); #endif - return result; + return result; } // This function produces an HTTP response for the given // request. The type of the response object depends on the // contents of the request, so the interface requires the // caller to pass a generic lambda for receiving the response. -template< - class Body, class Allocator, - class Send> -void -handle_request( - beast::string_view doc_root, - http::request>&& req, - Send&& send) -{ - // Returns a bad request response - auto const bad_request = - [&req](beast::string_view why) - { - http::response res{http::status::bad_request, req.version()}; - res.set(http::field::server, BOOST_BEAST_VERSION_STRING); - res.set(http::field::content_type, "text/html"); - res.keep_alive(req.keep_alive()); - res.body() = std::string(why); - res.prepare_payload(); - return res; - }; - - // Returns a not found response - auto const not_found = - [&req](beast::string_view target) - { - http::response res{http::status::not_found, req.version()}; - res.set(http::field::server, BOOST_BEAST_VERSION_STRING); - res.set(http::field::content_type, "text/html"); - res.keep_alive(req.keep_alive()); - res.body() = "The resource '" + std::string(target) + "' was not found."; - res.prepare_payload(); - return res; - }; - - // Returns a server error response - auto const server_error = - [&req](beast::string_view what) - { - http::response res{http::status::internal_server_error, req.version()}; - res.set(http::field::server, BOOST_BEAST_VERSION_STRING); - res.set(http::field::content_type, "text/html"); - res.keep_alive(req.keep_alive()); - res.body() = "An error occurred: '" + std::string(what) + "'"; - res.prepare_payload(); - return res; - }; - - // Make sure we can handle the method - if( req.method() != http::verb::get && - req.method() != http::verb::head) - return send(bad_request("Unknown HTTP-method")); - - // Request path must be absolute and not contain "..". - if( req.target().empty() || - req.target()[0] != '/' || - req.target().find("..") != beast::string_view::npos) - return send(bad_request("Illegal request-target")); - - // Build the path to the requested file - std::string path = path_cat(doc_root, req.target()); - if(req.target().back() == '/') - path.append("index.html"); - - // Attempt to open the file - beast::error_code ec; - http::file_body::value_type body; - body.open(path.c_str(), beast::file_mode::scan, ec); - - // Handle the case where the file doesn't exist - if(ec == beast::errc::no_such_file_or_directory) - return send(not_found(req.target())); - - // Handle an unknown error - if(ec) - return send(server_error(ec.message())); - - // Cache the size since we need it after the move - auto const size = body.size(); - - // Respond to HEAD request - if(req.method() == http::verb::head) - { - http::response res{http::status::ok, req.version()}; - res.set(http::field::server, BOOST_BEAST_VERSION_STRING); - res.set(http::field::content_type, mime_type(path)); - res.content_length(size); - res.keep_alive(req.keep_alive()); - return send(std::move(res)); - } - - // Respond to GET request - http::response res{ - std::piecewise_construct, - std::make_tuple(std::move(body)), - std::make_tuple(http::status::ok, req.version())}; +template +void handle_request(beast::string_view doc_root, + http::request>&& req, + Send&& send) { + // Returns a bad request response + auto const bad_request = [&req](beast::string_view why) { + http::response res{http::status::bad_request, + req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = std::string(why); + res.prepare_payload(); + return res; + }; + + // Returns a not found response + auto const not_found = [&req](beast::string_view target) { + http::response res{http::status::not_found, + req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "The resource '" + std::string(target) + "' was not found."; + res.prepare_payload(); + return res; + }; + + // Returns a server error response + auto const server_error = [&req](beast::string_view what) { + http::response res{http::status::internal_server_error, + req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/html"); + res.keep_alive(req.keep_alive()); + res.body() = "An error occurred: '" + std::string(what) + "'"; + res.prepare_payload(); + return res; + }; + + // Make sure we can handle the method + if (req.method() != http::verb::get && req.method() != http::verb::head) + return send(bad_request("Unknown HTTP-method")); + + // Request path must be absolute and not contain "..". + if (req.target().empty() || req.target()[0] != '/' || + req.target().find("..") != beast::string_view::npos) + return send(bad_request("Illegal request-target")); + + // Build the path to the requested file + std::string path = path_cat(doc_root, req.target()); + if (req.target().back() == '/') path.append("index.html"); + + // Attempt to open the file + beast::error_code ec; + http::file_body::value_type body; + body.open(path.c_str(), beast::file_mode::scan, ec); + + // Handle the case where the file doesn't exist + if (ec == beast::errc::no_such_file_or_directory) + return send(not_found(req.target())); + + // Handle an unknown error + if (ec) return send(server_error(ec.message())); + + // Cache the size since we need it after the move + auto const size = body.size(); + + // Respond to HEAD request + if (req.method() == http::verb::head) { + http::response res{http::status::ok, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); res.set(http::field::content_type, mime_type(path)); res.content_length(size); res.keep_alive(req.keep_alive()); return send(std::move(res)); + } + + // Respond to GET request + http::response res{ + std::piecewise_construct, std::make_tuple(std::move(body)), + std::make_tuple(http::status::ok, req.version())}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, mime_type(path)); + res.content_length(size); + res.keep_alive(req.keep_alive()); + return send(std::move(res)); } //------------------------------------------------------------------------------ // Report a failure -void -fail(beast::error_code ec, char const* what) -{ - std::cerr << what << ": " << ec.message() << "\n"; +void fail(beast::error_code ec, char const* what) { + std::cerr << what << ": " << ec.message() << "\n"; } // This is the C++11 equivalent of a generic lambda. // The function object is used to send an HTTP message. -template -struct send_lambda -{ - Stream& stream_; - bool& close_; - beast::error_code& ec_; - - explicit - send_lambda( - Stream& stream, - bool& close, - beast::error_code& ec) - : stream_(stream) - , close_(close) - , ec_(ec) - { - } - - template - void - operator()(http::message&& msg) const - { - // Determine if we should close the connection after - close_ = msg.need_eof(); - - // We need the serializer here because the serializer requires - // a non-const file_body, and the message oriented version of - // http::write only works with const messages. - http::serializer sr{msg}; - http::write(stream_, sr, ec_); - } +template +struct send_lambda { + Stream& stream_; + bool& close_; + beast::error_code& ec_; + + explicit send_lambda(Stream& stream, bool& close, beast::error_code& ec) + : stream_(stream), close_(close), ec_(ec) {} + + template + void operator()(http::message&& msg) const { + // Determine if we should close the connection after + close_ = msg.need_eof(); + + // We need the serializer here because the serializer requires + // a non-const file_body, and the message oriented version of + // http::write only works with const messages. + http::serializer sr{msg}; + http::write(stream_, sr, ec_); + } }; // Handles an HTTP server connection -void -do_session( - tcp::socket& socket, - std::shared_ptr const& doc_root) -{ - bool close = false; - beast::error_code ec; - - // This buffer is required to persist across reads - beast::flat_buffer buffer; - - // This lambda is used to send messages - send_lambda lambda{socket, close, ec}; - - for(;;) - { - // Read a request - http::request req; - http::read(socket, buffer, req, ec); - if(ec == http::error::end_of_stream) - break; - if(ec) - return fail(ec, "read"); - - // Send the response - handle_request(*doc_root, std::move(req), lambda); - if(ec) - return fail(ec, "write"); - if(close) - { - // This means we should close the connection, usually because - // the response indicated the "Connection: close" semantic. - break; - } +void do_session(tcp::socket& socket, + std::shared_ptr const& doc_root) { + bool close = false; + beast::error_code ec; + + // This buffer is required to persist across reads + beast::flat_buffer buffer; + + // This lambda is used to send messages + send_lambda lambda{socket, close, ec}; + + for (;;) { + // Read a request + http::request req; + http::read(socket, buffer, req, ec); + if (ec == http::error::end_of_stream) break; + if (ec) return fail(ec, "read"); + + // Send the response + handle_request(*doc_root, std::move(req), lambda); + if (ec) return fail(ec, "write"); + if (close) { + // This means we should close the connection, usually because + // the response indicated the "Connection: close" semantic. + break; } + } - // Send a TCP shutdown - socket.shutdown(tcp::socket::shutdown_send, ec); + // Send a TCP shutdown + socket.shutdown(tcp::socket::shutdown_send, ec); - // At this point the connection is closed gracefully + // At this point the connection is closed gracefully } //------------------------------------------------------------------------------ -int main(int argc, char* argv[]) -{ - try - { - // Check command line arguments. - if (argc != 4) - { - std::cerr << - "Usage: http-server-sync
\n" << - "Example:\n" << - " http-server-sync 0.0.0.0 8080 .\n"; - return EXIT_FAILURE; - } - auto const address = net::ip::make_address(argv[1]); - auto const port = static_cast(std::atoi(argv[2])); - auto const doc_root = std::make_shared(argv[3]); - - // The io_context is required for all I/O - net::io_context ioc{1}; - - // The acceptor receives incoming connections - tcp::acceptor acceptor{ioc, {address, port}}; - for(;;) - { - // This will receive the new connection - tcp::socket socket{ioc}; - - // Block until we get a connection - acceptor.accept(socket); - - // Launch the session, transferring ownership of the socket - std::thread{std::bind( - &do_session, - std::move(socket), - doc_root)}.detach(); - } +int main(int argc, char* argv[]) { + try { + // Check command line arguments. + if (argc != 4) { + std::cerr << "Usage: http-server-sync
\n" + << "Example:\n" + << " http-server-sync 0.0.0.0 8080 .\n"; + return EXIT_FAILURE; } - catch (const std::exception& e) - { - std::cerr << "Error: " << e.what() << std::endl; - return EXIT_FAILURE; + auto const address = net::ip::make_address(argv[1]); + auto const port = static_cast(std::atoi(argv[2])); + auto const doc_root = std::make_shared(argv[3]); + + // The io_context is required for all I/O + net::io_context ioc{1}; + + // The acceptor receives incoming connections + tcp::acceptor acceptor{ioc, {address, port}}; + for (;;) { + // This will receive the new connection + tcp::socket socket{ioc}; + + // Block until we get a connection + acceptor.accept(socket); + + // Launch the session, transferring ownership of the socket + std::thread{std::bind(&do_session, std::move(socket), doc_root)}.detach(); } -} \ No newline at end of file + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return EXIT_FAILURE; + } +} -- GitLab From d727decc36204efc32051962c05927944d7f94ee Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 1 May 2023 19:23:06 +0300 Subject: [PATCH 4/7] fix boost --- Dockerfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cdea2e8..16fed7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,13 +10,19 @@ RUN apt install -y clang-tidy RUN apt install -y python3-pip RUN apt install -y cppcheck RUN apt install -y cmake -RUN apt install -y libboost-all-dev RUN apt install -y git RUN apt-get update -y RUN apt install -y xvfb RUN pip install gcovr RUN pip install cpplint +RUN apt-get install wget +RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.tar.gz +RUN tar xvf boost_1_82_0.tar.gz +WORKDIR boost_1_82_0 +RUN ./bootstrap.sh --prefix=/usr/ +RUN ./b2 install + RUN git clone https://github.com/google/googletest.git -b release-1.11.0 WORKDIR googletest/build RUN cmake .. -DBUILD_GMOCK=OFF -- GitLab From e5daf13f5a155c26baf722cea52e5db48a365c02 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 1 May 2023 19:40:35 +0300 Subject: [PATCH 5/7] add compile flags --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41ba7c6..7efaa4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ set(CMAKE_CXX_STANDARD 17) -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.19) set(CMAKE_PREFIX_PATH build) project(SourcedOut CXX) # find_package(antlr4-runtime REQUIRED) @@ -7,6 +7,7 @@ find_package(Boost 1.8.1 REQUIRED) # find_package(libpqxx REQUIRED) find_package(GTest REQUIRED) message(STATUS ${Boost_LIBRARIES}) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lboost_system -lboost_thread -lpthread") add_executable(${PROJECT_NAME} src/main.cpp) #add_executable(${PROJECT_NAME} text-basic-metrics/tbm_main.cpp text-basic-metrics/tbm_main.cpp) строка для запуска моей части в text-basic-metrics target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} ${antlr4-runtime_LIBRARIES} ${libpqxx_LIBRARIES} ${GTest_LIBRARIES}) \ No newline at end of file -- GitLab From bc349bb2464f2fdd0db299ec923b161b30381400 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 1 May 2023 20:12:42 +0300 Subject: [PATCH 6/7] change cmakelists --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7efaa4a..5054100 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,15 @@ set(CMAKE_CXX_STANDARD 17) -cmake_minimum_required(VERSION 3.19) +cmake_minimum_required(VERSION 3.16) set(CMAKE_PREFIX_PATH build) project(SourcedOut CXX) # find_package(antlr4-runtime REQUIRED) find_package(Boost 1.8.1 REQUIRED) # find_package(libpqxx REQUIRED) find_package(GTest REQUIRED) +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) message(STATUS ${Boost_LIBRARIES}) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lboost_system -lboost_thread -lpthread") +set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-lpthread -pthread") add_executable(${PROJECT_NAME} src/main.cpp) #add_executable(${PROJECT_NAME} text-basic-metrics/tbm_main.cpp text-basic-metrics/tbm_main.cpp) строка для запуска моей части в text-basic-metrics target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} ${antlr4-runtime_LIBRARIES} ${libpqxx_LIBRARIES} ${GTest_LIBRARIES}) \ No newline at end of file -- GitLab From 7409880f0e1a665867c9f71efba9e982d7e698d5 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 1 May 2023 21:56:03 +0300 Subject: [PATCH 7/7] fix ci --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3859e29..debe623 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,11 +28,11 @@ jobs: linters: runs-on: ubuntu-latest container: raiden454/sourced-out - needs: [build] steps: + - uses: actions/checkout@v3 - name: Cppcheck run: | - cppcheck --language=c++ ./src/main.cpp + cppcheck src --std=c++17 --enable=all - name: Cpplint run: | - cpplint --filter=-legal/copyright,-readability/casting,-whitespace/tab,-build/include_subdir --linelength=110 ./src/main.cpp \ No newline at end of file + cpplint --extensions=cpp,hpp --recursive ./src/* \ No newline at end of file -- GitLab