first attempt at using mason to install packages
[skip ci]
This commit is contained in:
1
Makefile
1
Makefile
@@ -109,3 +109,4 @@ distclean: clean
|
||||
-find ./mapnik-packaging/osx/out/packages -type d ! -name 'packages' -maxdepth 1 -exec rm -rf {} \;
|
||||
|
||||
.PHONY: mbgl test linux build/test/Makefile
|
||||
# DO NOT DELETE
|
||||
|
||||
181
configure
vendored
181
configure
vendored
@@ -1,144 +1,55 @@
|
||||
#!/usr/bin/env python
|
||||
import optparse
|
||||
import os
|
||||
import pprint
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
#!/usr/bin/env bash
|
||||
|
||||
root_dir = os.path.dirname(__file__)
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
# parse our options
|
||||
parser = optparse.OptionParser()
|
||||
. ~/.nvm/nvm.sh
|
||||
nvm use 0.10
|
||||
|
||||
parser.add_option("--debug",
|
||||
action="store_true",
|
||||
dest="debug",
|
||||
help="Also build debug build")
|
||||
LIBCURL_VERSION=system
|
||||
GLFW_VERSION=a21f2377
|
||||
LIBPNG_VERSION=1.6.13
|
||||
SQLITE_VERSION=system
|
||||
LIBUV_VERSION=0.10.28
|
||||
|
||||
parser.add_option("--node",
|
||||
action="store",
|
||||
dest="node",
|
||||
help="Name of the node executable (defaults to node)")
|
||||
mason install libcurl ${LIBCURL_VERSION}
|
||||
mason install glfw ${GLFW_VERSION}
|
||||
mason install libpng ${LIBPNG_VERSION}
|
||||
mason install sqlite ${SQLITE_VERSION}
|
||||
mason install libuv ${LIBUV_VERSION}
|
||||
|
||||
parser.add_option("--npm",
|
||||
action="store",
|
||||
dest="npm",
|
||||
help="Name of the npm executable (defaults to npm)")
|
||||
BOOST_ROOT=/usr
|
||||
if [ -d '/usr/local/boost' ]; then BOOST_ROOT='/usr/local' ; fi
|
||||
|
||||
parser.add_option("--pkg-config-root",
|
||||
action="store",
|
||||
dest="pkgconfig_root",
|
||||
help="Path to pkg-config directory")
|
||||
|
||||
parser.add_option("--boost",
|
||||
action="store",
|
||||
dest="boost_root",
|
||||
help="Path to boost (defaults to /usr/local)")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
def pkg_config(pkg, pkgconfig_root):
|
||||
env = os.environ.copy()
|
||||
if pkgconfig_root:
|
||||
env["PKG_CONFIG_PATH"] = pkgconfig_root
|
||||
env["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "1"
|
||||
env["PKG_CONFIG_ALLOW_SYSTEM_LIBS"] = "1"
|
||||
cmd = subprocess.Popen(['pkg-config', '--static', '--libs', pkg], stdout=subprocess.PIPE, env=env)
|
||||
libs, ret = cmd.communicate()
|
||||
if (ret): return None
|
||||
|
||||
cmd = subprocess.Popen(['pkg-config', '--static', '--cflags', pkg], stdout=subprocess.PIPE, env=env)
|
||||
cflags, ret = cmd.communicate()
|
||||
if (ret): return None
|
||||
|
||||
return (libs, cflags)
|
||||
|
||||
def configure_mbgl(o):
|
||||
if options.boost_root:
|
||||
o['variables']['boost_root'] = options.boost_root
|
||||
else:
|
||||
o['variables']['boost_root'] = '/usr/local'
|
||||
if options.node:
|
||||
o['variables']['node'] = options.node
|
||||
else:
|
||||
o['variables']['node'] = 'node'
|
||||
if options.npm:
|
||||
o['variables']['npm'] = options.npm
|
||||
else:
|
||||
o['variables']['npm'] = 'npm'
|
||||
o['target_defaults']['default_configuration'] = 'Debug' if options.debug else 'Release'
|
||||
|
||||
|
||||
def fix_frameworks(libs):
|
||||
# don't split "-framework Foo"
|
||||
return re.split('(?<!-framework)\s+', libs.strip())
|
||||
|
||||
def configure_glfw3(o):
|
||||
ret = pkg_config('glfw3', options.pkgconfig_root)
|
||||
if not ret:
|
||||
sys.stderr.write('could not find glfw3 with pkg-config')
|
||||
sys.exit(-1)
|
||||
o['variables']['glfw3_libraries'] = fix_frameworks(ret[0])
|
||||
o['variables']['glfw3_cflags'] = ret[1].split()
|
||||
|
||||
def configure_uv(o):
|
||||
ret = pkg_config('libuv', options.pkgconfig_root)
|
||||
if not ret:
|
||||
sys.stderr.write('could not find uv with pkg-config')
|
||||
sys.exit(-1)
|
||||
o['variables']['uv_libraries'] = ret[0].split()
|
||||
o['variables']['uv_cflags'] = ret[1].split()
|
||||
|
||||
def configure_png(o):
|
||||
ret = pkg_config('libpng', options.pkgconfig_root)
|
||||
if not ret:
|
||||
sys.stderr.write('could not find png with pkg-config')
|
||||
sys.exit(-1)
|
||||
o['variables']['png_libraries'] = ret[0].split()
|
||||
o['variables']['png_cflags'] = ret[1].split()
|
||||
|
||||
def configure_curl(o):
|
||||
ret = pkg_config('libcurl', options.pkgconfig_root)
|
||||
if not ret:
|
||||
sys.stderr.write('could not find curl with pkg-config')
|
||||
sys.exit(-1)
|
||||
o['variables']['curl_libraries'] = ret[0].split()
|
||||
o['variables']['curl_cflags'] = ret[1].split()
|
||||
|
||||
def configure_sqlite3(o):
|
||||
ret = pkg_config('sqlite3', options.pkgconfig_root)
|
||||
if not ret:
|
||||
sys.stderr.write('could not find sqlite3 with pkg-config')
|
||||
sys.exit(-1)
|
||||
o['variables']['sqlite3_libraries'] = ret[0].split()
|
||||
o['variables']['sqlite3_cflags'] = ret[1].split()
|
||||
|
||||
def write(filename, data):
|
||||
filename = os.path.join(root_dir, filename)
|
||||
print "creating ", filename
|
||||
f = open(filename, 'w+')
|
||||
f.write(data)
|
||||
|
||||
output = {
|
||||
'variables': { 'python': sys.executable },
|
||||
'target_defaults' : {
|
||||
'include_dirs': [],
|
||||
'libraries': [],
|
||||
'defines': [],
|
||||
'cflags': []
|
||||
}
|
||||
function quote_flags {
|
||||
python -c "import sys, re; print re.split('(?<!-framework)\s+', ' '.join(sys.argv[1:]))" "$@"
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
configure_mbgl(output)
|
||||
configure_glfw3(output)
|
||||
configure_uv(output)
|
||||
configure_png(output)
|
||||
configure_curl(output)
|
||||
configure_sqlite3(output)
|
||||
pprint.pprint(output, indent=2)
|
||||
echo "# Do not edit. Generated by the configure script.
|
||||
{
|
||||
'target_defaults': {
|
||||
'cflags': [],
|
||||
'default_configuration': 'Release',
|
||||
'defines': [],
|
||||
'include_dirs': [],
|
||||
'libraries': []
|
||||
},
|
||||
'variables': {
|
||||
'node': '$(which node)',
|
||||
'npm': '$(which npm)',
|
||||
'python': '$(which python)',
|
||||
'boost_root': '/usr/local',
|
||||
'curl_cflags': $(quote_flags $(mason cflags libcurl ${LIBCURL_VERSION})),
|
||||
'curl_libraries': $(quote_flags $(mason ldflags libcurl ${LIBCURL_VERSION})),
|
||||
'glfw3_cflags': $(quote_flags $(mason cflags glfw ${GLFW_VERSION})),
|
||||
'glfw3_libraries': $(quote_flags $(mason ldflags glfw ${GLFW_VERSION})),
|
||||
'png_cflags': $(quote_flags $(mason cflags libpng ${LIBPNG_VERSION})),
|
||||
'png_libraries': $(quote_flags $(mason ldflags libpng ${LIBPNG_VERSION})),
|
||||
'sqlite3_cflags': $(quote_flags $(mason cflags sqlite ${SQLITE_VERSION})),
|
||||
'sqlite3_libraries': $(quote_flags $(mason ldflags sqlite ${SQLITE_VERSION})),
|
||||
'uv_cflags': $(quote_flags $(mason cflags libuv ${LIBUV_VERSION})),
|
||||
'uv_libraries': $(quote_flags $(mason ldflags libuv ${LIBUV_VERSION})),
|
||||
}
|
||||
}" > config.gypi
|
||||
|
||||
write('config.gypi', "# Do not edit. Generated by the configure script.\n" +
|
||||
pprint.pformat(output, indent=2) + "\n")
|
||||
cat config.gypi
|
||||
|
||||
@@ -143,10 +143,15 @@ public:
|
||||
|
||||
private:
|
||||
// uv async callbacks
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
static void render(uv_async_t *async, int status);
|
||||
static void terminate(uv_async_t *async, int status);
|
||||
static void cleanup(uv_async_t *async, int status);
|
||||
#else
|
||||
static void render(uv_async_t *async);
|
||||
static void terminate(uv_async_t *async);
|
||||
static void cleanup(uv_async_t *async);
|
||||
static void delete_async(uv_handle_t *handle);
|
||||
#endif
|
||||
|
||||
// Setup
|
||||
void setup();
|
||||
|
||||
@@ -24,17 +24,31 @@ private:
|
||||
class loop {
|
||||
public:
|
||||
inline loop() {
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
l = uv_loop_new();
|
||||
if (l == nullptr) {
|
||||
#else
|
||||
l = new uv_loop_t;
|
||||
if (uv_loop_init(&l) != 0) {
|
||||
#endif
|
||||
throw std::runtime_error("failed to initialize loop");
|
||||
}
|
||||
}
|
||||
|
||||
inline ~loop() { uv_loop_close(&l); }
|
||||
inline ~loop() {
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
uv_loop_delete(l);
|
||||
#else
|
||||
uv_loop_close(l);
|
||||
delete l;
|
||||
#endif
|
||||
|
||||
inline uv_loop_t *operator*() { return &l; }
|
||||
}
|
||||
|
||||
inline uv_loop_t *operator*() { return l; }
|
||||
|
||||
private:
|
||||
uv_loop_t l;
|
||||
uv_loop_t *l = nullptr;
|
||||
};
|
||||
|
||||
class mutex {
|
||||
|
||||
@@ -145,10 +145,6 @@ void Map::stop(stop_callback cb, void *data) {
|
||||
async = false;
|
||||
}
|
||||
|
||||
void Map::delete_async(uv_handle_t *handle) {
|
||||
delete (uv_async_t *)handle;
|
||||
}
|
||||
|
||||
void Map::run() {
|
||||
#ifndef NDEBUG
|
||||
if (!async) {
|
||||
@@ -203,7 +199,11 @@ void Map::cleanup() {
|
||||
}
|
||||
}
|
||||
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
void Map::cleanup(uv_async_t *async, int) {
|
||||
#else
|
||||
void Map::cleanup(uv_async_t *async) {
|
||||
#endif
|
||||
Map *map = static_cast<Map *>(async->data);
|
||||
|
||||
map->view.make_active();
|
||||
@@ -221,7 +221,11 @@ void Map::setReachability(bool reachable) {
|
||||
}
|
||||
}
|
||||
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
void Map::render(uv_async_t *async, int) {
|
||||
#else
|
||||
void Map::render(uv_async_t *async) {
|
||||
#endif
|
||||
Map *map = static_cast<Map *>(async->data);
|
||||
assert(uv_thread_self() == map->map_thread);
|
||||
|
||||
@@ -241,7 +245,11 @@ void Map::render(uv_async_t *async) {
|
||||
}
|
||||
}
|
||||
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
void Map::terminate(uv_async_t *async, int) {
|
||||
#else
|
||||
void Map::terminate(uv_async_t *async) {
|
||||
#endif
|
||||
// Closes all open handles on the loop. This means that the loop will automatically terminate.
|
||||
Map *map = static_cast<Map *>(async->data);
|
||||
assert(uv_thread_self() == map->map_thread);
|
||||
|
||||
@@ -29,7 +29,11 @@ void FileRequestBaton::notify_error(uv_fs_t *req) {
|
||||
if (ptr->request && req->result < 0 && !ptr->canceled && req->result != UV_ECANCELED) {
|
||||
ptr->request->response = std::unique_ptr<Response>(new Response);
|
||||
ptr->request->response->code = req->result == UV_ENOENT ? 404 : 500;
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
ptr->request->response->message = uv_strerror(uv_last_error(req->loop));
|
||||
#else
|
||||
ptr->request->response->message = uv_strerror(int(req->result));
|
||||
#endif
|
||||
ptr->request->notify();
|
||||
}
|
||||
}
|
||||
@@ -54,7 +58,8 @@ void FileRequestBaton::file_opened(uv_fs_t *req) {
|
||||
uv_fs_close(req->loop, req, fd, file_closed);
|
||||
} else {
|
||||
ptr->fd = fd;
|
||||
uv_fs_fstat(req->loop, req, fd, file_stated);
|
||||
const int r = uv_fs_fstat(req->loop, req, fd, file_stated);
|
||||
assert(r == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +68,7 @@ void FileRequestBaton::file_stated(uv_fs_t *req) {
|
||||
FileRequestBaton *ptr = (FileRequestBaton *)req->data;
|
||||
assert(ptr->thread_id == uv_thread_self());
|
||||
|
||||
if (req->result < 0 || ptr->canceled || !ptr->request) {
|
||||
if (req->result != 0 || ptr->canceled || !ptr->request) {
|
||||
// Stating failed or was canceled. We already have an open file handle
|
||||
// though, which we'll have to close.
|
||||
notify_error(req);
|
||||
@@ -71,13 +76,22 @@ void FileRequestBaton::file_stated(uv_fs_t *req) {
|
||||
uv_fs_req_cleanup(req);
|
||||
uv_fs_close(req->loop, req, ptr->fd, file_closed);
|
||||
} else {
|
||||
if (static_cast<const uv_stat_t *>(req->ptr)->st_size > std::numeric_limits<int>::max()) {
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
const uv_statbuf_t *stat = static_cast<const uv_statbuf_t *>(req->ptr);
|
||||
#else
|
||||
const uv_stat_t *stat = static_cast<const uv_stat_t *>(req->ptr);
|
||||
#endif
|
||||
if (stat->st_size > std::numeric_limits<int>::max()) {
|
||||
// File is too large for us to open this way because uv_buf's only support unsigned
|
||||
// ints as maximum size.
|
||||
if (ptr->request) {
|
||||
ptr->request->response = std::unique_ptr<Response>(new Response);
|
||||
ptr->request->response->code = UV_EFBIG;
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
ptr->request->response->message = uv_strerror(uv_err_t {UV_EFBIG, 0});
|
||||
#else
|
||||
ptr->request->response->message = uv_strerror(UV_EFBIG);
|
||||
#endif
|
||||
ptr->request->notify();
|
||||
}
|
||||
|
||||
@@ -85,11 +99,15 @@ void FileRequestBaton::file_stated(uv_fs_t *req) {
|
||||
uv_fs_close(req->loop, req, ptr->fd, file_closed);
|
||||
} else {
|
||||
const unsigned int size =
|
||||
(unsigned int)(static_cast<const uv_stat_t *>(req->ptr)->st_size);
|
||||
(unsigned int)(stat->st_size);
|
||||
ptr->body.resize(size);
|
||||
ptr->buffer = uv_buf_init(const_cast<char *>(ptr->body.data()), size);
|
||||
uv_fs_req_cleanup(req);
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
uv_fs_read(req->loop, req, ptr->fd, ptr->buffer.base, ptr->buffer.len, -1, file_read);
|
||||
#else
|
||||
uv_fs_read(req->loop, req, ptr->fd, &ptr->buffer, 1, 0, file_read);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,11 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr<Response> &&res) {
|
||||
http_baton->response = std::move(res);
|
||||
http_baton->async->data = new util::ptr<HTTPRequestBaton>(http_baton);
|
||||
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
uv_async_init(loop, http_baton->async, [](uv_async_t *async, int) {
|
||||
#else
|
||||
uv_async_init(loop, http_baton->async, [](uv_async_t *async) {
|
||||
#endif
|
||||
util::ptr<HTTPRequestBaton> &http_baton = *(util::ptr<HTTPRequestBaton> *)async->data;
|
||||
|
||||
if (http_baton->request) {
|
||||
@@ -193,7 +197,12 @@ void HTTPRequest::retryHTTPRequest(std::unique_ptr<Response> &&res, uint64_t tim
|
||||
backoff_timer = new uv_timer_t();
|
||||
uv_timer_init(loop, backoff_timer);
|
||||
backoff_timer->data = new RetryBaton(this, std::move(res));
|
||||
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
uv_timer_start(backoff_timer, [](uv_timer_t *timer, int) {
|
||||
#else
|
||||
uv_timer_start(backoff_timer, [](uv_timer_t *timer) {
|
||||
#endif
|
||||
std::unique_ptr<RetryBaton> pair { static_cast<RetryBaton *>(timer->data) };
|
||||
pair->first->startHTTPRequest(std::move(pair->second));
|
||||
pair->first->backoff_timer = nullptr;
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
namespace uv {
|
||||
|
||||
std::string cwd() {
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
char dir[512];
|
||||
uv_cwd(dir, 512);
|
||||
return dir;
|
||||
#else
|
||||
size_t max = 0;
|
||||
std::string dir;
|
||||
do {
|
||||
@@ -14,6 +19,7 @@ std::string cwd() {
|
||||
} while (max == dir.size());
|
||||
dir.resize(max - 1);
|
||||
return dir;
|
||||
#endif
|
||||
}
|
||||
|
||||
void deleter::operator()(uv_async_t *async) {
|
||||
|
||||
Reference in New Issue
Block a user