[dev-libs/libmongocrypt] enable inteldfp again, now that FETCHCOMMAND_FULLY_DISCONNECTED is gone

given its "fetching" from local fs its a non-issue
This commit is contained in:
Robert Förster 2024-07-06 02:18:49 +02:00
parent 148a4f8dd7
commit 196defa264
4 changed files with 119 additions and 137 deletions

View File

@ -1,133 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4285f3d39..fe09b8857 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,10 @@ elseif (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
message (WARNING "The CMAKE_MSVC_RUNTIME_LIBRARY variable is set, but CMake is too old to understand it")
endif ()
+if (POLICY CMP0135)
+ cmake_policy (SET CMP0135 NEW)
+endif ()
+
project (mongocrypt C)
# Used for the csfle-markup util:
diff --git a/cmake/IntelDFP.cmake b/cmake/IntelDFP.cmake
index da0cdc2fd..cb6bb48d4 100644
--- a/cmake/IntelDFP.cmake
+++ b/cmake/IntelDFP.cmake
@@ -1,7 +1,5 @@
include (FetchContent)
-find_program (GIT_EXECUTABLE git)
-find_program (PATCH_EXECUTABLE patch)
# When updating the version of IntelDFP, also update the version in etc/purls.txt
set (_default_url "${PROJECT_SOURCE_DIR}/third-party/IntelRDFPMathLib20U2.tar.xz")
@@ -19,18 +17,22 @@ if (NOT INTEL_DFP_LIBRARY_URL_SHA256 STREQUAL "no-verify")
set (_hash_arg URL_HASH "${INTEL_DFP_LIBRARY_URL_HASH}")
endif ()
-# Make the PATCH_COMMAND a no-op if it was disabled
-set (patch_command)
-set (patch_input_opt)
if (NOT INTEL_DFP_LIBRARY_PATCH_ENABLED)
- set (patch_command "${CMAKE_COMMAND}" -E true)
-elseif (GIT_EXECUTABLE)
- set (patch_command "${GIT_EXECUTABLE}" --work-tree=<SOURCE_DIR> apply)
-else ()
- set (patch_command "${PATCH_EXECUTABLE}" --dir=<SOURCE_DIR>)
- set (patch_input_opt -i)
+ set (patch_disabled ON)
endif ()
+include (Patch)
+make_patch_command (patch_command
+ STRIP_COMPONENTS 4
+ DIRECTORY "<SOURCE_DIR>"
+ DISABLED "${patch_disabled}"
+ PATCHES
+ "${PROJECT_SOURCE_DIR}/etc/mongo-inteldfp-s390x.patch"
+ "${PROJECT_SOURCE_DIR}/etc/mongo-inteldfp-MONGOCRYPT-571.patch"
+ "${PROJECT_SOURCE_DIR}/etc/mongo-inteldfp-libmongocrypt-pr-625.patch"
+ "${PROJECT_SOURCE_DIR}/etc/mongo-inteldfp-alpine-arm-fix.patch"
+ )
+
# NOTE: The applying of the patch expects the correct input directly from the
# expanded archive. If the patch needs to be reapplied, you may see errors
# about trying to update the intel_dfp component. If you are seeing such
@@ -40,14 +42,7 @@ FetchContent_Declare (
intel_dfp
URL "${_default_url}"
${_hash_arg}
- PATCH_COMMAND
- ${patch_command}
- -p 4 # Strip four path components
- ${patch_input_opt} "${PROJECT_SOURCE_DIR}/etc/mongo-inteldfp-s390x.patch"
- ${patch_input_opt} "${PROJECT_SOURCE_DIR}/etc/mongo-inteldfp-MONGOCRYPT-571.patch"
- ${patch_input_opt} "${PROJECT_SOURCE_DIR}/etc/mongo-inteldfp-libmongocrypt-pr-625.patch"
- ${patch_input_opt} "${PROJECT_SOURCE_DIR}/etc/mongo-inteldfp-alpine-arm-fix.patch"
- --verbose
+ PATCH_COMMAND ${patch_command} --verbose
)
FetchContent_GetProperties (intel_dfp)
diff --git a/cmake/Patch.cmake b/cmake/Patch.cmake
new file mode 100644
index 000000000..057e91a48
--- /dev/null
+++ b/cmake/Patch.cmake
@@ -0,0 +1,52 @@
+find_program(GIT_EXECUTABLE git)
+find_program(PATCH_EXECUTABLE patch)
+
+#[[
+ Form a new Patch-applying command for the given inputs
+
+ make_patch_command(
+ <outvar>
+ [DISABLED <bool>]
+ [DIRECTORY <dir>]
+ [STRIP_COMPONENTS <N>]
+ PATCHES [<file> ...]
+ )
+]]
+function(make_patch_command out)
+ cmake_parse_arguments(PARSE_ARGV 1 patch "" "DIRECTORY;STRIP_COMPONENTS;DISABLED" "PATCHES")
+ if(patch_DISABLED)
+ # Use a placeholder "no-op" patch command.
+ set(cmd "${CMAKE_COMMAND}" "-E" "true")
+ elseif(GIT_EXECUTABLE)
+ # git ...
+ set(cmd ${GIT_EXECUTABLE})
+
+ if(patch_DIRECTORY)
+ # git --work-tree=...
+ list(APPEND cmd --work-tree=${patch_DIRECTORY})
+ endif()
+ # git ... apply ...
+ list(APPEND cmd apply)
+ # git ... apply -pN ...
+ if(patch_STRIP_COMPONENTS)
+ list(APPEND cmd -p${patch_STRIP_COMPONENTS})
+ endif()
+ # git accepts patch filepaths as positional arguments
+ list(APPEND cmd ${patch_PATCHES})
+ else()
+ # patch ...
+ set(cmd ${PATCH_EXECUTABLE})
+ if(patch_DIRECTORY)
+ # patch --dir=...
+ list(APPEND cmd --dir=${patch_DIRECTORY})
+ endif()
+ # patch ... -pN ...
+ if(patch_STRIP_COMPONENTS)
+ list(APPEND cmd -p${patch_STRIP_COMPONENTS})
+ endif()
+ # Prepend "--input=" to each patch filepath and add them to the argv
+ list(TRANSFORM patch_PATCHES PREPEND "--input=")
+ list(APPEND cmd ${patch_PATCHES})
+ endif()
+ set("${out}" "${cmd}" PARENT_SCOPE)
+endfunction()

View File

@ -0,0 +1,91 @@
From 887361a9e3bc3cfae306badb9f583e20bc808410 Mon Sep 17 00:00:00 2001
From: Kevin Albertson <kevin.albertson@mongodb.com>
Date: Fri, 5 Jul 2024 09:44:18 -0400
Subject: [PATCH 1/2] MONGOCRYPT-706 clear `BUILD_VERSION` before including C
driver
To prevent applying `BUILD_VERSION` intended for libmongocrypt to the C driver.
---
cmake/ImportBSON.cmake | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/cmake/ImportBSON.cmake b/cmake/ImportBSON.cmake
index 58d863b87..ae489cfb5 100644
--- a/cmake/ImportBSON.cmake
+++ b/cmake/ImportBSON.cmake
@@ -142,9 +142,16 @@ function (_import_bson)
set (ENABLE_EXTRA_ALIGNMENT ${_extra_alignment_default} CACHE BOOL "Toggle extra alignment of bson_t")
# We don't want the subproject to find libmongocrypt
set (ENABLE_CLIENT_SIDE_ENCRYPTION OFF CACHE BOOL "Disable client-side encryption for the libmongoc subproject")
- # Set `BUILD_VERSION` so C driver does not use a `BUILD_VERSION` meant for libmongocrypt.
+ # Clear `BUILD_VERSION` so C driver does not use a `BUILD_VERSION` meant for libmongocrypt.
# Both libmongocrypt and C driver support setting a `BUILD_VERSION` to override the version.
- set (BUILD_VERSION ${MONGOC_FETCH_TAG_FOR_LIBBSON})
+ if (DEFINED CACHE{BUILD_VERSION})
+ set (SAVED_CACHED_BUILD_VERSION "${BUILD_VERSION}")
+ unset (BUILD_VERSION CACHE) # Undefine cache variable.
+ endif ()
+ if (DEFINED BUILD_VERSION)
+ set (SAVED_BUILD_VERSION "${BUILD_VERSION}")
+ unset (BUILD_VERSION) # Undefine normal variable.
+ endif ()
# Disable building tests in C driver:
set (ENABLE_TESTS OFF)
set (BUILD_TESTING OFF)
@@ -157,6 +164,12 @@ function (_import_bson)
else ()
add_subdirectory ("${MONGOCRYPT_MONGOC_DIR}" _mongo-c-driver EXCLUDE_FROM_ALL)
endif ()
+ if (DEFINED SAVED_CACHED_BUILD_VERSION)
+ set (BUILD_VERSION "${SAVED_CACHED_BUILD_VERSION}" CACHE STRING "Library version")
+ endif ()
+ if (DEFINED SAVED_BUILD_VERSION)
+ set (BUILD_VERSION "${SAVED_BUILD_VERSION}")
+ endif ()
if (TARGET mongoc_static)
# Workaround: Embedded mongoc_static does not set its INCLUDE_DIRECTORIES for user targets
target_include_directories (mongoc_static
From 5d4657060df0a3ab22293094669fe769aa8bfde3 Mon Sep 17 00:00:00 2001
From: Kevin Albertson <kevin.albertson@mongodb.com>
Date: Fri, 5 Jul 2024 16:30:38 -0400
Subject: [PATCH 2/2] use lowercase variable names
---
cmake/ImportBSON.cmake | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/cmake/ImportBSON.cmake b/cmake/ImportBSON.cmake
index ae489cfb5..fac2cb921 100644
--- a/cmake/ImportBSON.cmake
+++ b/cmake/ImportBSON.cmake
@@ -145,11 +145,11 @@ function (_import_bson)
# Clear `BUILD_VERSION` so C driver does not use a `BUILD_VERSION` meant for libmongocrypt.
# Both libmongocrypt and C driver support setting a `BUILD_VERSION` to override the version.
if (DEFINED CACHE{BUILD_VERSION})
- set (SAVED_CACHED_BUILD_VERSION "${BUILD_VERSION}")
+ set (saved_cached_build_version "${BUILD_VERSION}")
unset (BUILD_VERSION CACHE) # Undefine cache variable.
endif ()
if (DEFINED BUILD_VERSION)
- set (SAVED_BUILD_VERSION "${BUILD_VERSION}")
+ set (saved_build_version "${BUILD_VERSION}")
unset (BUILD_VERSION) # Undefine normal variable.
endif ()
# Disable building tests in C driver:
@@ -164,11 +164,11 @@ function (_import_bson)
else ()
add_subdirectory ("${MONGOCRYPT_MONGOC_DIR}" _mongo-c-driver EXCLUDE_FROM_ALL)
endif ()
- if (DEFINED SAVED_CACHED_BUILD_VERSION)
- set (BUILD_VERSION "${SAVED_CACHED_BUILD_VERSION}" CACHE STRING "Library version")
+ if (DEFINED saved_cached_build_version)
+ set (BUILD_VERSION "${saved_cached_build_version}" CACHE STRING "Library version")
endif ()
- if (DEFINED SAVED_BUILD_VERSION)
- set (BUILD_VERSION "${SAVED_BUILD_VERSION}")
+ if (DEFINED saved_build_version)
+ set (BUILD_VERSION "${saved_build_version}")
endif ()
if (TARGET mongoc_static)
# Workaround: Embedded mongoc_static does not set its INCLUDE_DIRECTORIES for user targets

View File

@ -0,0 +1,24 @@
From 0fd2c3d04a17e4957c4b4fcc838de12756de3311 Mon Sep 17 00:00:00 2001
From: Kevin Albertson <kevin.albertson@mongodb.com>
Date: Mon, 17 Jun 2024 13:33:40 -0400
Subject: [PATCH] enable policy CMP0135 (#835)
---
CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4285f3d39..fe09b8857 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,10 @@ elseif (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
message (WARNING "The CMAKE_MSVC_RUNTIME_LIBRARY variable is set, but CMake is too old to understand it")
endif ()
+if (POLICY CMP0135)
+ cmake_policy (SET CMP0135 NEW)
+endif ()
+
project (mongocrypt C)
# Used for the csfle-markup util:

View File

@ -24,9 +24,10 @@ DEPEND="${RDEPEND}
dev-libs/libbson[static-libs]
)"
#PATCHES=(
# "${FILESDIR}/inteldfp.patch"
#)
PATCHES=(
"${FILESDIR}/${P}-cmake.patch"
"${FILESDIR}/${P}-build-version.patch"
)
src_configure() {
local mycmakeargs=(
@ -35,7 +36,6 @@ src_configure() {
-DMONGOCRYPT_MONGOC_DIR=USE-SYSTEM
-DENABLE_ONLINE_TESTS=OFF
-DBUILD_VERSION=${PV}
-DMONGOCRYPT_ENABLE_DECIMAL128=OFF
-DENABLE_STATIC="$(usex static-libs ON OFF)"
)