diff --git a/README.md b/README.md index bfb754c..db566b9 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ are welcome. ## Compatibility -Tested on 2.4.x, 2.5.x and 2.6.x with Exiv2 0.27.1 +Tested on 2.6.x, 2.7.x, 3.0.x, 3.1.x and 3.2.x with Exiv2 0.27.1 and 0.28.0. ## Developing diff --git a/ext/exiv2/exiv2.cpp b/ext/exiv2/exiv2.cpp index 36a852f..a42332d 100644 --- a/ext/exiv2/exiv2.cpp +++ b/ext/exiv2/exiv2.cpp @@ -1,7 +1,20 @@ -#include "exiv2/image.hpp" -#include "exiv2/error.hpp" +#include "exiv2/exiv2.hpp" #include "ruby.h" +#if EXIV2_MAJOR_VERSION == 0 && EXIV2_MINOR_VERSION <= 27 +#define ExivImagePtr Exiv2::Image::AutoPtr +#define ExivValuePtr Exiv2::Value::AutoPtr +#else +#define ExivImagePtr Exiv2::Image::UniquePtr +#define ExivValuePtr Exiv2::Value::UniquePtr +#endif + +#if EXIV2_MAJOR_VERSION == 0 && EXIV2_MINOR_VERSION <= 27 +#define ExivError Exiv2::BasicError +#else +#define ExivError Exiv2::Error +#endif + // Create a Ruby string from a C++ std::string. static VALUE to_ruby_string(const std::string& string) { VALUE str = rb_str_new(string.data(), string.length()); @@ -121,7 +134,7 @@ static VALUE image_read_metadata(VALUE self) { try { image->readMetadata(); } - catch (Exiv2::BasicError error) { + catch (ExivError error) { rb_raise(basic_error_class, "%s", error.what()); } @@ -135,7 +148,7 @@ static VALUE image_write_metadata(VALUE self) { try { image->writeMetadata(); } - catch (Exiv2::BasicError error) { + catch (ExivError error) { rb_raise(basic_error_class, "%s", error.what()); } @@ -178,10 +191,10 @@ static VALUE image_factory_open(VALUE klass, VALUE path) { Exiv2::Image* image; try { - Exiv2::Image::AutoPtr image_auto_ptr = Exiv2::ImageFactory::open(to_std_string(path)); - image = image_auto_ptr.release(); // Release the AutoPtr, so we can keep the image around. + ExivImagePtr image_ptr = Exiv2::ImageFactory::open(to_std_string(path)); + image = image_ptr.release(); // Release the pointer, so we can keep the image around. } - catch (Exiv2::BasicError error) { + catch (ExivError error) { rb_raise(basic_error_class, "%s", error.what()); } @@ -207,7 +220,7 @@ static VALUE exif_data_add(VALUE self, VALUE key, VALUE value) { Exiv2::TypeId typeId = exifKey.defaultTypeId(); #endif - Exiv2::Value::AutoPtr v = Exiv2::Value::create(typeId); + ExivValuePtr v = Exiv2::Value::create(typeId); v->read(to_std_string(value)); data->add(exifKey, v.get()); @@ -240,7 +253,7 @@ static VALUE iptc_data_add(VALUE self, VALUE key, VALUE value) { Exiv2::IptcKey iptcKey = Exiv2::IptcKey(to_std_string(key)); Exiv2::TypeId typeId = Exiv2::IptcDataSets::dataSetType(iptcKey.tag(), iptcKey.record()); - Exiv2::Value::AutoPtr v = Exiv2::Value::create(typeId); + ExivValuePtr v = Exiv2::Value::create(typeId); v->read(to_std_string(value)); if(data->add(iptcKey, v.get())) { @@ -274,7 +287,7 @@ static VALUE xmp_data_add(VALUE self, VALUE key, VALUE value) { Exiv2::XmpKey xmpKey = Exiv2::XmpKey(to_std_string(key)); Exiv2::TypeId typeId = Exiv2::XmpProperties::propertyType(xmpKey); - Exiv2::Value::AutoPtr v = Exiv2::Value::create(typeId); + ExivValuePtr v = Exiv2::Value::create(typeId); v->read(to_std_string(value)); if(data->add(xmpKey, v.get())) { diff --git a/ext/exiv2/extconf.rb b/ext/exiv2/extconf.rb index d37cb67..ad94b9f 100644 --- a/ext/exiv2/extconf.rb +++ b/ext/exiv2/extconf.rb @@ -1,12 +1,29 @@ require 'mkmf' -RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC'] -RbConfig::MAKEFILE_CONFIG['CCFLAGS'] = ENV['CCFLAGS'] if ENV['CCFLAGS'] -RbConfig::MAKEFILE_CONFIG['CXX'] = ENV['CXX'] if ENV['CXX'] -RbConfig::MAKEFILE_CONFIG['CXXFLAGS'] = ENV['CXXFLAGS'] if ENV['CXXFLAGS'] +$CXXFLAGS += " -std=c++11" +RbConfig::CONFIG['PKG_CONFIG'] = 'pkg-config' if dir_config("exiv2") == [nil, nil] pkg_config("exiv2") end have_library("exiv2") + +# Some extensions are optional in versions <= 0.27 and also don't exist in +# versions >= 0.28. +# Check if they're enabled in the existing exiv2 headers +# configuration and include the relevant libraries. +if have_macro("EXV_USE_SSH", "exiv2/exv_conf.h") + if dir_config("libssh") == [nil, nil] + pkg_config("libssh") + end + have_library("libssh") +end + +if have_macro("EXV_USE_CURL", "exiv2/exv_conf.h") + if dir_config("libcurl") == [nil, nil] + pkg_config("libcurl") + end + have_library("libcurl") +end + create_makefile("exiv2/exiv2") diff --git a/lib/exiv2/version.rb b/lib/exiv2/version.rb index 2603c75..63fefc3 100644 --- a/lib/exiv2/version.rb +++ b/lib/exiv2/version.rb @@ -1,4 +1,4 @@ # coding: utf-8 module Exiv2 - VERSION = "0.1.1" + VERSION = "0.1.2" end