From e75dc0fedc638dcec31bdf094cc9e6edec5e76a9 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 21:17:30 -0700 Subject: [PATCH 01/13] Try using the maintained version of CPR. --- CMakeLists.txt | 2 +- README.md | 4 +++- cmake/packages.cmake | 8 +++++--- lib/net/net.cpp | 36 +++++++++++++++++++----------------- lib/options/user_options.cpp | 2 +- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21c72dc4..24bac198 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." diff --git a/README.md b/README.md index d41e955c..dee77ae5 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ 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. diff --git a/cmake/packages.cmake b/cmake/packages.cmake index de82367e..b2753be8 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -56,11 +56,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) 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()) From 082efc2cec3b8d9d6bfae431fe9c8a45766b77a8 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 21:19:10 -0700 Subject: [PATCH 02/13] Bump up clang version. --- .github/workflows/build-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c95d045e..467eabc3 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 From 908852520a3085bf477c196289b1df058c3d1eb1 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 21:28:32 -0700 Subject: [PATCH 03/13] Does this help things build in source control? --- cmake/packages.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/packages.cmake b/cmake/packages.cmake index b2753be8..59a8f695 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -5,6 +5,7 @@ FetchContent_Declare( njson URL https://github.com/nlohmann/json/releases/download/v3.10.5/include.zip URL_HASH SHA256=b94997df68856753b72f0d7a3703b7d484d4745c567f3584ef97c96c25a5798e + DOWNLOAD_EXTRACT_TIMESTAMP true ) #FetchContent_MakeAvailable(json) Not available in cmake 13 @@ -142,6 +143,7 @@ if (MSVC) set (CMAKE_USE_OPENSSL OFF CACHE BOOL "Don't use openssl" FORCE) endif() +set(CPR_USE_SYSTEM_CURL "${USE_SYSTEM_CURL}" ON CACHE STRING "Ensure CPR's use system curl setting matches ours.") FetchContent_GetProperties(libcpr) if(NOT libcpr_POPULATED) message(STATUS "Configuring CPR...") From e2aa5614edc8122addc0ec471182a946a29d738a Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 21:30:40 -0700 Subject: [PATCH 04/13] One too many ONs. --- cmake/packages.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/packages.cmake b/cmake/packages.cmake index 59a8f695..6f4105f4 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -143,7 +143,7 @@ if (MSVC) set (CMAKE_USE_OPENSSL OFF CACHE BOOL "Don't use openssl" FORCE) endif() -set(CPR_USE_SYSTEM_CURL "${USE_SYSTEM_CURL}" ON CACHE STRING "Ensure CPR's use system curl setting matches ours.") +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...") From 305807729a170d1e7c641340e8c6ba7780f0cf03 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 21:35:06 -0700 Subject: [PATCH 05/13] Does the i386 guy need another library? --- .github/workflows/build-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 467eabc3..9978d27a 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -37,7 +37,7 @@ jobs: 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 From d6c5713361fe45472dffba322259e64dbc781ee1 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 21:37:10 -0700 Subject: [PATCH 06/13] They both need it, I imagine. --- .github/workflows/build-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 9978d27a..908bc791 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -30,7 +30,7 @@ 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 From afa02f741485b549e2eabc7e8af3b99225df9ae8 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 21:42:03 -0700 Subject: [PATCH 07/13] Does removing the 64-bit versions of these help? --- .github/workflows/build-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 908bc791..3725d104 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -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 From 5ab894c39a8870568b43cd2b5a28fe7157ca3cd6 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 21:55:35 -0700 Subject: [PATCH 08/13] Quiet warning about zip file timestamps. --- CMakeLists.txt | 1 + cmake/packages.cmake | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24bac198..7dd5b0ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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/cmake/packages.cmake b/cmake/packages.cmake index 6f4105f4..c1cb1155 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -1,3 +1,5 @@ +cmake_policy(SET CMP0135 NEW) #fix warning about zip file timestamps + include(FetchContent) message(STATUS "Downloading nlohmann json...") @@ -5,7 +7,6 @@ FetchContent_Declare( njson URL https://github.com/nlohmann/json/releases/download/v3.10.5/include.zip URL_HASH SHA256=b94997df68856753b72f0d7a3703b7d484d4745c567f3584ef97c96c25a5798e - DOWNLOAD_EXTRACT_TIMESTAMP true ) #FetchContent_MakeAvailable(json) Not available in cmake 13 From dcfbee7cc2ba09ad0eb168cb023502e31bc2fc41 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 21:57:49 -0700 Subject: [PATCH 09/13] Do older versions like this? --- cmake/packages.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/packages.cmake b/cmake/packages.cmake index c1cb1155..1ea47243 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -1,4 +1,6 @@ -cmake_policy(SET CMP0135 NEW) #fix warning about zip file timestamps +if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) #fix warning about zip file timestamps +endif() include(FetchContent) From edeef81e27ca773cbd4c61a3d4246faa0b50ae55 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 22:02:29 -0700 Subject: [PATCH 10/13] Add a note about libssl. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dee77ae5..7e3d7803 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Arch Linux users can use the AUR packages [msync](https://aur.archlinux.org/pack ##### 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 From ced240f7929fab647436afc025e2fcaf77dfa630 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 22:04:44 -0700 Subject: [PATCH 11/13] Forgot to update this. --- .github/workflows/build-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 3725d104..49aad137 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -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 From f0240176a545d568af0a54301609748a9cef0b0c Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 22:07:46 -0700 Subject: [PATCH 12/13] Update nlohmann json while I'm at it. --- cmake/packages.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/packages.cmake b/cmake/packages.cmake index 1ea47243..c031e017 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -7,8 +7,8 @@ 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 From 5c7313d4cd9bf26bdb88d59b2657e9fff5896866 Mon Sep 17 00:00:00 2001 From: Grace L Date: Thu, 12 Oct 2023 22:10:02 -0700 Subject: [PATCH 13/13] In fact, bump all dependencies. --- cmake/packages.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/packages.cmake b/cmake/packages.cmake index c031e017..9b21f7aa 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -46,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) @@ -164,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 )