diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c95d045e..49aad137 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -21,8 +21,8 @@ jobs: arch: x64 apt: libcurl4-openssl-dev - os: ubuntu-latest - compiler: clang-12 - cxx_compiler: clang++-12 + compiler: clang-13 + cxx_compiler: clang++-13 arch: x64 apt: libcurl4-openssl-dev - os: ubuntu-latest @@ -30,14 +30,14 @@ jobs: cxx_compiler: g++-9 arch: i386 cflags: -m32 - apt: gcc-9-multilib g++-9-multilib libcurl4-openssl-dev:i386 linux-libc-dev:i386 + apt: gcc-9-multilib g++-9-multilib libcurl4-openssl-dev:i386 linux-libc-dev:i386 libssl-dev:i386 - os: ubuntu-latest compiler: gcc-9 cxx_compiler: g++-9 arch: i386 cflags: -m32 configure_args: -DMSYNC_USER_CONFIG=ON -DMSYNC_FILE_LOG=OFF - apt: gcc-9-multilib g++-9-multilib libcurl4-openssl-dev:i386 linux-libc-dev:i386 + apt: gcc-9-multilib g++-9-multilib libcurl4-openssl-dev:i386 linux-libc-dev:i386 libssl-dev:i386 - os: ubuntu-latest compiler: gcc-9 cxx_compiler: g++-9 @@ -102,7 +102,7 @@ jobs: - name: Enable Cross-Compilation If Needed if: matrix.os == 'ubuntu-latest' && matrix.arch == 'i386' - run: sudo dpkg --add-architecture i386 && sudo apt update + run: sudo dpkg --add-architecture i386 && sudo apt update && sudo apt purge --autoremove libssl-dev libcurl4-openssl-dev linux-libc-dev - name: Install Boost For Earlier OSX Versions if: matrix.os == 'macos-10.15' && matrix.deployment_target < 10.15 @@ -205,7 +205,7 @@ jobs: if-no-files-found: error - name: Upload Man Page - uses: actions/upload-artifact@v2.2.2 + uses: actions/upload-artifact@v3 if: matrix.make_deb with: # Artifact name diff --git a/CMakeLists.txt b/CMakeLists.txt index 21c72dc4..7dd5b0ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12..3.15) +cmake_minimum_required(VERSION 3.15) project (msync VERSION 0.9.9.8 DESCRIPTION "Store and forward messages with a Mastodon API-compatible server." @@ -11,6 +11,7 @@ option(MSYNC_FILE_LOG "Log debug messages to msync.log" ON) option(MSYNC_USER_CONFIG "Store configuration in the OS user configuration folder. Otherwise, store configuration in msync_accounts in the executable's directory." OFF) set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) #enable interprocedural optimization for all projects +cmake_policy(SET CMP0069 NEW) #enable interprocedural optimization for all projects include(cmake/linktimeoptimization.cmake) diff --git a/README.md b/README.md index d41e955c..7e3d7803 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,15 @@ I recommend downloading the `.deb` file if you're on a x64 Debian-like system th If you're on OSX, the builds for 10.15 use std::filesystem APIs that are only available on OSX 10.15. Not that you can download these any more- GitHub Actions removed support for pre-11 versions of macOS, so you'll have to build yourself if you're on an older macOS. -If you would like to build `msync` yourself, read on. If you have a fairly recent version of CMake (3.12 or later), you can simply clone the repo, make a `build` directory, run CMake inside, and CMake will download and build `msync` and its dependencies automatically. +If you would like to build `msync` yourself, read on. If you have a fairly recent version of CMake (3.15 or later), you can simply clone the repo, make a `build` directory, run CMake inside, and CMake will download and build `msync` and its dependencies automatically. + +If you're on a version of CMake before 3.15, you may have to use [my old, unsupported branch of CPR](https://github.com/Kansattica/cpr) because pre-3.15 CMake versions don't support its newer FetchContent calls. Arch Linux users can use the AUR packages [msync](https://aur.archlinux.org/packages/msync/) and [msync-git](https://aur.archlinux.org/packages/msync-git/). These are maintained by someone else and I cannot test them, but I have no reason to believe they won't work. ##### Notes on libcurl -- If you're compiling `msync` from source, you'll need something like `libcurl4-gnutls-dev` or `libcurl4-openssl-dev` installed. +- If you're compiling `msync` from source, you'll need something like `libcurl4-gnutls-dev` or `libcurl4-openssl-dev` and `libssl-dev` (new CPR likes to see the SSL library headers) installed. - If you'd rather have msync compile curl into itself, add `-DUSE_SYSTEM_CURL=OFF` after `-DCMAKE_BUILD_TYPE=Release`. This will automatically download and configure curl as part of the build process. If you go this route, I suggest having zlib (e.g. `zlib1g-dev`, optional but highly recommended) and an ssl library (e.g. `libssl-dev`, required) installed where curl can find them. #### Building on Linux diff --git a/cmake/packages.cmake b/cmake/packages.cmake index de82367e..9b21f7aa 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -1,10 +1,14 @@ +if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) #fix warning about zip file timestamps +endif() + include(FetchContent) message(STATUS "Downloading nlohmann json...") FetchContent_Declare( njson - URL https://github.com/nlohmann/json/releases/download/v3.10.5/include.zip - URL_HASH SHA256=b94997df68856753b72f0d7a3703b7d484d4745c567f3584ef97c96c25a5798e + URL https://github.com/nlohmann/json/releases/download/v3.11.2/include.zip + URL_HASH SHA256=e5c7a9f49a16814be27e4ed0ee900ecd0092bfb7dbfca65b5a421b774dccaaed ) #FetchContent_MakeAvailable(json) Not available in cmake 13 @@ -42,7 +46,7 @@ if (NOT MSYNC_USER_CONFIG) FetchContent_Declare( whereamilib GIT_REPOSITORY https://github.com/gpakosz/whereami.git - GIT_TAG 6a8536a8b2d8c1903f22333c1a130a142f6d31de + GIT_TAG ba364cd54fd431c76c045393b6522b4bff547f50 ) FetchContent_GetProperties(whereamilib) @@ -56,11 +60,13 @@ else() endif() message(STATUS "Downloading CPR...") +include(FetchContent) FetchContent_Declare( - libcpr - GIT_REPOSITORY https://github.com/kansattica/cpr.git - GIT_TAG 20d438db91d5be7acb3c2ba0b3183f8872287b58 + libcpr + GIT_REPOSITORY https://github.com/libcpr/cpr.git + GIT_TAG 2553fc41450301cd09a9271c8d2c3e0cf3546b73 ) + option(USE_SYSTEM_CURL "Try to use the system's libcurl instead of downloading and statically linking." ON) option(MSYNC_DOWNLOAD_ZLIB "If downloading and building curl on Windows, try to download zlib as well." ON) option(BUILD_CPR_TESTS "" OFF) @@ -140,6 +146,7 @@ if (MSVC) set (CMAKE_USE_OPENSSL OFF CACHE BOOL "Don't use openssl" FORCE) endif() +set(CPR_USE_SYSTEM_CURL "${USE_SYSTEM_CURL}" CACHE STRING "Ensure CPR's use system curl setting matches ours.") FetchContent_GetProperties(libcpr) if(NOT libcpr_POPULATED) message(STATUS "Configuring CPR...") @@ -157,7 +164,7 @@ if (MSYNC_BUILD_TESTS) FetchContent_Declare( catch2lib GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v2.13.8 + GIT_TAG v2.13.10 GIT_SHALLOW TRUE ) diff --git a/lib/net/net.cpp b/lib/net/net.cpp index 08d920c7..729ca0eb 100644 --- a/lib/net/net.cpp +++ b/lib/net/net.cpp @@ -6,6 +6,8 @@ #include +using namespace std::string_view_literals; + std::string_view ensure_small_string(const std::string_view sv) { // I want to ensure that, when a string is constructed from this, it's cheap to make @@ -96,32 +98,32 @@ net_response upload_media(std::string_view url, std::string_view access_token, c )); } -void add_if_value(cpr::Payload& params, const char* key, const std::string& value) +void add_if_value(cpr::Payload& params, const std::string_view key, const std::string& value) { if (!value.empty()) - params.AddPair(cpr::Pair(key, value)); + params.Add(cpr::Pair(std::string(key), value)); } -void add_array(cpr::Payload& params, const char* key, const std::vector& values) +void add_array(cpr::Payload& params, const std::string_view key, const std::vector& values) { for (const auto& value : values) { - params.AddPair(cpr::Pair(key, value)); + params.Add(cpr::Pair(std::string(key), value)); } } net_response new_status(std::string_view url, std::string_view access_token, const status_params& params) { cpr::Payload post_params{}; - add_if_value(post_params, "status", params.body); - add_if_value(post_params, "spoiler_text", params.content_warning); - add_if_value(post_params, "visibility", params.visibility); - add_if_value(post_params, "in_reply_to_id", params.reply_to); + add_if_value(post_params, "status"sv, params.body); + add_if_value(post_params, "spoiler_text"sv, params.content_warning); + add_if_value(post_params, "visibility"sv, params.visibility); + add_if_value(post_params, "in_reply_to_id"sv, params.reply_to); // the mastodon api page doesn't mention this, but apparently this is a feature of rails // (that the other mastodon api libs use) // that lets you specify arrays with empty brackets like this - add_array(post_params, "media_ids[]", params.attachment_ids); + add_array(post_params, "media_ids[]"sv, params.attachment_ids); return handle_response( @@ -131,17 +133,17 @@ net_response new_status(std::string_view url, std::string_view access_token, con std::move(post_params))); } -void add_if_value(cpr::Parameters& params, const char* key, const std::string_view value) +void add_if_value(cpr::Parameters& params, const std::string_view key, const std::string_view value) { if (!value.empty()) - params.AddParameter(cpr::Parameter{ key, value }); + params.Add(cpr::Parameter{ std::string(key), std::string(value) }); } -void add_array(cpr::Parameters& params, const char* key, const std::vector& values) +void add_array(cpr::Parameters& params, const std::string_view key, const std::vector& values) { for (const auto& value : values) { - params.AddParameter(cpr::Parameter{ key, value }); + params.Add(cpr::Parameter{ std::string(key), std::string(value) }); } } @@ -149,11 +151,11 @@ net_response get_timeline_and_notifs(std::string_view url, std::string_view acce { cpr::Parameters query_params{ { "limit", std::to_string(limit) } }; - add_if_value(query_params, "min_id", params.min_id); - add_if_value(query_params, "max_id", params.max_id); - add_if_value(query_params, "since_id", params.since_id); + add_if_value(query_params, "min_id"sv, params.min_id); + add_if_value(query_params, "max_id"sv, params.max_id); + add_if_value(query_params, "since_id"sv, params.since_id); - if (params.exclude_notifs != nullptr) { add_array(query_params, "exclude_types[]", *params.exclude_notifs); } + if (params.exclude_notifs != nullptr) { add_array(query_params, "exclude_types[]"sv, *params.exclude_notifs); } return handle_response( cpr::Get(cpr::Url{ url }, diff --git a/lib/options/user_options.cpp b/lib/options/user_options.cpp index 20bf0fc3..4752c179 100644 --- a/lib/options/user_options.cpp +++ b/lib/options/user_options.cpp @@ -46,7 +46,7 @@ std::array sync_setting_defaults = { sync_settings user_options::get_sync_option(user_option toget) const { //only these guys have sync options - assert(toget == user_option::pull_home || toget == user_option::pull_dms || toget == user_option::pull_notifications); + assert(toget == user_option::pull_home || toget == user_option::pull_dms || toget == user_option::pull_notifications || toget == user_option::pull_bookmarks); const auto option = static_cast(toget); const auto val = backing.parsed.find(USER_OPTION_NAMES[option]); if (val == backing.parsed.end())