File: fix-multi-arch-folder-detection.patch

package info (click to toggle)
sight 25.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 43,252 kB
  • sloc: cpp: 310,629; xml: 17,622; ansic: 9,960; python: 1,379; sh: 144; makefile: 33
file content (41 lines) | stat: -rw-r--r-- 2,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Description: Fix multi arch folder detection
Forwarded: https://git.ircad.fr/sight/sight/-/issues/1416

--- sight.orig/lib/__/core/runtime/detail/runtime.cpp
+++ sight/lib/__/core/runtime/detail/runtime.cpp
@@ -60,26 +60,25 @@
 
     // In most cases, we can rely on finding sight_core library and then go upward in the filesystem tree
     // The lib location looks like 'SIGHT_DIR/lib/<arch>/libsight_core.*', where arch is optional
-    const std::string core_path = boost::dll::this_line_location().generic_string();
-    const std::string lib_prefix("/" MODULE_LIB_PREFIX "/");
-    auto it = std::search(core_path.rbegin(), core_path.rend(), lib_prefix.rbegin(), lib_prefix.rend());
+    const std::string core_path = boost::dll::this_line_location().string();
+    const std::string lib_prefix(MODULE_LIB_PREFIX);
+    auto it = std::search(core_path.begin(), core_path.end(), lib_prefix.begin(), lib_prefix.end());
 
-    if(it == core_path.rend())
+    if(it == core_path.end())
     {
         // But if we link statically, for instance linking with sight_core as an object library, then
         // boost::dll::this_line_location() will return the location of the current executable
         // In this case, we know that have to locate the bin directory instead of the library directory
-        const std::string bin_prefix("/" MODULE_BIN_PREFIX "/");
-        it = std::search(core_path.rbegin(), core_path.rend(), bin_prefix.rbegin(), bin_prefix.rend());
+        const std::string bin_prefix(MODULE_BIN_PREFIX);
+        it = std::search(core_path.begin(), core_path.end(), bin_prefix.begin(), bin_prefix.end());
         SIGHT_FATAL_IF(
             "Failed to locate Sight runtime. We tried to guess it from: " + core_path,
-            it == core_path.rend()
+            it == core_path.end()
         );
     }
 
-    const auto dist = std::distance(it, core_path.rend());
-    const std::filesystem::path lib_path(core_path.begin(), core_path.begin() + dist - 1);
-    m_working_path = std::filesystem::weakly_canonical(lib_path.parent_path().make_preferred());
+    const std::filesystem::path lib_path(core_path.begin(), it);
+    m_working_path = lib_path.parent_path();
     SIGHT_INFO("Located Sight runtime in folder: " + m_working_path.string());
 }