[MacPorts] #69455: poppler @24.03.0: build failure on macOS 10.14 and earlier due to use of std::filesystem
MacPorts
noreply at macports.org
Sun Mar 10 12:31:19 UTC 2024
#69455: poppler @24.03.0: build failure on macOS 10.14 and earlier due to use of
std::filesystem
-------------------------+-------------------------------------------------
Reporter: lukaso | Owner: dbevans
Type: defect | Status: assigned
Priority: Normal | Milestone:
Component: ports | Version: 2.8.1
Resolution: | Keywords: tiger leopard snowleopard lion
| mountainlion mavericks yosemite elcapitan
Port: poppler | sierra highsierra mojave
-------------------------+-------------------------------------------------
Comment (by tomio-arisaka):
Replying to [comment:12 kencu]:
>
> There are also some other replacements for filesystem that might be
interesting to look into, eg
>
> https://github.com/gulrak/filesystem
MacPorts includes ghc-filesystem:
{{{
$ port info ghc-filesystem
ghc-filesystem @1.5.14 (devel)
Variants: debug, tests
Description: An implementation of C++17 std::filesystem for
C++11/C++14/C++17/C++20 on Windows, macOS, Linux and
FreeBSD.
Homepage: https://github.com/gulrak/filesystem
Build Dependencies: cmake
Platforms: any
License: MIT
Maintainers: none
}}}
So I tried to build Poppler-24.03.0 with ghc-filesystem. My example is as
follows:
{{{
$ diff -u Portfile.orig Portfile
--- Portfile.orig 2024-03-06 04:56:12.000000000 +0900
+++ Portfile 2024-03-10 05:30:00.000000000 +0900
@@ -9,7 +9,7 @@
conflicts poppler-devel xpdf-tools
set my_name poppler
version 24.03.0
-revision 0
+revision 2
categories graphics
license GPL-2+
@@ -69,6 +69,17 @@
compiler.c_standard 2011
compiler.thread_local_storage yes
+if {${os.major} < 19} {
+ # change std::filesystem to ghc::filesystem in order to avoid an
error
+ depends_build-append \
+ port:ghc-filesystem
+ patchfiles-append \
+ patch-utils_pdfdetach.cc.diff
+ post-extract {
+ system -W ${worksrcpath} "cp -fRp ${prefix}/include/ghc ./utils/"
+ }
+}
+
# match clang, not strequal
patchfiles-append patch-cmake_modules_PopplerMacros.cmake.diff
}}}
{{{
$ cat ./files/patch-utils_pdfdetach.cc.diff
--- utils/pdfdetach.cc.orig 2024-03-04 02:30:22.000000000 +0900
+++ utils/pdfdetach.cc 2024-03-10 05:20:20.000000000 +0900
@@ -45,7 +45,17 @@
#include "Error.h"
#include "Win32Console.h"
+#if __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED <
101500
+ #include "ghc/filesystem.hpp"
+ namespace fs {
+ using namespace ghc::filesystem;
+ using ifstream = ghc::filesystem::ifstream;
+ using ofstream = ghc::filesystem::ofstream;
+ using fstream = ghc::filesystem::fstream;
+ }
+#else
#include <filesystem>
+#endif
static bool doList = false;
static int saveNum = 0;
@@ -89,6 +99,7 @@
const GooString *s1;
Unicode u;
bool isUnicode;
+ std::error_code ec;
Win32Console win32Console(&argc, &argv);
@@ -194,9 +205,9 @@
// save all embedded files
} else if (saveAll) {
- std::filesystem::path basePath = savePath;
+ ghc::filesystem::path basePath = savePath;
if (basePath.empty()) {
- basePath = std::filesystem::current_path();
+ basePath = ghc::filesystem::current_path(ec);
}
basePath = basePath.lexically_normal();
@@ -230,7 +241,7 @@
if (filename.empty()) {
return 3;
}
- std::filesystem::path filePath = basePath;
+ ghc::filesystem::path filePath = basePath;
filePath = filePath.append(filename).lexically_normal();
if (filePath.generic_string().find(basePath.generic_string())
!= 0) {
@@ -292,8 +303,8 @@
targetPath.append(uBuf, n);
}
- const std::filesystem::path basePath =
std::filesystem::current_path().lexically_normal();
- std::filesystem::path filePath = basePath;
+ const ghc::filesystem::path basePath =
ghc::filesystem::current_path(ec).lexically_normal();
+ ghc::filesystem::path filePath = basePath;
filePath = filePath.append(targetPath).lexically_normal();
if (filePath.generic_string().find(basePath.generic_string())
!= 0) {
}}}
It works well for me.
--
Ticket URL: <https://trac.macports.org/ticket/69455#comment:14>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list