diff --git a/gyp/mbgl-ios.gypi b/gyp/mbgl-ios.gypi index df6896e1e..da05619a3 100644 --- a/gyp/mbgl-ios.gypi +++ b/gyp/mbgl-ios.gypi @@ -40,9 +40,11 @@ '../platform/darwin/string_nsstring.mm', '../platform/darwin/http_request_baton_cocoa.mm', '../platform/darwin/image.mm', + '../platform/default/file_request_libuv.cpp', ], 'include_dirs': [ '../include', + '../src', ], 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(uv_cflags)' ], diff --git a/gyp/mbgl-linux.gypi b/gyp/mbgl-linux.gypi index fdea368ae..51df45ecc 100644 --- a/gyp/mbgl-linux.gypi +++ b/gyp/mbgl-linux.gypi @@ -34,6 +34,7 @@ '../platform/default/shader_cache_tmp.cpp', '../platform/default/log_stderr.cpp', '../platform/default/string_stdlib.cpp', + '../platform/default/file_request_libuv.cpp', '../platform/default/http_request_baton_curl.cpp', '../platform/default/image.cpp', '../platform/default/image_reader.cpp', @@ -42,6 +43,7 @@ ], 'include_dirs': [ '../include', + '../src', ], 'link_settings': { 'libraries': [ diff --git a/gyp/mbgl-osx.gypi b/gyp/mbgl-osx.gypi index 4e8a131da..cc6db2eb2 100644 --- a/gyp/mbgl-osx.gypi +++ b/gyp/mbgl-osx.gypi @@ -15,9 +15,11 @@ '../platform/darwin/string_nsstring.mm', '../platform/darwin/http_request_baton_cocoa.mm', '../platform/darwin/image.mm', + '../platform/default/file_request_libuv.cpp', ], 'include_dirs': [ '../include', + '../src', ], 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(uv_cflags)' ], diff --git a/gyp/styles.gypi b/gyp/styles.gypi index 02cdea6e0..e1cd344fe 100644 --- a/gyp/styles.gypi +++ b/gyp/styles.gypi @@ -18,9 +18,17 @@ 'type': 'none', 'hard_dependency': 1, 'dependencies': [ 'touch_styles' ], # required for xcode http://openradar.appspot.com/7232149 - 'direct_dependent_settings': { - 'mac_bundle_resources': [ '../styles/styles' ], - } + 'conditions': [ + ['OS == "mac"', { + 'direct_dependent_settings': { + 'mac_bundle_resources': [ '../styles/styles' ], + } + }, { + 'direct_dependent_settings': { + 'copies': [{ 'files': [ '../styles/styles' ], 'destination': '<(PRODUCT_DIR)' }], + } + }] + ], } ] } diff --git a/src/mbgl/storage/file_request.hpp b/include/mbgl/storage/file_request.hpp similarity index 98% rename from src/mbgl/storage/file_request.hpp rename to include/mbgl/storage/file_request.hpp index 2f883728f..3de2d5b60 100644 --- a/src/mbgl/storage/file_request.hpp +++ b/include/mbgl/storage/file_request.hpp @@ -24,4 +24,4 @@ private: } -#endif \ No newline at end of file +#endif diff --git a/linux/main.cpp b/linux/main.cpp index 42a98d019..c5b2569ba 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) { // Load style if (style.empty()) - style = std::string("file://") + uv::cwd() + std::string("/../../styles/styles/bright-v6.json"); + style = std::string("file://") + uv::cwd() + std::string("/styles/bright-v6.json"); map.setStyleURL(style); diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index fbeabd74e..4127b5c27 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -48,6 +48,7 @@ 'dependencies': [ '../mapboxgl.gyp:mbgl-standalone', '../mapboxgl.gyp:mbgl-linux', + '../mapboxgl.gyp:bundle_styles', '../mapboxgl.gyp:copy_certificate_bundle', ], 'copies': [{ diff --git a/src/mbgl/storage/file_request_baton.cpp b/platform/default/file_request_libuv.cpp similarity index 80% rename from src/mbgl/storage/file_request_baton.cpp rename to platform/default/file_request_libuv.cpp index 0a9c5f6f5..f874bed8d 100644 --- a/src/mbgl/storage/file_request_baton.cpp +++ b/platform/default/file_request_libuv.cpp @@ -1,12 +1,34 @@ -#include #include #include #include +#include + #include namespace mbgl { +struct FileRequestBaton { + FileRequestBaton(FileRequest *request_, const std::string &path, uv_loop_t *loop); + ~FileRequestBaton(); + + void cancel(); + static void file_opened(uv_fs_t *req); + static void file_stated(uv_fs_t *req); + static void file_read(uv_fs_t *req); + static void file_closed(uv_fs_t *req); + static void notify_error(uv_fs_t *req); + static void cleanup(uv_fs_t *req); + + const std::thread::id thread_id; + FileRequest *request = nullptr; + uv_fs_t req; + uv_file fd = -1; + bool canceled = false; + std::string body; + uv_buf_t buffer; +}; + FileRequestBaton::FileRequestBaton(FileRequest *request_, const std::string &path, uv_loop_t *loop) : thread_id(std::this_thread::get_id()), request(request_) { req.data = this; @@ -157,4 +179,31 @@ void FileRequestBaton::cleanup(uv_fs_t *req) { delete ptr; } + +FileRequest::FileRequest(const std::string &path_, uv_loop_t *loop) + : BaseRequest(path_), ptr(new FileRequestBaton(this, path, loop)) { +} + +void FileRequest::cancel() { + assert(thread_id == std::this_thread::get_id()); + + if (ptr) { + ptr->cancel(); + + // When deleting a FileRequest object with a uv_fs_* call is in progress, we are making sure + // that the callback doesn't accidentally reference this object again. + ptr->request = nullptr; + ptr = nullptr; + } + + notify(); +} + +FileRequest::~FileRequest() { + assert(thread_id == std::this_thread::get_id()); + cancel(); + + // Note: The FileRequestBaton object is deleted in FileRequestBaton::cleanup(). +} + } diff --git a/src/mbgl/storage/file_request.cpp b/src/mbgl/storage/file_request.cpp deleted file mode 100644 index 9f74c7b41..000000000 --- a/src/mbgl/storage/file_request.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include - -#include - -#include - -#include - -namespace mbgl { - -FileRequest::FileRequest(const std::string &path_, uv_loop_t *loop) - : BaseRequest(path_), ptr(new FileRequestBaton(this, path, loop)) { -} - -void FileRequest::cancel() { - assert(thread_id == std::this_thread::get_id()); - - if (ptr) { - ptr->cancel(); - - // When deleting a FileRequest object with a uv_fs_* call is in progress, we are making sure - // that the callback doesn't accidentally reference this object again. - ptr->request = nullptr; - ptr = nullptr; - } - - notify(); -} - -FileRequest::~FileRequest() { - assert(thread_id == std::this_thread::get_id()); - cancel(); -} - -} diff --git a/src/mbgl/storage/file_request_baton.hpp b/src/mbgl/storage/file_request_baton.hpp deleted file mode 100644 index 897c88061..000000000 --- a/src/mbgl/storage/file_request_baton.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef MBGL_STORAGE_FILE_REQUEST_BATON -#define MBGL_STORAGE_FILE_REQUEST_BATON - -#include -#include - -#include - -namespace mbgl { - -struct FileRequestBaton { - FileRequestBaton(FileRequest *request_, const std::string &path, uv_loop_t *loop); - ~FileRequestBaton(); - - void cancel(); - static void file_opened(uv_fs_t *req); - static void file_stated(uv_fs_t *req); - static void file_read(uv_fs_t *req); - static void file_closed(uv_fs_t *req); - static void notify_error(uv_fs_t *req); - static void cleanup(uv_fs_t *req); - - const std::thread::id thread_id; - FileRequest *request = nullptr; - uv_fs_t req; - uv_file fd = -1; - bool canceled = false; - std::string body; - uv_buf_t buffer; -}; - - -} - - -#endif