changeset 5813:2b429588de28

fix support for Boost 1.86
author Alain Mazy <am@orthanc.team>
date Wed, 25 Sep 2024 16:27:07 +0200
parents 16df20505710
children 122fd5f97d39
files NEWS OrthancFramework/Resources/CMake/BoostConfiguration.cmake OrthancFramework/Resources/CMake/BoostConfiguration.sh OrthancFramework/Resources/Patches/boost-1.86.0-emscripten.patch OrthancFramework/Sources/Toolbox.cpp
diffstat 5 files changed, 162 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Sep 24 09:26:42 2024 +0200
+++ b/NEWS	Wed Sep 25 16:27:07 2024 +0200
@@ -30,6 +30,8 @@
   before decoding the frame.  This solves some issues with JP2K Lossy compression:
   https://discourse.orthanc-server.org/t/decoding-displaying-jpeg2000-lossy-images/5117
 * Added a new warning that can be disabled in the configuration: W003_DecoderFailure
+* Upgraded dependencies for static builds:
+  - boost 1.86.0
 
 
 
--- a/OrthancFramework/Resources/CMake/BoostConfiguration.cmake	Tue Sep 24 09:26:42 2024 +0200
+++ b/OrthancFramework/Resources/CMake/BoostConfiguration.cmake	Wed Sep 25 16:27:07 2024 +0200
@@ -91,10 +91,10 @@
   ## Parameters for static compilation of Boost 
   ##
   
-  set(BOOST_NAME boost_1_85_0)
-  set(BOOST_VERSION 1.85.0)
-  set(BOOST_BCP_SUFFIX bcpdigest-1.12.4)
-  set(BOOST_MD5 "1017e9c8383efdea01c059a8d3cc4dda")
+  set(BOOST_NAME boost_1_86_0)
+  set(BOOST_VERSION 1.86.0)
+  set(BOOST_BCP_SUFFIX bcpdigest-1.12.5)
+  set(BOOST_MD5 "20b9c325c0dde830889ee75a9e64ded8")
   set(BOOST_URL "https://orthanc.uclouvain.be/downloads/third-party-downloads/${BOOST_NAME}_${BOOST_BCP_SUFFIX}.tar.gz")
   set(BOOST_SOURCES_DIR ${CMAKE_BINARY_DIR}/${BOOST_NAME})
 
@@ -115,7 +115,7 @@
   if (FirstRun)
     execute_process(
       COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
-      ${CMAKE_CURRENT_LIST_DIR}/../Patches/boost-1.85.0-emscripten.patch
+      ${CMAKE_CURRENT_LIST_DIR}/../Patches/boost-1.86.0-emscripten.patch
       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
       RESULT_VARIABLE Failure
       )
--- a/OrthancFramework/Resources/CMake/BoostConfiguration.sh	Tue Sep 24 09:26:42 2024 +0200
+++ b/OrthancFramework/Resources/CMake/BoostConfiguration.sh	Wed Sep 25 16:27:07 2024 +0200
@@ -27,9 +27,10 @@
 ##   - Orthanc 1.12.2: Boost 1.83.0
 ##   - Orthanc 1.12.3: Boost 1.84.0
 ##   - Orthanc > 1.12.3: Boost 1.85.0
+##   - Orthanc 1.12.5: Boost 1.86.0
 
-BOOST_VERSION=1_85_0
-ORTHANC_VERSION=1.12.4
+BOOST_VERSION=1_86_0
+ORTHANC_VERSION=1.12.5
 
 rm -rf /tmp/boost_${BOOST_VERSION}
 rm -rf /tmp/bcp/boost_${BOOST_VERSION}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancFramework/Resources/Patches/boost-1.86.0-emscripten.patch	Wed Sep 25 16:27:07 2024 +0200
@@ -0,0 +1,127 @@
+diff -urEb boost_1_86_0.orig/libs/locale/src/boost/locale/shared/date_time.cpp boost_1_86_0/libs/locale/src/boost/locale/shared/date_time.cpp
+--- boost_1_86_0.orig/libs/locale/src/boost/locale/shared/date_time.cpp	2024-09-25 15:46:01.000000000 +0200
++++ boost_1_86_0/libs/locale/src/boost/locale/shared/date_time.cpp	2024-09-25 15:58:51.306131987 +0200
+@@ -12,8 +12,10 @@
+ #include <boost/locale/date_time.hpp>
+ #include <boost/locale/formatting.hpp>
+ #include <boost/core/exchange.hpp>
+-#include <boost/thread/locks.hpp>
+-#include <boost/thread/mutex.hpp>
++#if !defined(__EMSCRIPTEN__)
++#  include <boost/thread/locks.hpp>
++#  include <boost/thread/mutex.hpp>
++#endif
+ #include <cmath>
+ 
+ namespace boost { namespace locale {
+@@ -400,6 +402,7 @@
+         return impl_->get_option(abstract_calendar::is_dst) != 0;
+     }
+ 
++#if !defined(__EMSCRIPTEN__)
+     namespace time_zone {
+         boost::mutex& tz_mutex()
+         {
+@@ -422,7 +425,7 @@
+             return boost::exchange(tz_id(), new_id);
+         }
+     } // namespace time_zone
+-
++#endif
+ }} // namespace boost::locale
+ 
+ // boostinspect:nominmax
+diff -urEb boost_1_86_0.orig/libs/locale/src/boost/locale/shared/generator.cpp boost_1_86_0/libs/locale/src/boost/locale/shared/generator.cpp
+--- boost_1_86_0.orig/libs/locale/src/boost/locale/shared/generator.cpp	2024-09-25 15:46:01.000000000 +0200
++++ boost_1_86_0/libs/locale/src/boost/locale/shared/generator.cpp	2024-09-25 16:00:07.756233916 +0200
+@@ -7,8 +7,10 @@
+ #include <boost/locale/encoding.hpp>
+ #include <boost/locale/generator.hpp>
+ #include <boost/locale/localization_backend.hpp>
+-#include <boost/thread/locks.hpp>
+-#include <boost/thread/mutex.hpp>
++#if !defined(__EMSCRIPTEN__)
++#  include <boost/thread/locks.hpp>
++#  include <boost/thread/mutex.hpp>
++#endif
+ #include <algorithm>
+ #include <map>
+ #include <vector>
+@@ -21,8 +23,9 @@
+         {}
+ 
+         mutable std::map<std::string, std::locale> cached;
++#if !defined(__EMSCRIPTEN__)
+         mutable boost::mutex cached_lock;
+-
++#endif
+         category_t cats;
+         char_facet_t chars;
+ 
+@@ -101,7 +104,9 @@
+     std::locale generator::generate(const std::locale& base, const std::string& id) const
+     {
+         if(d->caching_enabled) {
++#if !defined(__EMSCRIPTEN__)
+             boost::unique_lock<boost::mutex> guard(d->cached_lock);
++#endif
+             const auto p = d->cached.find(id);
+             if(p != d->cached.end())
+                 return p->second;
+@@ -126,7 +131,9 @@
+                 result = backend->install(result, facet, char_facet_t::nochar);
+         }
+         if(d->caching_enabled) {
++#if !defined(__EMSCRIPTEN__)
+             boost::unique_lock<boost::mutex> guard(d->cached_lock);
++#endif
+             const auto p = d->cached.find(id);
+             if(p == d->cached.end())
+                 d->cached[id] = result;
+diff -urEb boost_1_86_0.orig/libs/locale/src/boost/locale/shared/localization_backend.cpp boost_1_86_0/libs/locale/src/boost/locale/shared/localization_backend.cpp
+--- boost_1_86_0.orig/libs/locale/src/boost/locale/shared/localization_backend.cpp	2024-09-25 15:46:01.000000000 +0200
++++ boost_1_86_0/libs/locale/src/boost/locale/shared/localization_backend.cpp	2024-09-25 16:01:09.196820495 +0200
+@@ -5,8 +5,10 @@
+ // https://www.boost.org/LICENSE_1_0.txt
+ 
+ #include <boost/locale/localization_backend.hpp>
+-#include <boost/thread/locks.hpp>
+-#include <boost/thread/mutex.hpp>
++#if !defined(__EMSCRIPTEN__)
++#  include <boost/thread/locks.hpp>
++#  include <boost/thread/mutex.hpp>
++#endif
+ #include <functional>
+ #include <memory>
+ #include <vector>
+@@ -211,11 +213,13 @@
+             return mgr;
+         }
+ 
++#if !defined(__EMSCRIPTEN__)
+         boost::mutex& localization_backend_manager_mutex()
+         {
+             static boost::mutex the_mutex;
+             return the_mutex;
+         }
++#endif
+         localization_backend_manager& localization_backend_manager_global()
+         {
+             static localization_backend_manager the_manager = make_default_backend_mgr();
+@@ -225,12 +229,16 @@
+ 
+     localization_backend_manager localization_backend_manager::global()
+     {
++#if !defined(__EMSCRIPTEN__)
+         boost::unique_lock<boost::mutex> lock(localization_backend_manager_mutex());
++#endif
+         return localization_backend_manager_global();
+     }
+     localization_backend_manager localization_backend_manager::global(const localization_backend_manager& in)
+     {
++#if !defined(__EMSCRIPTEN__)
+         boost::unique_lock<boost::mutex> lock(localization_backend_manager_mutex());
++#endif
+         return exchange(localization_backend_manager_global(), in);
+     }
+ 
--- a/OrthancFramework/Sources/Toolbox.cpp	Tue Sep 24 09:26:42 2024 +0200
+++ b/OrthancFramework/Sources/Toolbox.cpp	Wed Sep 25 16:27:07 2024 +0200
@@ -812,14 +812,32 @@
       sha1.process_bytes(data, size);
     }
 
+#if BOOST_VERSION >= 108600
+    unsigned char digest[20];
+
+    // Sanity check for the memory layout: A SHA-1 digest is 160 bits wide
+    assert(sizeof(digest) == (160 / 8));
+    assert(sizeof(boost::uuids::detail::sha1::digest_type) == 20);
+
+    // From Boost 1.86, digest_type is "unsigned char[20]" while it was "unsigned int[5]"" in previous versions.
+    // Always perform the cast even if it is useless for Boost < 1.86
+    sha1.get_digest(digest);
+
+    result.resize(8 * 5 + 4);
+    sprintf(&result[0], "%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x",
+            digest[0], digest[1], digest[2], digest[3],
+            digest[4], digest[5], digest[6], digest[7],
+            digest[8], digest[9], digest[10], digest[11],
+            digest[12], digest[13], digest[14], digest[15],
+            digest[16], digest[17], digest[18], digest[19]);
+
+#else
     unsigned int digest[5];
     // Sanity check for the memory layout: A SHA-1 digest is 160 bits wide
     assert(sizeof(unsigned int) == 4 && sizeof(digest) == (160 / 8));
     assert(sizeof(boost::uuids::detail::sha1::digest_type) == 20);
-    
-    // From Boost 1.86, digest_type is "unsigned char[20]" while it was "unsigned int[5]"" in previous versions.
-    // Always perform the cast even if it is useless for Boost < 1.86
-    sha1.get_digest(*(reinterpret_cast<boost::uuids::detail::sha1::digest_type*>(digest)));
+
+    sha1.get_digest(digest));
 
     result.resize(8 * 5 + 4);
     sprintf(&result[0], "%08x-%08x-%08x-%08x-%08x",
@@ -828,6 +846,9 @@
             digest[2],
             digest[3],
             digest[4]);
+
+#endif
+
   }
 
   void Toolbox::ComputeSHA1(std::string& result,