diff --git a/.github/workflows/build-test-all.yml b/.github/workflows/build-test-all.yml new file mode 100644 index 0000000000..1e7b2f6cd7 --- /dev/null +++ b/.github/workflows/build-test-all.yml @@ -0,0 +1,106 @@ +# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. +# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml +name: CMake on multiple platforms + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + # Set up a matrix to run the following 3 configurations: + # 1. + # 2. + # 3. + # + # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. + matrix: + #os: [ubuntu-latest, windows-latest, macos-latest] + os: [macos-latest] + build_type: [Debug] + #c_compiler: [gcc, clang, cl] + c_compiler: [clang] +# arch: [x64] + include: +# - os: windows-latest +# c_compiler: clang +# cpp_compiler: clang++ + # - os: ubuntu-latest + # c_compiler: gcc + # cpp_compiler: g++ + - os: macos-latest + c_compiler: clang + cpp_compiler: clang++ + # exclude: + # - os: windows-latest + # c_compiler: gcc + # - os: windows-latest + # c_compiler: clang + # - os: ubuntu-latest + # c_compiler: cl + # # excluded until building for multiple platforms + # - os: windows-latest + # c_compiler: cl + + steps: + - uses: actions/checkout@v4 + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + +# to use a specific version of cmake? +# - name: Setup cmake +# uses: jwlawson/actions-setup-cmake@v2 +# with: +# cmake-version: '3.16.x' + + - name: Use cmake + run: cmake --version + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -S ${{ github.workspace }}/superbuild + -G Ninja + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} +# -DCMAKE_SYSTEM_NAME=Linux +# -DCMAKE_SYSTEM_PROCESSOR=x86_64 +# -DARCHITECTURE=${{ matrix.arch }} + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + continue-on-error: true + + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + with: + name: extra-logs + path: | + ./**/*.log + retention-days: 1 + + #- name: Show log + # run: cat /home/runner/work/blackcat/blackcat/build/decimal_for_cpp-prefix/src/decimal_for_cpp-stamp/decimal_for_cpp-configure-Debug.log + + # - name: Test + # working-directory: ${{ steps.strings.outputs.build-output-dir }} + # # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + # # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + # run: ctest --build-config ${{ matrix.build_type }} diff --git a/.gitignore b/.gitignore index 3a3fea4411..c1c224e1e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,12 @@ +# CMake's installation directory +install/ +# CMake project files +cmake-build-debug/ +cmake-build-release/ +# CLion # +################# +/.idea/* +!/.idea/runConfigurations # Visual Studio files *.o *.d diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index 14e43cedcd..9b0426482f 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -22,12 +22,9 @@ set(CPPREST_EXCLUDE_BROTLI ON CACHE BOOL "Exclude Brotli compression functionali set(CPPREST_EXPORT_DIR cmake/cpprestsdk CACHE STRING "Directory to install CMake config files.") set(CPPREST_INSTALL_HEADERS ON CACHE BOOL "Install header files.") set(CPPREST_INSTALL ON CACHE BOOL "Add install commands.") +set(CPPREST_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries.") -if(IOS OR ANDROID) - set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries") -else() - set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries") -endif() +set(BUILD_SHARED_LIBS ${CPPREST_BUILD_SHARED_LIBS}) if(IOS OR ANDROID OR WINDOWS_STORE OR WINDOWS_PHONE) set(BUILD_TESTS OFF CACHE BOOL "Build tests.") diff --git a/Release/include/cpprest/char_traits.h b/Release/include/cpprest/char_traits.h new file mode 100644 index 0000000000..1e7d172bb0 --- /dev/null +++ b/Release/include/cpprest/char_traits.h @@ -0,0 +1,74 @@ +#include +#include +#include + +namespace std +{ +template<> +struct char_traits +{ + using char_type = uint8_t; + using int_type = unsigned int; + using off_type = std::streamoff; + using pos_type = std::streampos; + using state_type = std::mbstate_t; + + static void assign(char_type& c1, const char_type& c2) noexcept { c1 = c2; } + + static bool eq(char_type c1, char_type c2) noexcept { return c1 == c2; } + + static bool lt(char_type c1, char_type c2) noexcept { return c1 < c2; } + + static int compare(const char_type* s1, const char_type* s2, std::size_t n) noexcept + { + return std::memcmp(s1, s2, n); + } + + static std::size_t length(const char_type* s) noexcept + { + const char_type* p = s; + while (*p != 0) + ++p; + return p - s; + } + + static const char_type* find(const char_type* s, std::size_t n, const char_type& a) noexcept + { + for (std::size_t i = 0; i < n; ++i) + { + if (eq(s[i], a)) + { + return s + i; + } + } + + return nullptr; + } + + static char_type* move(char_type* s1, const char_type* s2, std::size_t n) noexcept + { + return static_cast(std::memmove(s1, s2, n)); + } + + static char_type* copy(char_type* s1, const char_type* s2, std::size_t n) noexcept + { + return static_cast(std::memcpy(s1, s2, n)); + } + + static char_type* assign(char_type* s, std::size_t n, char_type a) noexcept + { + std::fill_n(s, n, a); + return s; + } + + static int_type not_eof(int_type c) noexcept { return c == eof() ? ~eof() : c; } + + static char_type to_char_type(int_type c) noexcept { return static_cast(c); } + + static int_type to_int_type(char_type c) noexcept { return static_cast(c); } + + static bool eq_int_type(int_type c1, int_type c2) noexcept { return c1 == c2; } + + static int_type eof() noexcept { return static_cast(-1); } +}; +} // namespace std diff --git a/Release/include/cpprest/http_client.h b/Release/include/cpprest/http_client.h index fb7c6067ab..0dfa27cfc9 100644 --- a/Release/include/cpprest/http_client.h +++ b/Release/include/cpprest/http_client.h @@ -15,6 +15,19 @@ #ifndef CASA_HTTP_CLIENT_H #define CASA_HTTP_CLIENT_H +#if !defined(_WIN32) && !defined(__cplusplus_winrt) || defined(CPPREST_FORCE_HTTP_CLIENT_ASIO) +namespace boost +{ +namespace asio +{ +namespace ssl +{ +class context; +} +} +} +#endif + #if defined(__cplusplus_winrt) #if !defined(__WRL_NO_DEFAULT_LIB__) #define __WRL_NO_DEFAULT_LIB__ @@ -60,17 +73,6 @@ typedef void* native_handle; #include "cpprest/oauth2.h" -#if !defined(_WIN32) && !defined(__cplusplus_winrt) || defined(CPPREST_FORCE_HTTP_CLIENT_ASIO) -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconversion" -#endif -#include "boost/asio/ssl.hpp" -#if defined(__clang__) -#pragma clang diagnostic pop -#endif -#endif - /// The web namespace contains functionality common to multiple protocols like HTTP and WebSockets. namespace web { @@ -368,18 +370,12 @@ class http_client_config /// /// A user callback allowing for customization of the ssl context at construction /// time. - void set_ssl_context_callback(const std::function& callback) - { - m_ssl_context_callback = callback; - } + void set_ssl_context_callback(const std::function& callback); /// /// Gets the user's callback to allow for customization of the ssl context. /// - const std::function& get_ssl_context_callback() const - { - return m_ssl_context_callback; - } + const std::function& get_ssl_context_callback() const; /// /// Gets the TLS extension server name indication (SNI) status. diff --git a/Release/include/cpprest/streams.h b/Release/include/cpprest/streams.h index b6c3864028..e505c841ef 100644 --- a/Release/include/cpprest/streams.h +++ b/Release/include/cpprest/streams.h @@ -15,6 +15,7 @@ #ifndef CASA_STREAMS_H #define CASA_STREAMS_H +#include "char_traits.h" #include "cpprest/astreambuf.h" #include #include diff --git a/Release/src/http/client/http_client.cpp b/Release/src/http/client/http_client.cpp index 09e3eed15a..116e1e7d3c 100644 --- a/Release/src/http/client/http_client.cpp +++ b/Release/src/http/client/http_client.cpp @@ -17,12 +17,43 @@ #include "http_client_impl.h" +#if !defined(_WIN32) && !defined(__cplusplus_winrt) || defined(CPPREST_FORCE_HTTP_CLIENT_ASIO) +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" +#endif +#include "boost/asio/ssl.hpp" +#if defined(__clang__) +#pragma clang diagnostic pop +#endif +#endif + namespace web { namespace http { namespace client { +#if !defined(_WIN32) && !defined(__cplusplus_winrt) || defined(CPPREST_FORCE_HTTP_CLIENT_ASIO) +/// +/// Sets a callback to enable custom setting of the ssl context, at construction time. +/// +/// A user callback allowing for customization of the ssl context at construction +/// time. +void http_client_config::set_ssl_context_callback(const std::function& callback) +{ + m_ssl_context_callback = callback; +} + +/// +/// Gets the user's callback to allow for customization of the ssl context. +/// +const std::function& http_client_config::get_ssl_context_callback() const +{ + return m_ssl_context_callback; +} +#endif + // Helper function to check to make sure the uri is valid. static void verify_uri(const uri& uri) { diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt new file mode 100644 index 0000000000..21ed6292d2 --- /dev/null +++ b/superbuild/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 3.30.5) +project(cpprestsdk-root NONE) + +include(ExternalProject) + +ExternalProject_Add(openssl + GIT_REPOSITORY https://github.com/openssl/openssl.git + GIT_TAG openssl-3.5.0 + CMAKE_ARGS + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + LOG_INSTALL ON +) + +ExternalProject_Add(boost + GIT_REPOSITORY https://github.com/boostorg/boost.git + GIT_TAG boost-1.87.0 + CMAKE_ARGS + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + LOG_INSTALL ON +) + +ExternalProject_Add(cpprestsdk + GIT_REPOSITORY https://github.com/codeavour/cpprestsdk.git + GIT_TAG HEAD + DEPENDS openssl boost + CMAKE_ARGS + -DBUILD_TESTS=OFF # turned off as it generates build errors + -DWERROR=OFF # turned off as there are warnings +# -DCMAKE_CXX_STANDARD=11 + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install +# -DCMAKE_CXX_FLAGS=BOOST_ASIO_NO_DEPRECATED=0 + -DBoost_USE_STATIC_LIBS=ON +# -DBOOST_ASIO_NO_DEPRECATED=OFF # Linux version of cpprestsdk indirectly relies on boost's deprecated IO service + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + LOG_INSTALL ON +) \ No newline at end of file