diff --git a/.gitignore b/.gitignore index fb8b673..9c802af 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,16 @@ build/ node_modules/ test/copy.jpg *~ +npm-debug.log +*.swp +.vagrant +Vagrantfile + +*.o +*.lo +*.a +*.la +.vs +.vscode +yarn-error.log +yarn.lock diff --git a/.travis.yml b/.travis.yml index 2fbc55a..05d47f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,12 @@ language: node_js node_js: - - "4" - - "5" - - "6" - - "7" - - "node" - - "iojs" - - "0.12" - - "0.10" + - "8" + - "9" + - "10" + - "11" + - "12" + - "13" + - "14" sudo: false addons: apt: @@ -18,11 +17,3 @@ addons: - libexiv2-dev before_install: - export CXX=g++-4.8 - - case ${TRAVIS_NODE_VERSION} in - iojs*) - echo "Not upgrading npm for iojs." - ;; - *) - npm update -g npm@2.6.1 - ;; - esac diff --git a/README.md b/README.md index cc55a6c..17a7dd9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#Exiv2 +# Exiv2 Exiv2 is a native c++ extension for [io.js](https://iojs.org/en/index.html) and [node.js](https://nodejs.org/) that provides support for reading and writing @@ -11,7 +11,7 @@ a package manager you might need to install an additional "-dev" packages. ### Debian - apt-get install libexiv2 libexiv2-dev + apt-get install zlib1g-dev ### OS X @@ -25,6 +25,20 @@ You'll also need to install pkg-config to help locate the library and headers. brew install pkg-config exiv2 +### Windows +Install pkg-config using [Chocolatey](https://chocolatey.org/): + + choco install pkgconfiglite + +Download latest `msvc64` exiv2 build from the [Exiv2 download page](http://www.exiv2.org/download.html) and extract to a folder of your choice. + +Add a system variable named `PKG_CONFIG_PATH` and set it's value to `EXIV2ROOTDIR\lib\pkgconfig` replacing `EXIV2ROOTDIR` with the path where you extracted exiv2 from the step before (e.g. `D:\src\exiv2msvs\lib\pkgconfig`). + +You'll also need [windows-build-tools](https://www.npmjs.com/package/windows-build-tools) to compile this package. + +For Electron apps, you'll want to copy `exiv2.dll` to the root directory of your Electron Windows build. You can automated this using the [extraFiles option](https://www.electron.build/configuration/contents#extrafiles). + + ### Other systems See the [Exiv2 download page](http://www.exiv2.org/download.html) for more diff --git a/binding.gyp b/binding.gyp index 99be6bf..fd91c1e 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,4 +1,7 @@ { + 'variables': { + 'EXIV2_LIB': ' #include #include -#include +#ifdef _MSC_VER +# include +# include +#else +# include +# include +#endif #include #include #include @@ -88,7 +94,8 @@ class GetTagsWorker : public Exiv2Worker { Local hash = Nan::New(); // Copy the tags out. for (tag_map_t::iterator i = tags.begin(); i != tags.end(); ++i) { - hash->Set( + Nan::Set( + hash, Nan::New(i->first.c_str()).ToLocalChecked(), Nan::New(i->second.c_str()).ToLocalChecked() ); @@ -97,7 +104,7 @@ class GetTagsWorker : public Exiv2Worker { } // Pass the argv array object to our callback function. - callback->Call(2, argv); + Nan::Call(callback->GetFunction(), Nan::GetCurrentContext()->Global(), 2, argv); }; }; @@ -173,7 +180,7 @@ class SetTagsWorker : public Exiv2Worker { } // Pass the argv array object to our callback function. - callback->Call(1, argv); + Nan::Call(callback->GetFunction(), Nan::GetCurrentContext()->Global(), 1, argv); }; }; @@ -192,10 +199,10 @@ NAN_METHOD(SetImageTags) { Local tags = Local::Cast(info[1]); Local keys = Nan::GetOwnPropertyNames(tags).ToLocalChecked(); for (unsigned i = 0; i < keys->Length(); i++) { - Local key = keys->Get(i); + Local key = Nan::Get(keys, i).ToLocalChecked(); worker->tags.insert(std::pair ( *Nan::Utf8String(key), - *Nan::Utf8String(tags->Get(key)) + *Nan::Utf8String(Nan::Get(tags, key).ToLocalChecked()) )); } @@ -267,7 +274,7 @@ class DeleteTagsWorker : public Exiv2Worker { } // Pass the argv array object to our callback function. - callback->Call(1, argv); + Nan::Call(callback->GetFunction(), Nan::GetCurrentContext()->Global(), 1, argv); }; }; @@ -285,7 +292,7 @@ NAN_METHOD(DeleteImageTags) { Local keys = Local::Cast(info[1]); for (unsigned i = 0; i < keys->Length(); i++) { - Local key = keys->Get(i); + Local key = Nan::Get(keys, i).ToLocalChecked(); worker->tags.push_back(*Nan::Utf8String(key)); } @@ -337,18 +344,18 @@ class GetPreviewsWorker : public Exiv2Worker { Local array = Nan::New(previews.size()); for (size_t i = 0; i < previews.size(); ++i) { Local preview = Nan::New(); - preview->Set(Nan::New("mimeType").ToLocalChecked(), Nan::New(previews[i].mimeType.c_str()).ToLocalChecked()); - preview->Set(Nan::New("height").ToLocalChecked(), Nan::New(previews[i].height)); - preview->Set(Nan::New("width").ToLocalChecked(), Nan::New(previews[i].width)); - preview->Set(Nan::New("data").ToLocalChecked(), Nan::CopyBuffer(previews[i].data, previews[i].size).ToLocalChecked()); + Nan::Set(preview, Nan::New("mimeType").ToLocalChecked(), Nan::New(previews[i].mimeType.c_str()).ToLocalChecked()); + Nan::Set(preview, Nan::New("height").ToLocalChecked(), Nan::New(previews[i].height)); + Nan::Set(preview, Nan::New("width").ToLocalChecked(), Nan::New(previews[i].width)); + Nan::Set(preview, Nan::New("data").ToLocalChecked(), Nan::CopyBuffer(previews[i].data, previews[i].size).ToLocalChecked()); - array->Set(i, preview); + Nan::Set(array, i, preview); } argv[1] = array; } // Pass the argv array object to our callback function. - callback->Call(2, argv); + Nan::Call(callback->GetFunction(), Nan::GetCurrentContext()->Global(), 2, argv); }; protected: @@ -397,10 +404,26 @@ NAN_METHOD(GetImagePreviews) { // - - - -void InitAll(Handle target) { - target->Set(Nan::New("getImageTags").ToLocalChecked(), Nan::New(GetImageTags)->GetFunction()); - target->Set(Nan::New("setImageTags").ToLocalChecked(), Nan::New(SetImageTags)->GetFunction()); - target->Set(Nan::New("deleteImageTags").ToLocalChecked(), Nan::New(DeleteImageTags)->GetFunction()); - target->Set(Nan::New("getImagePreviews").ToLocalChecked(), Nan::New(GetImagePreviews)->GetFunction()); +void InitAll(Local target) { + Nan::Set( + target, + Nan::New("getImageTags").ToLocalChecked(), + Nan::GetFunction(Nan::New(GetImageTags)).ToLocalChecked() + ); + Nan::Set( + target, + Nan::New("setImageTags").ToLocalChecked(), + Nan::GetFunction(Nan::New(SetImageTags)).ToLocalChecked() + ); + Nan::Set( + target, + Nan::New("deleteImageTags").ToLocalChecked(), + Nan::GetFunction(Nan::New(DeleteImageTags)).ToLocalChecked() + ); + Nan::Set( + target, + Nan::New("getImagePreviews").ToLocalChecked(), + Nan::GetFunction(Nan::New(GetImagePreviews)).ToLocalChecked() + ); } NODE_MODULE(exiv2, InitAll) diff --git a/package.json b/package.json index 2cd38e0..df2dafd 100644 --- a/package.json +++ b/package.json @@ -13,21 +13,21 @@ "url": "git://github.com/dberesford/exiv2node.git" }, "dependencies": { - "nan": "~2.2" + "nan": "~2.14.0" }, "devDependencies": { - "should": "*", - "mocha": "*" + "mocha": "*", + "should": "*" }, "optionalDependencies": {}, "engines": { - "node": "~0.8.0" + "node": ">=8.0.0" }, "main": "exiv2", "scripts": { - "preuninstall": "rm -rf build/*", "test": "mocha", - "install": "node-gyp rebuild" + "clean": "node-gyp clean", + "build": "node-gyp configure build" }, "gypfile": true, "contributors": [