summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Morris <michael.patrick.morris@gmail.com>2015-05-15 12:27:10 -0400
committerMike Morris <michael.patrick.morris@gmail.com>2015-05-15 12:27:10 -0400
commit2d5a73b25b601d876047663832d4a0c71a2a4830 (patch)
treee55e7dd6aefc02e42a9640b840867620dc7dfdea
parent79c73f990bb62114af305df22ec7c780d4cfc123 (diff)
parent2da70779c60ba412a3387f1ba5c9147e68c7d89b (diff)
downloadqtlocation-mapboxgl-2d5a73b25b601d876047663832d4a0c71a2a4830.tar.gz
Merge pull request #88 from mapbox/node-exe
Add support for and test against Node.js v0.12 and io.js v2.0.1
-rw-r--r--.travis.yml65
-rw-r--r--Makefile4
-rw-r--r--binding.gyp1
-rw-r--r--package.json17
-rwxr-xr-xscripts/install_node.sh8
-rw-r--r--src/compress_png.cpp4
-rw-r--r--src/node_file_source.cpp32
-rw-r--r--src/node_file_source.hpp5
-rw-r--r--src/node_log.cpp9
-rw-r--r--src/node_map.cpp8
-rw-r--r--src/node_mapbox_gl_native.cpp3
-rw-r--r--src/node_request.cpp30
-rw-r--r--src/node_request.hpp2
13 files changed, 136 insertions, 52 deletions
diff --git a/.travis.yml b/.travis.yml
index 7edbcad904..8a7f5c345b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,25 +7,82 @@ matrix:
include:
- os: linux
compiler: clang
- env: FLAVOR=linux CXX=clang++-3.5 BUILDTYPE=Release
+ env:
+ - CXX: clang++-3.5
+ - NODE_EXE: "iojs"
+ - NODE_VERSION: 2.0.1
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ]
packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
- os: linux
+ compiler: clang
+ env:
+ - CXX: clang++-3.5
+ - NODE_EXE: "node"
+ - NODE_VERSION: 0.12.0
+ addons:
+ apt:
+ sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ]
+ packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
+ - os: linux
+ compiler: clang
+ env:
+ - CXX: clang++-3.5
+ - NODE_EXE: "node"
+ - NODE_VERSION: 0.10.36
+ addons:
+ apt:
+ sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ]
+ packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
+ - os: linux
+ compiler: gcc
+ env:
+ - CXX: g++-4.9
+ - NODE_EXE: "iojs"
+ - NODE_VERSION: 2.0.1
+ addons:
+ apt:
+ sources: [ 'ubuntu-toolchain-r-test' ]
+ packages: [ 'gdb', 'g++-4.9', 'gcc-4.9', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
+ - os: linux
+ compiler: gcc
+ env:
+ - CXX: g++-4.9
+ - NODE_EXE: "node"
+ - NODE_VERSION: 0.12.0
+ addons:
+ apt:
+ sources: [ 'ubuntu-toolchain-r-test' ]
+ packages: [ 'gdb', 'g++-4.9', 'gcc-4.9', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
+ - os: linux
compiler: gcc
- env: FLAVOR=linux CXX=g++-4.9 BUILDTYPE=Release
+ env:
+ - CXX: g++-4.9
+ - NODE_EXE: "node"
+ - NODE_VERSION: 0.10.36
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test' ]
packages: [ 'gdb', 'g++-4.9', 'gcc-4.9', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
- os: osx
compiler: clang
- env: FLAVOR=osx BUILDTYPE=Release
+ env:
+ - NODE_EXE: "iojs"
+ - NODE_VERSION: 2.0.1
+ - os: osx
+ compiler: clang
+ env:
+ - NODE_EXE: "node"
+ - NODE_VERSION: 0.12.0
+ - os: osx
+ compiler: clang
+ env:
+ - NODE_EXE: "node"
+ - NODE_VERSION: 0.10.36
env:
global:
- - NODE_VERSION: 0.10.36
- LD_LIBRARY_PATH: "/usr/local/lib"
- secure: pz/HAMQpnde//JJi3f+RcW32APN6g3QyFAH41JlZwgsM5Daj9RRoXqUcNg4hEyTvlThtc5t+wQQ2ejYAjMwDu00GAzRFJ03Sm45w2fPvith9fu4crXsyPUvWUfWPC0ajTXzorN4cwFwOoMoeo9DihLwb0EC0n4T6jWdBCae3k+s=
- secure: jYFAOQoMZkZVyc5AFPBKhR9oDqp5CciwCxFhVEHVjdImM+8V60loKazyw+bVLIjzKLnQbKKdiDudWL9TE1ylK/XSlF3K7o4gU2vIh5WzosKnU70Sanxd6tHt/Ui5eK+bAymKHbLdGiXIZtBZE0tML6+wgJ9vhV4ZKna5dM9tps4=
diff --git a/Makefile b/Makefile
index d66f6ad1c3..4884d5a5fd 100644
--- a/Makefile
+++ b/Makefile
@@ -63,11 +63,11 @@ $(MBGL)/config/%.gypi: $(MBGL) $(MBGL)/configure
.PHONY: test-suite
test-suite:
- -@(`npm bin`/tape test/render.test.js | `npm bin`/tap-spec)
+ -@(`npm bin`/tape test/render.test.js | `npm bin`/faucet)
.PHONY: test-js
test-js:
- @(`npm bin`/tape test/js/**/*.test.js | `npm bin`/tap-spec)
+ @(`npm bin`/tape test/js/**/*.test.js | `npm bin`/faucet)
.PHONY: test
test: test-js test-suite
diff --git a/binding.gyp b/binding.gyp
index 1f0f81c1fe..9c7cade1d9 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -52,7 +52,6 @@
'-Werror',
'-Wall',
'-Wextra',
- '-Wshadow',
'-Wno-variadic-macros',
'-Wno-error=unused-parameter',
'-frtti',
diff --git a/package.json b/package.json
index 65e68b6106..e8e2f13fc3 100644
--- a/package.json
+++ b/package.json
@@ -18,20 +18,21 @@
}
],
"dependencies": {
- "nan": "^1.4.1",
- "node-pre-gyp": "^0.6.4"
+ "nan": "^1.8.4",
+ "node-pre-gyp": "^0.6.7"
},
"bundledDependencies": [
"node-pre-gyp"
],
"devDependencies": {
- "aws-sdk": "^2.1.9",
+ "aws-sdk": "^2.1.27",
+ "faucet": "0.0.1",
"mapbox-gl-test-suite": "git://github.com/mapbox/mapbox-gl-test-suite#master",
- "mkdirp": "^0.5.0",
- "request": "^2.53.0",
- "tap-spec": "^2.2.1",
- "tape": "^3.5.0",
- "st": "^0.5.3"
+ "mkdirp": "^0.5.1",
+ "request": "^2.55.0",
+ "st": "^0.5.3",
+ "tap-spec": "^3.0.0",
+ "tape": "^4.0.0"
},
"scripts": {
"install": "node-pre-gyp install || make",
diff --git a/scripts/install_node.sh b/scripts/install_node.sh
index 49f81a4aa7..311b004243 100755
--- a/scripts/install_node.sh
+++ b/scripts/install_node.sh
@@ -4,10 +4,10 @@ set -e
set -o pipefail
# Mason exists on PATH from sourcing mbgl install script
-mapbox_time "node" \
-mason install node $NODE_VERSION
+mapbox_time $NODE_EXE \
+mason install $NODE_EXE $NODE_VERSION
-export PATH="`mason prefix node $NODE_VERSION`/bin":"$PATH"
+export PATH="`mason prefix $NODE_EXE $NODE_VERSION`/bin":"$PATH"
-node --version
+$NODE_EXE --version
npm --version
diff --git a/src/compress_png.cpp b/src/compress_png.cpp
index 068abe65f3..99cec5b1b1 100644
--- a/src/compress_png.cpp
+++ b/src/compress_png.cpp
@@ -8,15 +8,15 @@ public:
CompressPNGWorker(NanCallback *callback_, v8::Local<v8::Object> buffer_, uint32_t width_,
uint32_t height_)
: NanAsyncWorker(callback_),
- buffer(v8::Persistent<v8::Object>::New(buffer_)),
data(node::Buffer::Data(buffer_)),
width(width_),
height(height_) {
+ NanAssignPersistent(buffer, buffer_);
assert(width * height * 4 == node::Buffer::Length(buffer_));
}
~CompressPNGWorker() {
- buffer.Dispose();
+ NanDisposePersistent(buffer);
}
void Execute() {
diff --git a/src/node_file_source.cpp b/src/node_file_source.cpp
index e0b78008b3..866e6d4783 100644
--- a/src/node_file_source.cpp
+++ b/src/node_file_source.cpp
@@ -96,11 +96,18 @@ void NodeFileSource::processAdd(mbgl::Request *req) {
queue->ref();
}
- auto requestHandle = v8::Local<v8::Object>::New(NodeRequest::Create(handle_, req));
- pending.emplace(req, std::move(v8::Persistent<v8::Object>::New(requestHandle)));
+ auto handle = NanObjectWrapHandle(this);
+ auto requestHandle = NanNew<v8::Object>(NodeRequest::Create(handle, req));
+#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION)
+ const v8::UniquePersistent<v8::Object> requestPersistent(v8::Isolate::GetCurrent(), requestHandle);
+#else
+ v8::Persistent<v8::Object> requestPersistent;
+ NanAssignPersistent(requestPersistent, requestHandle);
+#endif
+ pending.emplace(req, std::move(requestPersistent));
v8::Local<v8::Value> argv[] = { requestHandle };
- NanMakeCallback(handle_, NanNew("request"), 1, argv);
+ NanMakeCallback(handle, NanNew("request"), 1, argv);
}
void NodeFileSource::processCancel(mbgl::Request *req) {
@@ -111,10 +118,16 @@ void NodeFileSource::processCancel(mbgl::Request *req) {
// The response callback was already fired. There is no point in calling the cancelation
// callback because the request is already completed.
} else {
- auto requestHandle = v8::Local<v8::Object>::New(it->second);
+#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION)
+ auto requestHandle = v8::Local<v8::Object>::New(v8::Isolate::GetCurrent(), it->second);
+#else
+ auto requestHandle = NanNew<v8::Object>(it->second);
+#endif
// Dispose and remove the persistent handle
- it->second.Dispose();
+#if (NODE_MODULE_VERSION <= NODE_0_10_MODULE_VERSION)
+ NanDisposePersistent(it->second);
+#endif
pending.erase(it);
// Make sure the the loop can exit when there are no pending requests.
@@ -122,9 +135,10 @@ void NodeFileSource::processCancel(mbgl::Request *req) {
queue->unref();
}
- if (handle_->Has(NanNew("cancel"))) {
+ auto handle = NanObjectWrapHandle(this);
+ if (handle->Has(NanNew("cancel"))) {
v8::Local<v8::Value> argv[] = { requestHandle };
- NanMakeCallback(handle_, NanNew("cancel"), 1, argv);
+ NanMakeCallback(handle, NanNew("cancel"), 1, argv);
}
// Set the request handle in the request wrapper handle to null
@@ -139,7 +153,9 @@ void NodeFileSource::notify(mbgl::Request *req, const std::shared_ptr<const mbgl
// First, remove the request, since it might be destructed at any point now.
auto it = pending.find(req);
if (it != pending.end()) {
- it->second.Dispose();
+#if (NODE_MODULE_VERSION <= NODE_0_10_MODULE_VERSION)
+ NanDisposePersistent(it->second);
+#endif
pending.erase(it);
// Make sure the the loop can exit when there are no pending requests.
diff --git a/src/node_file_source.hpp b/src/node_file_source.hpp
index 791b96969c..49ff27e148 100644
--- a/src/node_file_source.hpp
+++ b/src/node_file_source.hpp
@@ -6,6 +6,7 @@
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wshadow"
#include <node.h>
+#include <node_version.h>
#include <nan.h>
#pragma GCC diagnostic pop
@@ -46,7 +47,11 @@ private:
void processCancel(mbgl::Request*);
private:
+#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION)
+ std::map<mbgl::Request*, const v8::UniquePersistent<v8::Object> &> pending;
+#else
std::map<mbgl::Request*, v8::Persistent<v8::Object>> pending;
+#endif
Queue *queue = nullptr;
};
diff --git a/src/node_log.cpp b/src/node_log.cpp
index f10d52d443..d7cf0e0d80 100644
--- a/src/node_log.cpp
+++ b/src/node_log.cpp
@@ -32,7 +32,7 @@ NodeLogObserver::NodeLogObserver(v8::Handle<v8::Object> target)
: queue(new Queue(uv_default_loop(), [this](LogMessage &message) {
NanScope();
- auto msg = v8::Object::New();
+ auto msg = NanNew<v8::Object>();
msg->Set(NanNew("class"), NanNew(mbgl::EventClass(message.event).c_str()));
msg->Set(NanNew("severity"), NanNew(mbgl::EventSeverityClass(message.severity).c_str()));
if (message.code != -1) {
@@ -49,11 +49,12 @@ NodeLogObserver::NodeLogObserver(v8::Handle<v8::Object> target)
}
v8::Local<v8::Value> argv[] = { NanNew("message"), msg };
- auto emit = module->Get(NanNew("emit"))->ToObject();
- emit->CallAsFunction(module, 2, argv);
+ auto handle = NanNew<v8::Object>(module);
+ auto emit = handle->Get(NanNew("emit"))->ToObject();
+ emit->CallAsFunction(handle, 2, argv);
})) {
NanScope();
- module = v8::Persistent<v8::Object>::New(target);
+ NanAssignPersistent(module, target);
// Don't keep the event loop alive.
queue->unref();
diff --git a/src/node_map.cpp b/src/node_map.cpp
index b6aae1302c..e5b3fda5f2 100644
--- a/src/node_map.cpp
+++ b/src/node_map.cpp
@@ -239,7 +239,7 @@ void NodeMap::renderFinished() {
assert(!image);
if (img) {
- v8::Local<v8::Object> result = v8::Object::New();
+ auto result = NanNew<v8::Object>();
result->Set(NanNew("width"), NanNew(img->width));
result->Set(NanNew("height"), NanNew(img->height));
@@ -283,7 +283,11 @@ NodeMap::NodeMap(v8::Handle<v8::Object> source_) :
NanAssignPersistent(source, source_);
async->data = this;
+#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
uv_async_init(uv_default_loop(), async, [](uv_async_t *as, int) {
+#else
+ uv_async_init(uv_default_loop(), async, [](uv_async_t *as) {
+#endif
reinterpret_cast<NodeMap *>(as->data)->renderFinished();
});
@@ -292,7 +296,7 @@ NodeMap::NodeMap(v8::Handle<v8::Object> source_) :
}
NodeMap::~NodeMap() {
- source.Dispose();
+ NanDisposePersistent(source);
uv_close(reinterpret_cast<uv_handle_t *>(async), [] (uv_handle_t *handle) {
delete reinterpret_cast<uv_async_t *>(handle);
diff --git a/src/node_mapbox_gl_native.cpp b/src/node_mapbox_gl_native.cpp
index e784681a00..a7a0f0fcf6 100644
--- a/src/node_mapbox_gl_native.cpp
+++ b/src/node_mapbox_gl_native.cpp
@@ -11,7 +11,6 @@
#include "node_request.hpp"
#include "compress_png.hpp"
-
void RegisterModule(v8::Handle<v8::Object> exports) {
NanScope();
@@ -22,7 +21,7 @@ void RegisterModule(v8::Handle<v8::Object> exports) {
// Exports Resource constants.
auto ConstantProperty = static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
- auto resource = v8::Object::New();
+ auto resource = NanNew<v8::Object>();
resource->ForceSet(NanNew("Unknown"), NanNew(mbgl::Resource::Unknown), ConstantProperty);
resource->ForceSet(NanNew("Tile"), NanNew(mbgl::Resource::Tile), ConstantProperty);
resource->ForceSet(NanNew("Glyphs"), NanNew(mbgl::Resource::Glyphs), ConstantProperty);
diff --git a/src/node_request.cpp b/src/node_request.cpp
index b67fd2097a..0fdc05bff9 100644
--- a/src/node_request.cpp
+++ b/src/node_request.cpp
@@ -35,34 +35,35 @@ NAN_METHOD(NodeRequest::New) {
return NanThrowTypeError("Cannot create Request objects explicitly");
}
- auto source = v8::Persistent<v8::Object>::New(args[0]->ToObject());
+ v8::Persistent<v8::Object> source;
+ NanAssignPersistent(source, args[0]->ToObject());
+
auto request = reinterpret_cast<mbgl::Request *>(args[1].As<v8::External>()->Value());
- auto req = new NodeRequest(source, request);
+ auto req = new NodeRequest(NanNew<v8::Object>(std::move(source)), request);
req->Wrap(args.This());
NanReturnValue(args.This());
}
v8::Handle<v8::Object> NodeRequest::Create(v8::Handle<v8::Object> source, mbgl::Request *request) {
- NanScope();
- v8::Local<v8::Value> argv[] = { v8::Local<v8::Object>::New(source), NanNew<v8::External>(request) };
- auto instance = constructorTemplate->GetFunction()->NewInstance(2, argv);
+ NanEscapableScope();
+
+ v8::Local<v8::Value> argv[] = { NanNew<v8::Object>(source), NanNew<v8::External>(request) };
+ auto instance = NanNew<v8::FunctionTemplate>(constructorTemplate)->GetFunction()->NewInstance(2, argv);
- instance->Set(NanNew("url"), NanNew(request->resource.url), v8::ReadOnly);
- instance->Set(NanNew("kind"), NanNew<v8::Integer>(int(request->resource.kind)), v8::ReadOnly);
+ instance->ForceSet(NanNew("url"), NanNew(request->resource.url), v8::ReadOnly);
+ instance->ForceSet(NanNew("kind"), NanNew<v8::Integer>(int(request->resource.kind)), v8::ReadOnly);
- NanReturnValue(instance);
+ return NanEscapeScope(instance);
}
NAN_METHOD(NodeRequest::Respond) {
- NanScope();
-
auto nodeRequest = ObjectWrap::Unwrap<NodeRequest>(args.Holder());
if (!nodeRequest->request) {
return NanThrowError("Request has already been responded to, or was canceled.");
}
- auto source = ObjectWrap::Unwrap<NodeFileSource>(nodeRequest->source);
+ auto source = ObjectWrap::Unwrap<NodeFileSource>(NanNew<v8::Object>(nodeRequest->source));
auto request = nodeRequest->request;
nodeRequest->request = nullptr;
@@ -131,12 +132,13 @@ NAN_METHOD(NodeRequest::Respond) {
////////////////////////////////////////////////////////////////////////////////////////////////
// Instance
-NodeRequest::NodeRequest(v8::Persistent<v8::Object> source_, mbgl::Request *request_)
- : source(source_), request(request_) {
+NodeRequest::NodeRequest(v8::Local<v8::Object> source_, mbgl::Request *request_)
+ : request(request_) {
+ NanAssignPersistent(source, source_);
}
NodeRequest::~NodeRequest() {
- source.Dispose();
+ NanDisposePersistent(source);
}
void NodeRequest::cancel() {
diff --git a/src/node_request.hpp b/src/node_request.hpp
index ebbd962d47..0098550665 100644
--- a/src/node_request.hpp
+++ b/src/node_request.hpp
@@ -27,7 +27,7 @@ public:
////////////////////////////////////////////////////////////////////////////////////////////////
// Instance
public:
- NodeRequest(v8::Persistent<v8::Object> source, mbgl::Request *request);
+ NodeRequest(v8::Local<v8::Object> source, mbgl::Request *request);
~NodeRequest();
void cancel();