summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml31
-rw-r--r--binding.gyp49
-rwxr-xr-xscripts/deploy_results.sh7
-rwxr-xr-xscripts/install_node.sh4
-rwxr-xr-xscripts/setup_mesa.sh9
-rw-r--r--src/node_file_source.cpp2
-rw-r--r--src/node_file_source.hpp16
-rw-r--r--src/node_log.cpp1
-rw-r--r--src/node_log.hpp7
-rw-r--r--src/thread_object.cpp85
-rw-r--r--src/thread_object.hpp28
-rw-r--r--src/util/async_queue.hpp90
m---------vendor/mbgl13
13 files changed, 176 insertions, 166 deletions
diff --git a/.travis.yml b/.travis.yml
index c2e1ef4933..7edbcad904 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,29 +1,42 @@
-language: cpp
+# to prevent Travis from exporting CXX after matrix env
+language: c
+
+sudo: false
matrix:
include:
- os: linux
compiler: clang
+ env: FLAVOR=linux CXX=clang++-3.5 BUILDTYPE=Release
+ 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: JOBS=8
+ env: FLAVOR=linux CXX=g++-4.9 BUILDTYPE=Release
+ 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:
global:
- - NODE_VERSION: 0.10.35
+ - 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=
before_install:
-- cd ./vendor/mbgl && source ./scripts/local_mason.sh && cd ../../
-- source ./scripts/install_node.sh
- source ./vendor/mbgl/scripts/travis_helper.sh
-- source ./vendor/mbgl/scripts/flags.sh
-- source ./vendor/mbgl/scripts/travis_before_install.sh
-- source ./scripts/setup_mesa.sh
+- pushd ./vendor/mbgl
+- source ./scripts/${TRAVIS_OS_NAME}/install.sh
+- source ./scripts/${TRAVIS_OS_NAME}/setup.sh
+- popd
+- source ./scripts/install_node.sh
install:
- npm install --build-from-source
@@ -39,5 +52,3 @@ after_success:
git:
submodules: true
-
-sudo: required
diff --git a/binding.gyp b/binding.gyp
index a359f72bd7..c138be5522 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -21,32 +21,49 @@
'src/node_map.cpp',
'src/node_request.hpp',
'src/node_request.cpp',
+ 'src/util/async_queue.hpp',
],
- 'variables': {
- 'cflags_cc': [
- '-Wno-unused-parameter',
- ],
- },
-
'conditions': [
- ['OS == "mac"', {
+ ['OS=="mac"', {
'xcode_settings': {
- "CLANG_CXX_LIBRARY": "libc++",
- "CLANG_CXX_LANGUAGE_STANDARD":"c++11",
- "GCC_VERSION": "com.apple.compilers.llvm.clang.1_0",
- 'MACOSX_DEPLOYMENT_TARGET': '10.9',
- 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ],
+ 'CLANG_CXX_LIBRARY': 'libc++',
+ 'CLANG_CXX_LANGUAGE_STANDARD': 'c++14',
+ 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
- }
+ 'GCC_ENABLE_CPP_RTTI': 'YES',
+ 'OTHER_CPLUSPLUSFLAGS': [
+ '-Werror',
+ '-Wall',
+ '-Wextra',
+ '-Wshadow',
+ '-Wno-variadic-macros',
+ '-Wno-error=unused-parameter',
+ '-frtti',
+ '-fexceptions',
+ ],
+ 'GCC_WARN_PEDANTIC': 'YES',
+ 'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE',
+ 'MACOSX_DEPLOYMENT_TARGET': '10.9',
+ },
}, {
'cflags_cc': [
- '-std=c++11',
+ '-std=c++14',
+ '-Werror',
+ '-Wall',
+ '-Wextra',
+ '-Wno-variadic-macros',
+ '-Wno-error=unused-parameter',
+ '-frtti',
'-fexceptions',
- '<@(cflags_cc)',
],
'libraries': [ '<@(glfw3_ldflags)' ],
- }]
+ }],
+ ['OS=="linux"', {
+ 'cflags_cc': [
+ '-Wno-unknown-pragmas', # We are using '#pragma mark', but it is only available on Darwin.
+ ],
+ }],
],
},
diff --git a/scripts/deploy_results.sh b/scripts/deploy_results.sh
index 6a5bbd0fff..adbed4c2d8 100755
--- a/scripts/deploy_results.sh
+++ b/scripts/deploy_results.sh
@@ -4,5 +4,12 @@ set -e
set -o pipefail
if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then
+ # Install and add awscli to PATH for uploading the results
+ mapbox_time "install_awscli" \
+ pip install --user awscli
+ export PATH="`python -m site --user-base`/bin:${PATH}"
+
+ mapbox_time_start "deploy_results"
(cd ./node_modules/mapbox-gl-test-suite/ && ./bin/deploy_results.sh)
+ mapbox_time_finish
fi
diff --git a/scripts/install_node.sh b/scripts/install_node.sh
index dcdab35214..49f81a4aa7 100755
--- a/scripts/install_node.sh
+++ b/scripts/install_node.sh
@@ -3,7 +3,11 @@
set -e
set -o pipefail
+# Mason exists on PATH from sourcing mbgl install script
+mapbox_time "node" \
mason install node $NODE_VERSION
+
export PATH="`mason prefix node $NODE_VERSION`/bin":"$PATH"
+
node --version
npm --version
diff --git a/scripts/setup_mesa.sh b/scripts/setup_mesa.sh
deleted file mode 100755
index 74baffba06..0000000000
--- a/scripts/setup_mesa.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-set -o pipefail
-
-if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
- export LD_LIBRARY_PATH=`mason prefix mesa 10.4.3`/lib:$LD_LIBRARY_PATH;
- glxinfo;
-fi
diff --git a/src/node_file_source.cpp b/src/node_file_source.cpp
index 936dcf7163..2406264fcc 100644
--- a/src/node_file_source.cpp
+++ b/src/node_file_source.cpp
@@ -1,8 +1,8 @@
#include "node_file_source.hpp"
#include "node_request.hpp"
+#include "util/async_queue.hpp"
#include <mbgl/storage/request.hpp>
-#include <mbgl/util/async_queue.hpp>
namespace node_mbgl {
diff --git a/src/node_file_source.hpp b/src/node_file_source.hpp
index 4e2f967d67..4221f9875f 100644
--- a/src/node_file_source.hpp
+++ b/src/node_file_source.hpp
@@ -7,10 +7,10 @@
#include <map>
-namespace mbgl { namespace util { template <typename T> class AsyncQueue; } }
-
namespace node_mbgl {
+namespace util { template <typename T> class AsyncQueue; }
+
class NodeFileSource : public node::ObjectWrap, public mbgl::FileSource {
////////////////////////////////////////////////////////////////////////////////////////////////
// Static Node Methods
@@ -27,22 +27,22 @@ public:
~NodeFileSource();
mbgl::Request* request(const mbgl::Resource&, uv_loop_t*, Callback);
- void cancel(mbgl::Request *request);
+ void cancel(mbgl::Request*);
void request(const mbgl::Resource&, Callback);
// visiblity?
- void notify(mbgl::Request *request, const std::shared_ptr<const mbgl::Response> &response);
+ void notify(mbgl::Request*, const std::shared_ptr<const mbgl::Response>&);
private:
struct Action;
- using Queue = mbgl::util::AsyncQueue<Action>;
+ using Queue = util::AsyncQueue<Action>;
- void processAdd(mbgl::Request *request);
- void processCancel(mbgl::Request *request);
+ void processAdd(mbgl::Request*);
+ void processCancel(mbgl::Request*);
private:
- std::map<mbgl::Request *, v8::Persistent<v8::Object>> pending;
+ std::map<mbgl::Request*, v8::Persistent<v8::Object>> pending;
Queue *queue = nullptr;
};
diff --git a/src/node_log.cpp b/src/node_log.cpp
index 793a07664c..f10d52d443 100644
--- a/src/node_log.cpp
+++ b/src/node_log.cpp
@@ -1,4 +1,5 @@
#include "node_log.hpp"
+#include "util/async_queue.hpp"
#include <mbgl/map/environment.hpp>
diff --git a/src/node_log.hpp b/src/node_log.hpp
index 9cbd880942..c9a8ef3601 100644
--- a/src/node_log.hpp
+++ b/src/node_log.hpp
@@ -1,15 +1,14 @@
#pragma once
#include <mbgl/platform/log.hpp>
-#include <mbgl/util/async_queue.hpp>
#include <node.h>
#include <nan.h>
-namespace mbgl { namespace util { template <typename T> class AsyncQueue; } }
-
namespace node_mbgl {
+namespace util { template <typename T> class AsyncQueue; }
+
class NodeLogObserver : public mbgl::Log::Observer {
public:
NodeLogObserver(v8::Handle<v8::Object> target);
@@ -22,7 +21,7 @@ private:
v8::Persistent<v8::Object> module;
struct LogMessage;
- using Queue = mbgl::util::AsyncQueue<LogMessage>;
+ using Queue = util::AsyncQueue<LogMessage>;
Queue *queue = nullptr;
};
diff --git a/src/thread_object.cpp b/src/thread_object.cpp
deleted file mode 100644
index ea2e83130d..0000000000
--- a/src/thread_object.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "thread_object.hpp"
-#include "node_file_source.hpp"
-
-
- #include <unistd.h>
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-// Static Node Methods
-
-v8::Persistent<v8::FunctionTemplate> ThreadObject::constructorTemplate;
-
-void ThreadObject::Init(v8::Handle<v8::Object> target) {
- NanScope();
-
- v8::Local<v8::FunctionTemplate> t = NanNew<v8::FunctionTemplate>(New);
-
- t->InstanceTemplate()->SetInternalFieldCount(1);
- t->SetClassName(NanNew("ThreadObject"));
-
- NanAssignPersistent(constructorTemplate, t);
-
- target->Set(NanNew("ThreadObject"), t->GetFunction());
-}
-
-NAN_METHOD(ThreadObject::New) {
- NanScope();
-
- if (!args.IsConstructCall()) {
- return NanThrowTypeError("Use the new operator to create new ThreadObject objects");
- }
-
- if (args.Length() < 1 || !NanHasInstance(NodeFileSource::constructorTemplate, args[0])) {
- return NanThrowTypeError("Requires a FileSource as first argument");
- }
-
- auto fs = ObjectWrap::Unwrap<NodeFileSource>(args[0]->ToObject());
- auto to = new ThreadObject(fs);
- to->Wrap(args.This());
-
- NanReturnValue(args.This());
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-// Instance
-
-ThreadObject::ThreadObject(NodeFileSource *fs) {
- self = v8::Persistent<v8::Object>::New(handle_);
-
- auto async = new uv_async_t;
- async->data = this;
- uv_async_init(uv_default_loop(), async, [](uv_async_t *as, int) {
- NanScope();
- auto to = reinterpret_cast<ThreadObject *>(as->data);
-
- to->self.Dispose();
-
- uv_close((uv_handle_t *)as, [](uv_handle_t *handle) {
- delete reinterpret_cast<uv_async_t *>(handle);
- });
- });
-
- thread = std::thread([this, fs, async]() {
- auto loop = uv_loop_new();
-
- fs->request({ mbgl::Resource::Image, "http://example.com" }, loop, [&](const mbgl::Response &res) {
- fprintf(stderr, "response.status: %d\n", res.status);
- fprintf(stderr, "response.etag: %s\n", res.etag.c_str());
- fprintf(stderr, "response.modified: %lld\n", res.modified);
- fprintf(stderr, "response.expires: %lld\n", res.expires);
- fprintf(stderr, "response.data.size: %ld\n", res.data.size());
- fprintf(stderr, "response.message: %s\n", res.message.c_str());
- });
-
- uv_run(loop, UV_RUN_DEFAULT);
-
- uv_loop_delete(loop);
-
- // Notify that the loop has finished executing.
- uv_async_send(async);
- });
-}
-
-ThreadObject::~ThreadObject() {
- thread.join();
-}
diff --git a/src/thread_object.hpp b/src/thread_object.hpp
deleted file mode 100644
index 3fbdb0400e..0000000000
--- a/src/thread_object.hpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#pragma once
-
-#include <node.h>
-#include <nan.h>
-
-#include <thread>
-
-class NodeFileSource;
-
-class ThreadObject : public node::ObjectWrap {
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Static Node Methods
-public:
- static void Init(v8::Handle<v8::Object> target);
- static NAN_METHOD(New);
-
- static v8::Persistent<v8::FunctionTemplate> constructorTemplate;
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Instance
-private:
- ThreadObject(NodeFileSource *fs);
- ~ThreadObject();
-
-private:
- std::thread thread;
- v8::Persistent<v8::Object> self;
-};
diff --git a/src/util/async_queue.hpp b/src/util/async_queue.hpp
new file mode 100644
index 0000000000..81319da8c7
--- /dev/null
+++ b/src/util/async_queue.hpp
@@ -0,0 +1,90 @@
+#pragma once
+
+#include <uv.h>
+
+#include <thread>
+#include <mutex>
+#include <functional>
+#include <queue>
+#include <string>
+
+
+#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
+#define UV_ASYNC_PARAMS(handle) uv_async_t *handle, int
+#else
+#define UV_ASYNC_PARAMS(handle) uv_async_t *handle
+#endif
+
+namespace node_mbgl {
+namespace util {
+
+template <typename T>
+class AsyncQueue {
+public:
+ AsyncQueue(uv_loop_t *loop, std::function<void(T &)> fn) :
+ callback(fn) {
+ async.data = this;
+ uv_async_init(loop, &async, [](UV_ASYNC_PARAMS(handle)) {
+ auto q = reinterpret_cast<AsyncQueue *>(handle->data);
+ q->process();
+ });
+ }
+
+ void send(T &&data) {
+ {
+ std::lock_guard<std::mutex> lock(mutex);
+ queue.push(std::make_unique<T>(std::move(data)));
+ }
+ uv_async_send(&async);
+ }
+
+ void send(std::unique_ptr<T> data) {
+ {
+ std::lock_guard<std::mutex> lock(mutex);
+ queue.push(std::move(data));
+ }
+ uv_async_send(&async);
+ }
+
+ void stop() {
+ uv_close((uv_handle_t *)&async, [](uv_handle_t *handle) {
+ delete reinterpret_cast<AsyncQueue *>(handle->data);
+ });
+ }
+
+ void ref() {
+ uv_ref((uv_handle_t *)&async);
+ }
+
+ void unref() {
+ uv_unref((uv_handle_t *)&async);
+ }
+
+private:
+ ~AsyncQueue() {
+ }
+
+ void process() {
+ std::unique_ptr<T> item;
+ while (true) {
+ mutex.lock();
+ if (queue.empty()) {
+ mutex.unlock();
+ break;
+ }
+ item = std::move(queue.front());
+ queue.pop();
+ mutex.unlock();
+ callback(*item);
+ }
+ }
+
+private:
+ std::mutex mutex;
+ uv_async_t async;
+ std::queue<std::unique_ptr<T>> queue;
+ std::function<void(T &)> callback;
+};
+
+}
+}
diff --git a/vendor/mbgl b/vendor/mbgl
-Subproject 97fe50f35dbaa653fce44aa2918ba20b65c6b70
+Subproject 4c89323f6d669d9d5f93469e677477b125242a5