From 73f6ce62ec98ebae1eb08df039886c041b780b85 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Fri, 6 Oct 2023 16:55:35 +0200 Subject: [PATCH 1/5] persistent-cache-cpp: init at 1.0.5 --- .../pe/persistent-cache-cpp/package.nix | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 pkgs/by-name/pe/persistent-cache-cpp/package.nix diff --git a/pkgs/by-name/pe/persistent-cache-cpp/package.nix b/pkgs/by-name/pe/persistent-cache-cpp/package.nix new file mode 100644 index 000000000000..7461ced7f913 --- /dev/null +++ b/pkgs/by-name/pe/persistent-cache-cpp/package.nix @@ -0,0 +1,103 @@ +{ stdenv +, lib +, fetchFromGitLab +, fetchpatch +, gitUpdater +, testers +, boost +, cmake +, doxygen +, gtest +, leveldb +, lomiri +, pkg-config +, python3 +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "persistent-cache-cpp"; + version = "1.0.5"; + + src = fetchFromGitLab { + owner = "ubports"; + repo = "development/core/lib-cpp/persistent-cache-cpp"; + rev = finalAttrs.version; + hash = "sha256-MOH8ardiTliTKrtRQ5eFRhbRtnC0Yq20WJYoo1tAn3E="; + }; + + patches = [ + # Fix build on GCC 12 + # Remove when version > 1.0.5 + (fetchpatch { + url = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/commit/3ed84ee1d32a27d183de2cb5f9feffc3f48fd9a1.patch"; + hash = "sha256-aNZ6KVHAsLVYlAcPNNkjUlOPRDZxzN5tzk4/1KuVaSY="; + }) + # Fix build on current Boost + # Remove when version > 1.0.5 + (fetchpatch { + url = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/commit/a590ffcccec252caa7b19a2922c678502069b057.patch"; + hash = "sha256-OhlsnUVhclt17brkncYkJ0+lXrJO671mtwopaAGPrtY="; + }) + ]; + + postPatch = '' + # Wrong concatenation + substituteInPlace data/libpersistent-cache-cpp.pc.in \ + --replace "\''${prefix}/@CMAKE_INSTALL_LIBDIR@" "\''${prefix}/lib" + + # Runs in parallel to other tests, limit to 1 thread + substituteInPlace tests/headers/compile_headers.py \ + --replace 'multiprocessing.cpu_count()' '1' + '' + (if finalAttrs.doCheck then '' + patchShebangs tests/{headers,whitespace}/*.py + '' else '' + sed -i -e '/add_subdirectory(tests)/d' CMakeLists.txt + ''); + + nativeBuildInputs = [ + cmake + doxygen + pkg-config + ]; + + buildInputs = [ + boost + lomiri.cmake-extras + leveldb + ]; + + nativeCheckInputs = [ + python3 + ]; + + checkInputs = [ + gtest + ]; + + cmakeFlags = [ + # error: 'old_version' may be used uninitialized + "-DWerror=OFF" + ]; + + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; + + passthru = { + tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + updateScript = gitUpdater { }; + }; + + meta = with lib; { + description = "Cache of key-value pairs with persistent storage for C++ 11"; + longDescription = '' + A persistent cache for arbitrary (possibly large amount of data, such as + image files) that is fast, scalable, and crash-proof. + ''; + homepage = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp"; + license = licenses.lgpl3Only; + maintainers = teams.lomiri.members; + platforms = platforms.unix; + pkgConfigModules = [ + "libpersistent-cache-cpp" + ]; + }; +}) From b89bf6f9f201868b405ef86ef22beed81b1a7bb0 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Fri, 6 Oct 2023 21:10:48 +0200 Subject: [PATCH 2/5] persistent-cache-cpp: Add patch to fix on Darwin --- ...-cpp-Lenient-exception-test-matching.patch | 41 +++++++++++++++++++ .../pe/persistent-cache-cpp/package.nix | 6 +++ 2 files changed, 47 insertions(+) create mode 100644 pkgs/by-name/pe/persistent-cache-cpp/0001-persistent-cache-cpp-Lenient-exception-test-matching.patch diff --git a/pkgs/by-name/pe/persistent-cache-cpp/0001-persistent-cache-cpp-Lenient-exception-test-matching.patch b/pkgs/by-name/pe/persistent-cache-cpp/0001-persistent-cache-cpp-Lenient-exception-test-matching.patch new file mode 100644 index 000000000000..40d1cb6bf49e --- /dev/null +++ b/pkgs/by-name/pe/persistent-cache-cpp/0001-persistent-cache-cpp-Lenient-exception-test-matching.patch @@ -0,0 +1,41 @@ +From 74265493be3a4826199329d4e6ff8fc49a33850f Mon Sep 17 00:00:00 2001 +From: Puna2608 +Date: Fri, 6 Oct 2023 21:06:13 +0200 +Subject: [PATCH] persistent-cache-cpp: Lenient exception test matching + +PersistentStringCacheImpl::exceptions attempts to very precisely match a returned std::system_error exception text to an expectation. +On LLVM's libcxx, the message returned from it doesn't match the expectation. + +This patch changes the matching to only care about the part that doesn't depend on such an implementation detail. +--- + .../persistent_string_cache_impl_test.cpp | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp b/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp +index f3eee59..fedd466 100644 +--- a/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp ++++ b/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp +@@ -24,6 +24,7 @@ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" + #include ++#include + #pragma GCC diagnostic pop + + #include +@@ -1295,9 +1296,9 @@ TEST(PersistentStringCacheImpl, exceptions) + } + catch (system_error const& e) + { +- EXPECT_EQ("PersistentStringCache: check_version(): bad version: \"nan\" (cache_path: " + TEST_DB + +- "): Unknown error 666", +- e.what()); ++ EXPECT_THAT( ++ e.what(), ++ ::testing::StartsWith("PersistentStringCache: check_version(): bad version: \"nan\" (cache_path: " + TEST_DB + "): ")); + } + } + +-- +2.40.1 + diff --git a/pkgs/by-name/pe/persistent-cache-cpp/package.nix b/pkgs/by-name/pe/persistent-cache-cpp/package.nix index 7461ced7f913..176ee80d6892 100644 --- a/pkgs/by-name/pe/persistent-cache-cpp/package.nix +++ b/pkgs/by-name/pe/persistent-cache-cpp/package.nix @@ -32,12 +32,18 @@ stdenv.mkDerivation (finalAttrs: { url = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/commit/3ed84ee1d32a27d183de2cb5f9feffc3f48fd9a1.patch"; hash = "sha256-aNZ6KVHAsLVYlAcPNNkjUlOPRDZxzN5tzk4/1KuVaSY="; }) + # Fix build on current Boost # Remove when version > 1.0.5 (fetchpatch { url = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/commit/a590ffcccec252caa7b19a2922c678502069b057.patch"; hash = "sha256-OhlsnUVhclt17brkncYkJ0+lXrJO671mtwopaAGPrtY="; }) + + # PersistentStringCacheImpl.exceptions test fails on LLVM's libcxx, it depends on std::system_error producing a very specific exception text + # Expects "Unknown error 666", gets "unspecified generic_category error" + # https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/blob/1.0.5/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp?ref_type=tags#L1298 + ./0001-persistent-cache-cpp-Lenient-exception-test-matching.patch ]; postPatch = '' From 3ddfc8671c4a16ec095eb4fa7017631b30afc747 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Fri, 6 Oct 2023 21:22:21 +0200 Subject: [PATCH 3/5] persistent-cache-cpp: Propagate leveldb libpersistent-cache-cpp is a static library that still needs to be linked with leveldb. Propagating this dependency is easier than trying & failing to link. --- pkgs/by-name/pe/persistent-cache-cpp/package.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/by-name/pe/persistent-cache-cpp/package.nix b/pkgs/by-name/pe/persistent-cache-cpp/package.nix index 176ee80d6892..168f9656bdcb 100644 --- a/pkgs/by-name/pe/persistent-cache-cpp/package.nix +++ b/pkgs/by-name/pe/persistent-cache-cpp/package.nix @@ -69,6 +69,9 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ boost lomiri.cmake-extras + ]; + + propagatedBuildInputs = [ leveldb ]; From 5079ef293082fd890601c05e602e1420a7555032 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 18 Dec 2023 02:17:04 +0100 Subject: [PATCH 4/5] persistent-cache-cpp: 1.0.5 -> 1.0.6 --- .../pe/persistent-cache-cpp/package.nix | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/pkgs/by-name/pe/persistent-cache-cpp/package.nix b/pkgs/by-name/pe/persistent-cache-cpp/package.nix index 168f9656bdcb..8f21ab46c6cb 100644 --- a/pkgs/by-name/pe/persistent-cache-cpp/package.nix +++ b/pkgs/by-name/pe/persistent-cache-cpp/package.nix @@ -1,7 +1,6 @@ { stdenv , lib , fetchFromGitLab -, fetchpatch , gitUpdater , testers , boost @@ -16,30 +15,22 @@ stdenv.mkDerivation (finalAttrs: { pname = "persistent-cache-cpp"; - version = "1.0.5"; + version = "1.0.6"; src = fetchFromGitLab { owner = "ubports"; repo = "development/core/lib-cpp/persistent-cache-cpp"; rev = finalAttrs.version; - hash = "sha256-MOH8ardiTliTKrtRQ5eFRhbRtnC0Yq20WJYoo1tAn3E="; + hash = "sha256-RLZiYY0Y9LT+ajM4Va4MpVVDBlu2yvCpn8bNGMB8ydo="; }; + outputs = [ + "out" + "dev" + "doc" + ]; + patches = [ - # Fix build on GCC 12 - # Remove when version > 1.0.5 - (fetchpatch { - url = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/commit/3ed84ee1d32a27d183de2cb5f9feffc3f48fd9a1.patch"; - hash = "sha256-aNZ6KVHAsLVYlAcPNNkjUlOPRDZxzN5tzk4/1KuVaSY="; - }) - - # Fix build on current Boost - # Remove when version > 1.0.5 - (fetchpatch { - url = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/commit/a590ffcccec252caa7b19a2922c678502069b057.patch"; - hash = "sha256-OhlsnUVhclt17brkncYkJ0+lXrJO671mtwopaAGPrtY="; - }) - # PersistentStringCacheImpl.exceptions test fails on LLVM's libcxx, it depends on std::system_error producing a very specific exception text # Expects "Unknown error 666", gets "unspecified generic_category error" # https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/blob/1.0.5/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp?ref_type=tags#L1298 @@ -54,7 +45,7 @@ stdenv.mkDerivation (finalAttrs: { # Runs in parallel to other tests, limit to 1 thread substituteInPlace tests/headers/compile_headers.py \ --replace 'multiprocessing.cpu_count()' '1' - '' + (if finalAttrs.doCheck then '' + '' + (if finalAttrs.finalPackage.doCheck then '' patchShebangs tests/{headers,whitespace}/*.py '' else '' sed -i -e '/add_subdirectory(tests)/d' CMakeLists.txt From 07130e98563c9467969815060b7f7891a4922ff3 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 18 Dec 2023 02:37:22 +0100 Subject: [PATCH 5/5] persistent-cache-cpp: Fetch upstream-submitted patches --- ...-cpp-Lenient-exception-test-matching.patch | 41 ------------------ .../pe/persistent-cache-cpp/package.nix | 42 +++++++++++++++---- 2 files changed, 35 insertions(+), 48 deletions(-) delete mode 100644 pkgs/by-name/pe/persistent-cache-cpp/0001-persistent-cache-cpp-Lenient-exception-test-matching.patch diff --git a/pkgs/by-name/pe/persistent-cache-cpp/0001-persistent-cache-cpp-Lenient-exception-test-matching.patch b/pkgs/by-name/pe/persistent-cache-cpp/0001-persistent-cache-cpp-Lenient-exception-test-matching.patch deleted file mode 100644 index 40d1cb6bf49e..000000000000 --- a/pkgs/by-name/pe/persistent-cache-cpp/0001-persistent-cache-cpp-Lenient-exception-test-matching.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 74265493be3a4826199329d4e6ff8fc49a33850f Mon Sep 17 00:00:00 2001 -From: Puna2608 -Date: Fri, 6 Oct 2023 21:06:13 +0200 -Subject: [PATCH] persistent-cache-cpp: Lenient exception test matching - -PersistentStringCacheImpl::exceptions attempts to very precisely match a returned std::system_error exception text to an expectation. -On LLVM's libcxx, the message returned from it doesn't match the expectation. - -This patch changes the matching to only care about the part that doesn't depend on such an implementation detail. ---- - .../persistent_string_cache_impl_test.cpp | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp b/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp -index f3eee59..fedd466 100644 ---- a/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp -+++ b/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp -@@ -24,6 +24,7 @@ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" - #include -+#include - #pragma GCC diagnostic pop - - #include -@@ -1295,9 +1296,9 @@ TEST(PersistentStringCacheImpl, exceptions) - } - catch (system_error const& e) - { -- EXPECT_EQ("PersistentStringCache: check_version(): bad version: \"nan\" (cache_path: " + TEST_DB + -- "): Unknown error 666", -- e.what()); -+ EXPECT_THAT( -+ e.what(), -+ ::testing::StartsWith("PersistentStringCache: check_version(): bad version: \"nan\" (cache_path: " + TEST_DB + "): ")); - } - } - --- -2.40.1 - diff --git a/pkgs/by-name/pe/persistent-cache-cpp/package.nix b/pkgs/by-name/pe/persistent-cache-cpp/package.nix index 8f21ab46c6cb..c7d212a477af 100644 --- a/pkgs/by-name/pe/persistent-cache-cpp/package.nix +++ b/pkgs/by-name/pe/persistent-cache-cpp/package.nix @@ -1,6 +1,7 @@ { stdenv , lib , fetchFromGitLab +, fetchpatch , gitUpdater , testers , boost @@ -31,10 +32,38 @@ stdenv.mkDerivation (finalAttrs: { ]; patches = [ + # Version in CMakeLists.txt didn't get bumped, emits wrong version in pkg-config + # Remove when https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/merge_requests/13 merged & in release + (fetchpatch { + name = "0001-persistent-cache-cpp-CMakeLists-txt-Update-version.patch"; + url = "https://gitlab.com/OPNA2608/persistent-cache-cpp/-/commit/20d5d3f61563c62bcbe85e71ddc4fe16d7c995d5.patch"; + hash = "sha256-BKovtT9OvV+xEwBO8AZTxAzL9kqyDB9ip32t2Xx4eIk="; + }) + # PersistentStringCacheImpl.exceptions test fails on LLVM's libcxx, it depends on std::system_error producing a very specific exception text # Expects "Unknown error 666", gets "unspecified generic_category error" - # https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/blob/1.0.5/tests/core/internal/persistent_string_cache_impl/persistent_string_cache_impl_test.cpp?ref_type=tags#L1298 - ./0001-persistent-cache-cpp-Lenient-exception-test-matching.patch + # Remove when https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/merge_requests/14 merged & in release + (fetchpatch { + name = "0002-persistent-cache-cpp-persistent_string_cache_impl_test-libcxx-fix.patch"; + url = "https://gitlab.com/OPNA2608/persistent-cache-cpp/-/commit/a696dbd3093b8333f9ee1f0cad846b2256c729c5.patch"; + hash = "sha256-SJxdXeM7W+WKEmiLTwnQYAM7YmPayEk6vPb46y4thv4="; + }) + + # Enable usage of BUILD_TESTING to opting out of tests + # Remove when https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/merge_requests/15 merged & in release + (fetchpatch { + name = "0003-persistent-cache-cpp-Enable-opting-out-of-tests.patch"; + url = "https://gitlab.com/OPNA2608/persistent-cache-cpp/-/commit/1fb06d28c16325e90046e93662c0f5fd16c29b4a.patch"; + hash = "sha256-2/6EYBh71S4dzqWEde+3dLOGp015fN6IifAj1bI1XAI="; + }) + + # Enable linking based on stdenv (static or dynamic) + # Remove when https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/merge_requests/16 merged & in release + (fetchpatch { + name = "0004-persistent-cache-cpp-Un-hardcode-static-linking.patch"; + url = "https://gitlab.com/OPNA2608/persistent-cache-cpp/-/commit/45cd84fe76e3a0e1da41a662df695009a6f4f07e.patch"; + hash = "sha256-1UjdhzrjnIUO1ySaZTm0vkdNgok0RNlGtNOWUoAUlzU="; + }) ]; postPatch = '' @@ -45,11 +74,9 @@ stdenv.mkDerivation (finalAttrs: { # Runs in parallel to other tests, limit to 1 thread substituteInPlace tests/headers/compile_headers.py \ --replace 'multiprocessing.cpu_count()' '1' - '' + (if finalAttrs.finalPackage.doCheck then '' + '' + lib.optionalString finalAttrs.finalPackage.doCheck '' patchShebangs tests/{headers,whitespace}/*.py - '' else '' - sed -i -e '/add_subdirectory(tests)/d' CMakeLists.txt - ''); + ''; nativeBuildInputs = [ cmake @@ -76,7 +103,8 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ # error: 'old_version' may be used uninitialized - "-DWerror=OFF" + (lib.cmakeBool "Werror" false) + (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) ]; doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;