diff options
author | Miguel Borges de Freitas <92enen@gmail.com> | 2023-11-16 16:49:30 +0000 |
---|---|---|
committer | Miguel Borges de Freitas <92enen@gmail.com> | 2024-06-22 15:39:00 +0100 |
commit | c908d1c849c5a1f6eb6a6b85df4d02394dfdce60 (patch) | |
tree | d3847afe4038332840607954da50faabb50bd6c4 /tools | |
parent | f2b3913b64138c30bacfb7fbbc8ba0736eda6b3d (diff) |
[depends] Add exiv2 to depends
Co-authored-by: fuzzard <fuzzard@kodi.tv>
Diffstat (limited to 'tools')
6 files changed, 832 insertions, 0 deletions
diff --git a/tools/depends/target/Makefile b/tools/depends/target/Makefile index e47e8bff26..a815853007 100644 --- a/tools/depends/target/Makefile +++ b/tools/depends/target/Makefile @@ -152,6 +152,7 @@ download: $(DOWNLOAD_TARGETS) crossguid: $(LIBUUID) curl: brotli openssl nghttp2 $(ZLIB) dbus: expat +exiv2: $(ICONV) $(ZLIB) expat ffmpeg: $(ICONV) $(ZLIB) bzip2 gnutls dav1d $(LIBVA) fontconfig: freetype2 expat $(ICONV) $(LIBUUID) freetype2: bzip2 harfbuzz $(ZLIB) diff --git a/tools/depends/target/exiv2/0001-Add-EXIV2_ENABLE_FILESYSTEM_ACCESS-option.patch b/tools/depends/target/exiv2/0001-Add-EXIV2_ENABLE_FILESYSTEM_ACCESS-option.patch new file mode 100644 index 0000000000..85983690f1 --- /dev/null +++ b/tools/depends/target/exiv2/0001-Add-EXIV2_ENABLE_FILESYSTEM_ACCESS-option.patch @@ -0,0 +1,564 @@ +From 64acd1a9b4a83ae9fb093660245bb1206cf3817b Mon Sep 17 00:00:00 2001 +From: Miguel Borges de Freitas <92enen@gmail.com> +Date: Fri, 17 Nov 2023 17:08:29 +0000 +Subject: [PATCH 1/2] Add EXIV2_ENABLE_FILESYSTEM_ACCESS option + +--- + CMakeLists.txt | 3 ++- + README.md | 1 + + cmake/config.h.cmake | 3 +++ + cmake/findDependencies.cmake | 4 +++- + cmake/generateConfigFile.cmake | 9 +++++---- + cmake/printSummary.cmake | 1 + + include/exiv2/basicio.hpp | 4 +++- + include/exiv2/exif.hpp | 6 ++++++ + include/exiv2/preview.hpp | 2 ++ + meson.build | 1 + + src/basicio.cpp | 32 +++++++++++++++++--------------- + src/exif.cpp | 6 ++++++ + src/futils.cpp | 10 ++++++++++ + src/image.cpp | 14 +++++++++++++- + src/makernote_int.cpp | 8 +++++++- + src/preview.cpp | 2 ++ + src/tiffcomposite_int.cpp | 2 +- + 17 files changed, 83 insertions(+), 25 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e9f14f722..36266d41a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -36,7 +36,7 @@ option( EXIV2_ENABLE_BMFF "Build with BMFF support" + option( EXIV2_ENABLE_BROTLI "Use Brotli for JPEG XL compressed boxes (BMFF)" ON ) + option( EXIV2_ENABLE_VIDEO "Build with video support" ON ) + option( EXIV2_ENABLE_INIH "Use inih library" ON ) +- ++option( EXIV2_ENABLE_FILESYSTEM_ACCESS "Build with filesystem access" ON ) + option( EXIV2_BUILD_SAMPLES "Build sample applications" OFF ) + option( EXIV2_BUILD_EXIV2_COMMAND "Build exiv2 command-line executable" ON ) + option( EXIV2_BUILD_UNIT_TESTS "Build unit tests" OFF ) +@@ -106,6 +106,7 @@ if(EXIV2_BUILD_EXIV2_COMMAND) + + if( EXIV2_BUILD_SAMPLES ) + add_subdirectory( samples ) ++ set(EXIV2_ENABLE_FILESYSTEM_ACCESS ON) + get_directory_property(SAMPLES DIRECTORY samples DEFINITION APPLICATIONS) + + if (Python3_Interpreter_FOUND) +diff --git a/README.md b/README.md +index 63c9a1c4f..331065363 100644 +--- a/README.md ++++ b/README.md +@@ -254,6 +254,7 @@ option( EXIV2_ENABLE_PNG "Build with png support (requires libz)" + ... + option( EXIV2_ENABLE_BMFF "Build with BMFF support (brotli recommended)" ON ) + option( EXIV2_ENABLE_BROTLI "Use Brotli for JPEG XL compressed boxes (BMFF)" ON ) ++option( EXIV2_ENABLE_FILESYSTEM_ACCESS "Build with filesystem access" ON ) + 577 rmills@rmillsmm:~/gnu/github/exiv2/exiv2 $ + ``` + +diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake +index a817d2d1b..f24cd4a63 100644 +--- a/cmake/config.h.cmake ++++ b/cmake/config.h.cmake +@@ -6,6 +6,9 @@ + // Define to 1 if you want to use libcurl in httpIO. + #cmakedefine EXV_USE_CURL + ++// Define to 1 if you want to enable filesystem access ++#cmakedefine EXV_ENABLE_FILESYSTEM ++ + // Define if you require webready support. + #cmakedefine EXV_ENABLE_WEBREADY + +diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake +index 5ee481d1c..5159cb0b7 100644 +--- a/cmake/findDependencies.cmake ++++ b/cmake/findDependencies.cmake +@@ -35,7 +35,9 @@ if (NOT Python3_Interpreter_FOUND) + message(WARNING "Python3 was not found. Python tests under the 'tests' folder will not be executed") + endif() + +-find_package(Filesystem COMPONENTS Experimental Final REQUIRED) ++if(EXIV2_ENABLE_FILESYSTEM_ACCESS) ++ find_package(Filesystem COMPONENTS Experimental Final REQUIRED) ++endif() + + # don't use Frameworks on the Mac (#966) + if (APPLE) +diff --git a/cmake/generateConfigFile.cmake b/cmake/generateConfigFile.cmake +index 49c9a10f6..20e331c04 100644 +--- a/cmake/generateConfigFile.cmake ++++ b/cmake/generateConfigFile.cmake +@@ -6,10 +6,11 @@ include(CheckCXXSymbolExists) + if (${EXIV2_ENABLE_WEBREADY}) + set(EXV_USE_CURL ${EXIV2_ENABLE_CURL}) + endif() +-set(EXV_ENABLE_BMFF ${EXIV2_ENABLE_BMFF}) +-set(EXV_ENABLE_WEBREADY ${EXIV2_ENABLE_WEBREADY}) +-set(EXV_HAVE_LENSDATA ${EXIV2_ENABLE_LENSDATA}) +-set(EXV_ENABLE_INIH ${EXIV2_ENABLE_INIH}) ++set(EXV_ENABLE_BMFF ${EXIV2_ENABLE_BMFF}) ++set(EXV_ENABLE_WEBREADY ${EXIV2_ENABLE_WEBREADY}) ++set(EXV_HAVE_LENSDATA ${EXIV2_ENABLE_LENSDATA}) ++set(EXV_ENABLE_INIH ${EXIV2_ENABLE_INIH}) ++set(EXV_ENABLE_FILESYSTEM ${EXIV2_ENABLE_FILESYSTEM_ACCESS}) + + set(EXV_PACKAGE_NAME ${PROJECT_NAME}) + set(EXV_PACKAGE_VERSION ${PROJECT_VERSION}) +diff --git a/cmake/printSummary.cmake b/cmake/printSummary.cmake +index 854323ba0..06b2745a2 100644 +--- a/cmake/printSummary.cmake ++++ b/cmake/printSummary.cmake +@@ -69,4 +69,5 @@ OptionOutput( "Building unit tests: " EXIV2_BUILD_UNIT_TESTS + OptionOutput( "Building fuzz tests: " EXIV2_BUILD_FUZZ_TESTS ) + OptionOutput( "Building doc: " EXIV2_BUILD_DOC ) + OptionOutput( "Building with coverage flags: " BUILD_WITH_COVERAGE ) ++OptionOutput( "Building with filesystem access " EXIV2_ENABLE_FILESYSTEM_ACCESS ) + OptionOutput( "Using ccache: " BUILD_WITH_CCACHE ) +diff --git a/include/exiv2/basicio.hpp b/include/exiv2/basicio.hpp +index 179220464..71155136d 100644 +--- a/include/exiv2/basicio.hpp ++++ b/include/exiv2/basicio.hpp +@@ -276,6 +276,7 @@ class EXIV2API IoCloser { + IoCloser& operator=(const IoCloser&) = delete; + }; // class IoCloser + ++#ifdef EXV_ENABLE_FILESYSTEM + /*! + @brief Provides binary file IO by implementing the BasicIo + interface. +@@ -479,6 +480,7 @@ class EXIV2API FileIo : public BasicIo { + std::unique_ptr<Impl> p_; + + }; // class FileIo ++#endif + + /*! + @brief Provides binary IO on blocks of memory by implementing the BasicIo +@@ -686,7 +688,7 @@ class EXIV2API XPathIo : public MemIo { + */ + void ReadDataUri(const std::string& path); + }; // class XPathIo +-#else ++#elif defined(EXV_ENABLE_FILESYSTEM) + class EXIV2API XPathIo : public FileIo { + public: + /*! +diff --git a/include/exiv2/exif.hpp b/include/exiv2/exif.hpp +index 8b1d3d6a4..1228b5dd4 100644 +--- a/include/exiv2/exif.hpp ++++ b/include/exiv2/exif.hpp +@@ -229,6 +229,7 @@ class EXIV2API ExifThumbC { + data buffer and %DataBuf ensures that it will be deleted. + */ + [[nodiscard]] DataBuf copy() const; ++#ifdef EXV_ENABLE_FILESYSTEM + /*! + @brief Write the thumbnail image to a file. + +@@ -240,6 +241,7 @@ class EXIV2API ExifThumbC { + @return The number of bytes written. + */ + [[nodiscard]] size_t writeFile(const std::string& path) const; ++#endif + /*! + @brief Return the MIME type of the thumbnail, either \c "image/tiff" + or \c "image/jpeg". +@@ -279,6 +281,7 @@ class EXIV2API ExifThumb : public ExifThumbC { + + //! @name Manipulators + //@{ ++#ifdef EXV_ENABLE_FILESYSTEM + /*! + @brief Set the Exif thumbnail to the JPEG image \em path. Set + XResolution, YResolution and ResolutionUnit to \em xres, +@@ -297,6 +300,7 @@ class EXIV2API ExifThumb : public ExifThumbC { + application that comes with OS X for one.) - David Harvey. + */ + void setJpegThumbnail(const std::string& path, URational xres, URational yres, uint16_t unit); ++#endif + /*! + @brief Set the Exif thumbnail to the JPEG image pointed to by \em buf, + and size \em size. Set XResolution, YResolution and +@@ -315,6 +319,7 @@ class EXIV2API ExifThumb : public ExifThumbC { + application that comes with OS X for one.) - David Harvey. + */ + void setJpegThumbnail(const byte* buf, size_t size, URational xres, URational yres, uint16_t unit); ++#ifdef EXV_ENABLE_FILESYSTEM + /*! + @brief Set the Exif thumbnail to the JPEG image \em path. + +@@ -329,6 +334,7 @@ class EXIV2API ExifThumb : public ExifThumbC { + @note Additional existing Exif thumbnail tags are not modified. + */ + void setJpegThumbnail(const std::string& path); ++#endif + /*! + @brief Set the Exif thumbnail to the JPEG image pointed to by \em buf, + and size \em size. +diff --git a/include/exiv2/preview.hpp b/include/exiv2/preview.hpp +index 295c35b5c..db069ec8c 100644 +--- a/include/exiv2/preview.hpp ++++ b/include/exiv2/preview.hpp +@@ -68,6 +68,7 @@ class EXIV2API PreviewImage { + @brief Return the size of the preview image in bytes. + */ + [[nodiscard]] uint32_t size() const; ++#ifdef EXV_ENABLE_FILESYSTEM + /*! + @brief Write the thumbnail image to a file. + +@@ -79,6 +80,7 @@ class EXIV2API PreviewImage { + @return The number of bytes written. + */ + [[nodiscard]] size_t writeFile(const std::string& path) const; ++#endif + /*! + @brief Return the MIME type of the preview image, usually either + \c "image/tiff" or \c "image/jpeg". +diff --git a/meson.build b/meson.build +index 5c205d845..1b141d5cf 100644 +--- a/meson.build ++++ b/meson.build +@@ -116,6 +116,7 @@ cdata.set('EXV_HAVE_LIBZ', zlib_dep.found()) + cdata.set('EXV_USE_CURL', curl_dep.found()) + cdata.set('EXV_ENABLE_NLS', intl_dep.found()) + cdata.set('EXV_ENABLE_WEBREADY', curl_dep.found()) ++cdata.set('EXV_ENABLE_FILESYSTEM', true) + + cfile = configure_file( + input: 'cmake/config.h.cmake', +diff --git a/src/basicio.cpp b/src/basicio.cpp +index 1986622b3..36509b16b 100644 +--- a/src/basicio.cpp ++++ b/src/basicio.cpp +@@ -36,6 +36,7 @@ + #include <curl/curl.h> + #endif + ++#ifdef EXV_ENABLE_FILESYSTEM + #ifdef _WIN32 + using mode_t = unsigned short; + #include <io.h> +@@ -49,19 +50,7 @@ namespace fs = std::filesystem; + #include <experimental/filesystem> + namespace fs = std::experimental::filesystem; + #endif +- +-// ***************************************************************************** +-// class member definitions +-namespace { +-/// @brief replace each substring of the subject that matches the given search string with the given replacement. +-void ReplaceStringInPlace(std::string& subject, std::string_view search, std::string_view replace) { +- auto pos = subject.find(search); +- while (pos != std::string::npos) { +- subject.replace(pos, search.length(), replace); +- pos += subject.find(search, pos + replace.length()); +- } +-} +-} // namespace ++#endif + + namespace Exiv2 { + void BasicIo::readOrThrow(byte* buf, size_t rcount, ErrorCode err) { +@@ -75,6 +64,7 @@ void BasicIo::seekOrThrow(int64_t offset, Position pos, ErrorCode err) { + Internal::enforce(r == 0, err); + } + ++#ifdef EXV_ENABLE_FILESYSTEM + //! Internal Pimpl structure of class FileIo. + class FileIo::Impl { + public: +@@ -570,6 +560,7 @@ const std::string& FileIo::path() const noexcept { + + void FileIo::populateFakeData() { + } ++#endif + + //! Internal Pimpl structure of class MemIo. + class MemIo::Impl final { +@@ -918,7 +909,7 @@ void XPathIo::ReadDataUri(const std::string& path) { + delete[] decodeData; + } + +-#else ++#elif defined(EXV_ENABLE_FILESYSTEM) + XPathIo::XPathIo(const std::string& orgPath) : FileIo(XPathIo::writeDataToFile(orgPath)), tempFilePath_(path()) { + } + +@@ -933,6 +924,16 @@ void XPathIo::transfer(BasicIo& src) { + if (isTemp_) { + // replace temp path to gent path. + auto currentPath = path(); ++ ++ // replace each substring of the subject that matches the given search string with the given replacement. ++ auto ReplaceStringInPlace = [](std::string& subject, std::string_view search, std::string_view replace) { ++ auto pos = subject.find(search); ++ while (pos != std::string::npos) { ++ subject.replace(pos, search.length(), replace); ++ pos += subject.find(search, pos + replace.length()); ++ } ++ }; ++ + ReplaceStringInPlace(currentPath, XPathIo::TEMP_FILE_EXT, XPathIo::GEN_FILE_EXT); + setPath(currentPath); + +@@ -1726,7 +1727,7 @@ CurlIo::CurlIo(const std::string& url, size_t blockSize) { + + // ************************************************************************* + // free functions +- ++#ifdef EXV_ENABLE_FILESYSTEM + DataBuf readFile(const std::string& path) { + FileIo file(path); + if (file.open("rb") != 0) { +@@ -1750,6 +1751,7 @@ size_t writeFile(const DataBuf& buf, const std::string& path) { + } + return file.write(buf.c_data(), buf.size()); + } ++#endif + + #ifdef EXV_USE_CURL + size_t curlWriter(char* data, size_t size, size_t nmemb, std::string* writerData) { +diff --git a/src/exif.cpp b/src/exif.cpp +index 4f61b074c..9c300e531 100644 +--- a/src/exif.cpp ++++ b/src/exif.cpp +@@ -375,6 +375,7 @@ DataBuf ExifThumbC::copy() const { + return thumbnail->copy(exifData_); + } + ++#ifdef EXV_ENABLE_FILESYSTEM + size_t ExifThumbC::writeFile(const std::string& path) const { + auto thumbnail = Thumbnail::create(exifData_); + if (!thumbnail) +@@ -387,6 +388,7 @@ size_t ExifThumbC::writeFile(const std::string& path) const { + + return Exiv2::writeFile(buf, name); + } ++#endif + + const char* ExifThumbC::mimeType() const { + auto thumbnail = Thumbnail::create(exifData_); +@@ -405,10 +407,12 @@ const char* ExifThumbC::extension() const { + ExifThumb::ExifThumb(ExifData& exifData) : ExifThumbC(exifData), exifData_(exifData) { + } + ++#ifdef EXV_ENABLE_FILESYSTEM + void ExifThumb::setJpegThumbnail(const std::string& path, URational xres, URational yres, uint16_t unit) { + DataBuf thumb = readFile(path); // may throw + setJpegThumbnail(thumb.c_data(), thumb.size(), xres, yres, unit); + } ++#endif + + void ExifThumb::setJpegThumbnail(const byte* buf, size_t size, URational xres, URational yres, uint16_t unit) { + setJpegThumbnail(buf, size); +@@ -417,10 +421,12 @@ void ExifThumb::setJpegThumbnail(const byte* buf, size_t size, URational xres, U + exifData_["Exif.Thumbnail.ResolutionUnit"] = unit; + } + ++#ifdef EXV_ENABLE_FILESYSTEM + void ExifThumb::setJpegThumbnail(const std::string& path) { + DataBuf thumb = readFile(path); // may throw + setJpegThumbnail(thumb.c_data(), thumb.size()); + } ++#endif + + void ExifThumb::setJpegThumbnail(const byte* buf, size_t size) { + exifData_["Exif.Thumbnail.Compression"] = static_cast<uint16_t>(6); +diff --git a/src/futils.cpp b/src/futils.cpp +index c746838d5..0fd5024d4 100644 +--- a/src/futils.cpp ++++ b/src/futils.cpp +@@ -15,6 +15,7 @@ + #include <sstream> + #include <stdexcept> + ++#ifdef EXV_ENABLE_FILESYSTEM + #if __has_include(<filesystem>) + #include <filesystem> + namespace fs = std::filesystem; +@@ -22,6 +23,7 @@ namespace fs = std::filesystem; + #include <experimental/filesystem> + namespace fs = std::experimental::filesystem; + #endif ++#endif + + #if defined(_WIN32) + // clang-format off +@@ -230,7 +232,11 @@ bool fileExists(const std::string& path) { + if (fileProtocol(path) != pFile) { + return true; + } ++#ifdef EXV_ENABLE_FILESYSTEM + return fs::exists(path); ++#else ++ return false; ++#endif + } + + std::string strError() { +@@ -340,6 +346,7 @@ Uri Uri::Parse(const std::string& uri) { + } + + std::string getProcessPath() { ++#ifdef EXV_ENABLE_FILESYSTEM + #if defined(__FreeBSD__) + std::string ret("unknown"); + unsigned int n; +@@ -381,5 +388,8 @@ std::string getProcessPath() { + return "unknown"; + } + #endif ++#else ++ return "unknown"; ++#endif + } + } // namespace Exiv2 +diff --git a/src/image.cpp b/src/image.cpp +index 05d8345f9..9bbe1f272 100644 +--- a/src/image.cpp ++++ b/src/image.cpp +@@ -116,11 +116,13 @@ constexpr Registry registry[] = { + #endif // EXV_ENABLE_BMFF + }; + ++#ifdef EXV_ENABLE_FILESYSTEM + std::string pathOfFileUrl(const std::string& url) { + std::string path = url.substr(7); + size_t found = path.find('/'); + return (found == std::string::npos) ? path : path.substr(found); + } ++#endif + + } // namespace + +@@ -748,9 +750,13 @@ bool ImageFactory::checkType(ImageType type, BasicIo& io, bool advance) { + return false; + } + +-ImageType ImageFactory::getType(const std::string& path) { ++ImageType ImageFactory::getType([[maybe_unused]] const std::string& path) { ++#ifdef EXV_ENABLE_FILESYSTEM + FileIo fileIo(path); + return getType(fileIo); ++#else ++ return ImageType::none; ++#endif + } + + ImageType ImageFactory::getType(const byte* data, size_t size) { +@@ -781,12 +787,16 @@ BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, bool useCurl) + + if (fProt == pHttp) + return std::make_unique<HttpIo>(path); // may throw ++#ifdef EXV_ENABLE_FILESYSTEM + if (fProt == pFileUri) + return std::make_unique<FileIo>(pathOfFileUrl(path)); + if (fProt == pStdin || fProt == pDataUri) + return std::make_unique<XPathIo>(path); // may throw + + return std::make_unique<FileIo>(path); ++#else ++ return nullptr; ++#endif + + (void)(useCurl); + } // ImageFactory::createIo +@@ -817,6 +827,7 @@ Image::UniquePtr ImageFactory::open(BasicIo::UniquePtr io) { + return nullptr; + } + ++#ifdef EXV_ENABLE_FILESYSTEM + Image::UniquePtr ImageFactory::create(ImageType type, const std::string& path) { + auto fileIo = std::make_unique<FileIo>(path); + // Create or overwrite the file, then close it +@@ -831,6 +842,7 @@ Image::UniquePtr ImageFactory::create(ImageType type, const std::string& path) { + throw Error(ErrorCode::kerUnsupportedImageType, static_cast<int>(type)); + return image; + } ++#endif + + Image::UniquePtr ImageFactory::create(ImageType type) { + auto image = create(type, std::make_unique<MemIo>()); +diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp +index 0d2e0443f..0579d2596 100644 +--- a/src/makernote_int.cpp ++++ b/src/makernote_int.cpp +@@ -18,6 +18,7 @@ + #include <array> + #include <iostream> + ++#ifdef EXV_ENABLE_FILESYSTEM + #if __has_include(<filesystem>) + #include <filesystem> + namespace fs = std::filesystem; +@@ -25,6 +26,7 @@ namespace fs = std::filesystem; + #include <experimental/filesystem> + namespace fs = std::experimental::filesystem; + #endif ++#endif + + #if !defined(_WIN32) + #include <pwd.h> +@@ -62,6 +64,7 @@ namespace Exiv2::Internal { + // If not found in cwd, we return the default path + // which is the user profile path on win and the home dir on linux + std::string getExiv2ConfigPath() { ++#ifdef EXV_ENABLE_FILESYSTEM + #ifdef _WIN32 + std::string inifile("exiv2.ini"); + #else +@@ -83,13 +86,16 @@ std::string getExiv2ConfigPath() { + currentPath = std::string(pw ? pw->pw_dir : ""); + #endif + return (currentPath / inifile).string(); ++#else ++ return ""; ++#endif + } + + std::string readExiv2Config([[maybe_unused]] const std::string& section, [[maybe_unused]] const std::string& value, + const std::string& def) { + std::string result = def; + +-#ifdef EXV_ENABLE_INIH ++#if defined(EXV_ENABLE_INIH) && defined(EXV_ENABLE_FILESYSTEM) + INIReader reader(Exiv2::Internal::getExiv2ConfigPath()); + if (reader.ParseError() == 0) { + result = reader.Get(section, value, def); +diff --git a/src/preview.cpp b/src/preview.cpp +index 18fe6122b..993c3b749 100644 +--- a/src/preview.cpp ++++ b/src/preview.cpp +@@ -966,12 +966,14 @@ PreviewImage& PreviewImage::operator=(const PreviewImage& rhs) { + return *this; + } + ++#ifdef EXV_ENABLE_FILESYSTEM + size_t PreviewImage::writeFile(const std::string& path) const { + std::string name = path + extension(); + // Todo: Creating a DataBuf here unnecessarily copies the memory + DataBuf buf(pData(), size()); + return Exiv2::writeFile(buf, name); + } ++#endif + + DataBuf PreviewImage::copy() const { + return {pData(), size()}; +diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp +index 33967b427..95ce450c7 100644 +--- a/src/tiffcomposite_int.cpp ++++ b/src/tiffcomposite_int.cpp +@@ -1095,7 +1095,7 @@ size_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_ + } + DataBuf buf = cryptFct(tag(), mio.mmap(), mio.size(), pRoot_); + if (!buf.empty()) { +- mio.seek(0, Exiv2::FileIo::beg); ++ mio.seek(0, Exiv2::BasicIo::beg); + mio.write(buf.c_data(), buf.size()); + } + } +-- +2.39.3 (Apple Git-146) + diff --git a/tools/depends/target/exiv2/0002-Set-conditional-HTTP-depending-on-EXIV2_ENABLE_WEBRE.patch b/tools/depends/target/exiv2/0002-Set-conditional-HTTP-depending-on-EXIV2_ENABLE_WEBRE.patch new file mode 100644 index 0000000000..46cbb7079f --- /dev/null +++ b/tools/depends/target/exiv2/0002-Set-conditional-HTTP-depending-on-EXIV2_ENABLE_WEBRE.patch @@ -0,0 +1,169 @@ +From 0a626d3e54d5db1193e42b505db5cac9e65967af Mon Sep 17 00:00:00 2001 +From: Miguel Borges de Freitas <92enen@gmail.com> +Date: Fri, 24 Nov 2023 11:56:11 +0000 +Subject: [PATCH 2/2] Set conditional HTTP depending on EXIV2_ENABLE_WEBREADY + +--- + include/exiv2/exiv2.hpp | 2 ++ + include/meson.build | 5 ++++- + meson.build | 8 +++++++- + meson_options.txt | 5 +++++ + src/CMakeLists.txt | 6 ++++-- + src/basicio.cpp | 2 ++ + src/image.cpp | 4 +++- + 7 files changed, 27 insertions(+), 5 deletions(-) + +diff --git a/include/exiv2/exiv2.hpp b/include/exiv2/exiv2.hpp +index bae5614d2..35bdb1ab9 100644 +--- a/include/exiv2/exiv2.hpp ++++ b/include/exiv2/exiv2.hpp +@@ -19,7 +19,9 @@ + #include "exiv2/exif.hpp" + #include "exiv2/futils.hpp" + #include "exiv2/gifimage.hpp" ++#ifdef EXV_ENABLE_WEBREADY + #include "exiv2/http.hpp" ++#endif + #include "exiv2/image.hpp" + #include "exiv2/iptc.hpp" + #include "exiv2/jp2image.hpp" +diff --git a/include/meson.build b/include/meson.build +index 7bbb3800f..abcb4a4d6 100644 +--- a/include/meson.build ++++ b/include/meson.build +@@ -14,7 +14,6 @@ headers = files( + 'exiv2/exiv2.hpp', + 'exiv2/futils.hpp', + 'exiv2/gifimage.hpp', +- 'exiv2/http.hpp', + 'exiv2/image.hpp', + 'exiv2/image_types.hpp', + 'exiv2/iptc.hpp', +@@ -47,6 +46,10 @@ if get_option('video') + headers += files('exiv2/asfvideo.hpp', 'exiv2/matroskavideo.hpp', 'exiv2/quicktimevideo.hpp', 'exiv2/riffvideo.hpp') + endif + ++if get_option('webready') ++ headers += files('exiv2/http.hpp') ++endif ++ + if zlib_dep.found() + headers += files('exiv2/pngimage.hpp') + endif +diff --git a/meson.build b/meson.build +index 1b141d5cf..b69fada34 100644 +--- a/meson.build ++++ b/meson.build +@@ -67,7 +67,12 @@ if brotli_dep.found() + deps += brotli_dep + endif + +-curl_dep = dependency('libcurl', disabler: true, required: get_option('curl')) ++if get_option('webready') ++ curl_dep = dependency('libcurl', disabler: true, required: get_option('curl')) ++else ++ curl_dep = dependency('', disabler: true, required: false) ++endif ++ + if curl_dep.found() + deps += curl_dep + endif +@@ -113,6 +118,7 @@ cdata.set('EXV_HAVE_XMP_TOOLKIT', expat_dep.found()) + cdata.set('EXV_HAVE_BROTLI', brotli_dep.found()) + cdata.set('EXV_HAVE_ICONV', iconv_dep.found()) + cdata.set('EXV_HAVE_LIBZ', zlib_dep.found()) ++cdata.set('EXV_ENABLE_WEBREADY', get_option('webready')) + cdata.set('EXV_USE_CURL', curl_dep.found()) + cdata.set('EXV_ENABLE_NLS', intl_dep.found()) + cdata.set('EXV_ENABLE_WEBREADY', curl_dep.found()) +diff --git a/meson_options.txt b/meson_options.txt +index f80430a70..ca03706ea 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -44,3 +44,8 @@ option('xmp', type : 'feature', + option('unitTests', type : 'feature', + description : 'Build and run unit tests', + ) ++ ++option('webready', type : 'boolean', ++ value: true, ++ description : 'Build with support for webready', ++) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index f1b27b861..348a0bfb1 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -48,7 +48,6 @@ set(PUBLIC_HEADERS + ../include/exiv2/exiv2.hpp + ../include/exiv2/futils.hpp + ../include/exiv2/gifimage.hpp +- ../include/exiv2/http.hpp + ../include/exiv2/image.hpp + ../include/exiv2/image_types.hpp + ../include/exiv2/iptc.hpp +@@ -92,7 +91,6 @@ add_library( exiv2lib + futils.cpp + fff.h + gifimage.cpp +- http.cpp + image.cpp + iptc.cpp + jp2image.cpp +@@ -129,6 +127,10 @@ generate_export_header(exiv2lib + + # Conditional addition of sources to library targets + # --------------------------------------------------------- ++if(EXIV2_ENABLE_WEBREADY) ++ set(PUBLIC_HEADERS ${PUBLIC_HEADERS} ../include/exiv2/http.hpp) ++ target_sources(exiv2lib PRIVATE http.cpp ../include/exiv2/http.hpp) ++endif() + + if( EXIV2_ENABLE_PNG ) + set(PUBLIC_HEADERS ${PUBLIC_HEADERS} ../include/exiv2/pngimage.hpp) +diff --git a/src/basicio.cpp b/src/basicio.cpp +index 36509b16b..5f3a9abb3 100644 +--- a/src/basicio.cpp ++++ b/src/basicio.cpp +@@ -1386,6 +1386,7 @@ void RemoteIo::populateFakeData() { + } + } + ++#ifdef EXV_ENABLE_WEBREADY + //! Internal Pimpl structure of class HttpIo. + class HttpIo::HttpImpl : public Impl { + public: +@@ -1525,6 +1526,7 @@ void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, size_t from, s + HttpIo::HttpIo(const std::string& url, size_t blockSize) { + p_ = std::make_unique<HttpImpl>(url, blockSize); + } ++#endif + + #ifdef EXV_USE_CURL + //! Internal Pimpl structure of class RemoteIo. +diff --git a/src/image.cpp b/src/image.cpp +index 9bbe1f272..e65ec7464 100644 +--- a/src/image.cpp ++++ b/src/image.cpp +@@ -777,7 +777,7 @@ ImageType ImageFactory::getType(BasicIo& io) { + } + + BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, bool useCurl) { +- Protocol fProt = fileProtocol(path); ++ [[maybe_unused]] Protocol fProt = fileProtocol(path); + + #ifdef EXV_USE_CURL + if (useCurl && (fProt == pHttp || fProt == pHttps || fProt == pFtp)) { +@@ -785,8 +785,10 @@ BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, bool useCurl) + } + #endif + ++#ifdef EXV_ENABLE_WEBREADY + if (fProt == pHttp) + return std::make_unique<HttpIo>(path); // may throw ++#endif + #ifdef EXV_ENABLE_FILESYSTEM + if (fProt == pFileUri) + return std::make_unique<FileIo>(pathOfFileUrl(path)); +-- +2.39.3 (Apple Git-146) + diff --git a/tools/depends/target/exiv2/0003-UWP-Disable-getLoadedLibraries.patch b/tools/depends/target/exiv2/0003-UWP-Disable-getLoadedLibraries.patch new file mode 100644 index 0000000000..41047f7056 --- /dev/null +++ b/tools/depends/target/exiv2/0003-UWP-Disable-getLoadedLibraries.patch @@ -0,0 +1,45 @@ +From 8affb24ed2c704462cf49f8069954acdfe1f8f79 Mon Sep 17 00:00:00 2001 +From: Miguel Borges de Freitas <92enen@gmail.com> +Date: Mon, 17 Jun 2024 13:29:29 +0100 +Subject: [PATCH] [UWP] Disable getLoadedLibraries + +--- + src/version.cpp | 21 ++++++++++++--------- + 1 file changed, 12 insertions(+), 9 deletions(-) + +diff --git a/src/version.cpp b/src/version.cpp +index 7e8c0b98a..8dcc11ece 100644 +--- a/src/version.cpp ++++ b/src/version.cpp +@@ -122,16 +122,19 @@ static std::vector<std::string> getLoadedLibraries() { + std::string path; + + #if defined(_WIN32) || defined(__CYGWIN__) +- // enumerate loaded libraries and determine path to executable +- HMODULE handles[200]; +- DWORD cbNeeded; +- if (EnumProcessModules(GetCurrentProcess(), handles, static_cast<DWORD>(std::size(handles)), &cbNeeded)) { +- char szFilename[_MAX_PATH]; +- for (DWORD h = 0; h < cbNeeded / sizeof(handles[0]); h++) { +- GetModuleFileNameA(handles[h], szFilename, static_cast<DWORD>(std::size(szFilename))); +- pushPath(szFilename, libs, paths); +- } ++ #include <winapifamily.h> ++ #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_APP) ++ // enumerate loaded libraries and determine path to executable ++ HMODULE handles[200]; ++ DWORD cbNeeded; ++ if (EnumProcessModules(GetCurrentProcess(), handles, static_cast<DWORD>(std::size(handles)), &cbNeeded)) { ++ char szFilename[_MAX_PATH]; ++ for (DWORD h = 0; h < cbNeeded / sizeof(handles[0]); h++) { ++ GetModuleFileNameA(handles[h], szFilename, static_cast<DWORD>(std::size(szFilename))); ++ pushPath(szFilename, libs, paths); ++ } + } ++ #endif + #elif defined(__APPLE__) + // man 3 dyld + uint32_t count = _dyld_image_count(); +-- +2.39.3 (Apple Git-146) + diff --git a/tools/depends/target/exiv2/EXIV2-VERSION b/tools/depends/target/exiv2/EXIV2-VERSION new file mode 100644 index 0000000000..c07af28a90 --- /dev/null +++ b/tools/depends/target/exiv2/EXIV2-VERSION @@ -0,0 +1,6 @@ +LIBNAME=exiv2 +VERSION=0.28.2 +ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz +SHA512=197cc607c0271b5731714713283756250031cef81ba7ed5d9c3e222b4c2397966cc2bbdbceaae706598329dde6f8a9729597d0ae4c36ac264c76546942e4e37b +BYPRODUCT=libexiv2.a +BYPRODUCT_WIN=exiv2.lib diff --git a/tools/depends/target/exiv2/Makefile b/tools/depends/target/exiv2/Makefile new file mode 100644 index 0000000000..b26a4459a4 --- /dev/null +++ b/tools/depends/target/exiv2/Makefile @@ -0,0 +1,47 @@ +include ../../Makefile.include EXIV2-VERSION ../../download-files.include +DEPS = ../../Makefile.include Makefile EXIV2-VERSION ../../download-files.include \ + 0001-Add-EXIV2_ENABLE_FILESYSTEM_ACCESS-option.patch \ + 0002-Set-conditional-HTTP-depending-on-EXIV2_ENABLE_WEBRE.patch \ + 0003-UWP-Disable-getLoadedLibraries.patch + +# configuration settings +CMAKE_OPTIONS=-DCMAKE_INSTALL_PREFIX=$(PREFIX) \ + -DBUILD_SHARED_LIBS=OFF \ + -DEXIV2_ENABLE_WEBREADY=OFF \ + -DEXIV2_ENABLE_XMP=OFF \ + -DEXIV2_ENABLE_CURL=OFF \ + -DEXIV2_ENABLE_NLS=OFF \ + -DEXIV2_BUILD_SAMPLES=OFF \ + -DEXIV2_BUILD_UNIT_TESTS=OFF \ + -DEXIV2_ENABLE_VIDEO=OFF \ + -DEXIV2_ENABLE_BMFF=OFF \ + -DEXIV2_ENABLE_BROTLI=OFF \ + -DEXIV2_ENABLE_INIH=OFF \ + -DEXIV2_ENABLE_FILESYSTEM_ACCESS=OFF \ + -DEXIV2_BUILD_EXIV2_COMMAND=OFF + +LIBDYLIB=$(PLATFORM)/build/$(BYPRODUCT) + +all: .installed-$(PLATFORM) + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM); mkdir -p $(PLATFORM)/build + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); patch -p1 -i ../0001-Add-EXIV2_ENABLE_FILESYSTEM_ACCESS-option.patch + cd $(PLATFORM); patch -p1 -i ../0002-Set-conditional-HTTP-depending-on-EXIV2_ENABLE_WEBRE.patch + cd $(PLATFORM); patch -p1 -i ../0003-UWP-Disable-getLoadedLibraries.patch + cd $(PLATFORM)/build; $(CMAKE) $(CMAKE_OPTIONS) .. + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM)/build + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM)/build install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM)/build clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) |