From f8659509c289d4f964faea23f148e82bc498e09a Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 3 Aug 2025 20:46:53 +0200 Subject: [PATCH 1/2] add tmpfile android hack --- CMakeLists.txt | 12 ++++++++++++ conanfile.py | 10 ++++++++++ src/odr/global_params.cpp | 16 ++++++++++++++++ src/odr/global_params.hpp | 3 +++ 4 files changed, 41 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b7e3f926..b4da47a33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ option(ODR_CLI "enable command line interface" ON) option(ODR_CLANG_TIDY "Run clang-tidy static analysis" OFF) option(WITH_PDF2HTMLEX "Build with pdf2htmlEX" ON) option(WITH_WVWARE "Build with wvWare" ON) +option(WITH_CUSTOM_TMPFILE "Build with custom temporary file implementation" OFF) # TODO defining global compiler flags seems to be bad practice with conan # TODO consider using conan profiles @@ -247,6 +248,17 @@ if (WITH_WVWARE) ODR_WITH_WVWARE ) endif () +if (WITH_CUSTOM_TMPFILE) + find_package(tmpfile REQUIRED CONFIG) + target_link_libraries(odr + PRIVATE + tmpfile::tmpfile + ) + target_compile_definitions(odr + PRIVATE + ODR_WITH_CUSTOM_TMPFILE + ) +endif () if (EXISTS "${PROJECT_SOURCE_DIR}/.git") add_dependencies(odr check_git) diff --git a/conanfile.py b/conanfile.py index 6a8e22c01..0e8914d18 100644 --- a/conanfile.py +++ b/conanfile.py @@ -19,12 +19,14 @@ class OpenDocumentCoreConan(ConanFile): "fPIC": [True, False], "with_pdf2htmlEX": [True, False], "with_wvWare": [True, False], + "with_customTmpfile": [True, False], } default_options = { "shared": False, "fPIC": True, "with_pdf2htmlEX": True, "with_wvWare": True, + "with_customTmpfile": False, } exports_sources = ["cli/*", "cmake/*", "resources/dist/*", "src/*", "CMakeLists.txt"] @@ -35,6 +37,11 @@ def config_options(self): del self.options.with_pdf2htmlEX del self.options.with_wvWare + if self.settings.os == "Android": + self.default_options.with_customTmpfile = True + else: + del self.options.with_customTmpfile + def requirements(self): self.requires("pugixml/1.14") self.requires("cryptopp/8.9.0") @@ -50,6 +57,9 @@ def requirements(self): self.requires("cpp-httplib/0.16.3") self.requires("argon2/20190702") + if self.options.get_safe("with_customTmpfile", False): + self.requires("tmpfile/3.0.6") + def build_requirements(self): self.test_requires("gtest/1.14.0") diff --git a/src/odr/global_params.cpp b/src/odr/global_params.cpp index cd7f67ebb..f34af2cc9 100644 --- a/src/odr/global_params.cpp +++ b/src/odr/global_params.cpp @@ -6,6 +6,10 @@ #include #endif +#ifdef ODR_WITH_CUSTOM_TMPFILE +#include +#endif + namespace odr { GlobalParams &GlobalParams::instance() { @@ -41,6 +45,10 @@ const std::string &GlobalParams::pdf2htmlex_data_path() { return instance().m_pdf2htmlex_data_path; } +const std::string &GlobalParams::custom_tmpfile_path() { + return instance().m_custom_tmpfile_path; +} + void GlobalParams::set_odr_core_data_path(const std::string &path) { instance().m_odr_core_data_path = path; } @@ -62,6 +70,14 @@ void GlobalParams::set_pdf2htmlex_data_path(const std::string &path) { instance().m_pdf2htmlex_data_path = path; } +void GlobalParams::set_custom_tmpfile_path(const std::string &path) { +#ifdef ODR_WITH_CUSTOM_TMPFILE + set_tmpfile_directory(path.c_str()); +#endif + + instance().m_custom_tmpfile_path = path; +} + GlobalParams::GlobalParams() : m_odr_core_data_path{internal::project_info::odr_data_path()}, m_fontconfig_data_path{internal::project_info::fontconfig_data_path()}, diff --git a/src/odr/global_params.hpp b/src/odr/global_params.hpp index 9888be173..bc9c58a42 100644 --- a/src/odr/global_params.hpp +++ b/src/odr/global_params.hpp @@ -10,11 +10,13 @@ class GlobalParams { static const std::string &fontconfig_data_path(); static const std::string &poppler_data_path(); static const std::string &pdf2htmlex_data_path(); + static const std::string &custom_tmpfile_path(); static void set_odr_core_data_path(const std::string &path); static void set_fontconfig_data_path(const std::string &path); static void set_poppler_data_path(const std::string &path); static void set_pdf2htmlex_data_path(const std::string &path); + static void set_custom_tmpfile_path(const std::string &path); private: static GlobalParams &instance(); @@ -25,6 +27,7 @@ class GlobalParams { std::string m_fontconfig_data_path; std::string m_poppler_data_path; std::string m_pdf2htmlex_data_path; + std::string m_custom_tmpfile_path; }; } // namespace odr From 2556eb204c3121cdd37322071d1e0aadea1cc569 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 4 Aug 2025 08:01:15 +0200 Subject: [PATCH 2/2] fix --- conanfile.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/conanfile.py b/conanfile.py index ef09177c2..19c7c326d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -19,14 +19,14 @@ class OpenDocumentCoreConan(ConanFile): "fPIC": [True, False], "with_pdf2htmlEX": [True, False], "with_wvWare": [True, False], - "with_customTmpfile": [True, False], + "with_tmpfile_hack": [True, False], } default_options = { "shared": False, "fPIC": True, "with_pdf2htmlEX": True, "with_wvWare": True, - "with_customTmpfile": False, + "with_tmpfile_hack": True, } exports_sources = ["cli/*", "cmake/*", "resources/dist/*", "src/*", "CMakeLists.txt"] @@ -37,10 +37,8 @@ def config_options(self): del self.options.with_pdf2htmlEX del self.options.with_wvWare - if self.settings.os == "Android": - self.default_options.with_customTmpfile = True - else: - del self.options.with_customTmpfile + if self.settings.os != "Android": + del self.options.with_tmpfile_hack def requirements(self): self.requires("pugixml/1.14") @@ -57,7 +55,7 @@ def requirements(self): self.requires("cpp-httplib/0.16.3") self.requires("argon2/20190702-odr") - if self.options.get_safe("with_customTmpfile", False): + if self.options.get_safe("with_tmpfile_hack", False): self.requires("tmpfile/3.0.6") def build_requirements(self):