New mason-based build system

This commit is contained in:
Konstantin Käfer
2014-10-22 15:13:35 +02:00
37 changed files with 311 additions and 519 deletions

3
.gitignore vendored
View File

@@ -4,10 +4,11 @@
*.actual.png
*.diff.png
/node_modules
/mapnik-packaging
/mason_packages
/macosx/build
/ios/build
/config.gypi
/config-ios.gypi
/config/constants_local.cpp
/build
/bin/node_modules

View File

@@ -25,14 +25,12 @@ env:
before_install:
- source ./scripts/flags.sh
- (git clone https://github.com/mapbox/mason.git ~/.mason ; sudo ln -s ~/.mason/mason /usr/local/bin/mason)
- ./scripts/travis_before_install.sh
install:
- make setup
- ./scripts/travis_install.sh
before_script:
- rm -rf mapnik-packaging/out/packages
- make config.gypi
- ./scripts/travis_install_test_suite.sh
script:
- ./scripts/travis_script.sh

View File

@@ -2,31 +2,23 @@ BUILDTYPE ?= Release
PYTHON ?= python
V ?= 1
all: setup
setup: config.gypi
all: mbgl
config.gypi:
./setup-libraries.sh
./configure
xlibs:
@./mapnik-packaging/osx/darwin_configure.sh osx
ilibs:
@./mapnik-packaging/osx/darwin_configure.sh ios
config-ios.gypi:
MASON_PLATFORM=ios ./configure config-ios.gypi
# Builds the regular library
mbgl: config.gypi mapboxgl.gyp node
deps/run_gyp mapboxgl.gyp --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make
mbgl: config.gypi mapboxgl.gyp
deps/run_gyp mapboxgl.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make
$(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mapboxgl
node:
@if [ ! `which node` ]; then echo 'error: depends on node.js. please make sure node is on your PATH'; exit 1; fi;
##### Test cases ###############################################################
build/test/Makefile: src common config.gypi test/test.gyp
deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build/test -f make
deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/test -f make
test: build/test/Makefile
$(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) test
@@ -36,16 +28,16 @@ test_%: build/test/Makefile
(cd build/$(BUILDTYPE) && exec ./test_$*)
# build Mac OS X project for Xcode
xtest: config.gypi clear_xcode_cache node
deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build -f xcode
xtest: config.gypi clear_xcode_cache
deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build -f xcode
open ./build/test/test.xcodeproj
##### Makefile builds ##########################################################
# Builds the linux app with make.
linux: config.gypi linux/mapboxgl-app.gyp node
deps/run_gyp linux/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make
linux: config.gypi linux/mapboxgl-app.gyp
deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make
$(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp
# Executes the Linux binary
@@ -55,8 +47,8 @@ run-linux: linux
# Builds the OS X app with make.
osx: config.gypi macosx/mapboxgl-app.gyp node
deps/run_gyp macosx/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make
osx: config.gypi macosx/mapboxgl-app.gyp
deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make
$(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp
# Executes the OS X binary
@@ -77,22 +69,22 @@ clear_xcode_cache:
fi
# build Mac OS X project for Xcode
xproj-cli: config.gypi xlibs macosx/mapboxgl-app.gyp clear_xcode_cache node
deps/run_gyp macosx/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode
xproj-cli: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache
deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode
xproj: xproj-cli
open ./build/macosx/mapboxgl-app.xcodeproj
# build iOS project for Xcode
iproj-cli: config.gypi ilibs ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node
deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode
iproj-cli: config-ios.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache
deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp -Iconfig-ios.gypi --depth=. --generator-output=./build -f xcode
iproj: iproj-cli
open ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj
# build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code)
lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache node
deps/run_gyp linux/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode
lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache
deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode
open ./build/linux/mapboxgl-app.xcodeproj
@@ -101,11 +93,10 @@ lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache node
clean: clear_xcode_cache
-find ./deps/gyp -name "*.pyc" -exec rm {} \;
-rm -rf ./build/
-rm -rf ./config.gypi
-rm -rf ./config.gypi ./config-ios.gypi
distclean: clean
-rm -rf ./mapnik-packaging/osx/out/build-*
-rm -rf ./mapnik-packaging/osx/out/universal
-find ./mapnik-packaging/osx/out/packages -type d ! -name 'packages' -maxdepth 1 -exec rm -rf {} \;
-rm -rf ./mason_packages
.PHONY: mbgl test linux build/test/Makefile
# DO NOT DELETE

View File

@@ -52,7 +52,7 @@
// Handles the request thread + messaging to the thread.
static uv_once_t once;
static uv_loop_t loop;
static uv_loop_t *loop = nullptr;
static uv_messenger_t start_messenger;
static uv_messenger_t stop_messenger;
static uv_thread_t thread;
@@ -228,7 +228,7 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void *
context->sockfd = sockfd;
assert(!context->poll_handle);
context->poll_handle = new uv_poll_t;
uv_poll_init_socket(&loop, context->poll_handle, sockfd);
uv_poll_init_socket(loop, context->poll_handle, sockfd);
context->poll_handle->data = context;
curl_multi_assign(multi, sockfd, context);
}
@@ -253,7 +253,11 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void *
return 0;
}
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
void on_timeout(uv_timer_t *, int = 0) {
#else
void on_timeout(uv_timer_t *) {
#endif
int running_handles;
CURLMcode error = curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running_handles);
if (error != CURLM_OK) {
@@ -275,7 +279,7 @@ void thread_init(void *) {
#endif
thread_id = uv_thread_self();
uv_timer_init(&loop, &timeout);
uv_timer_init(loop, &timeout);
CURLSHcode share_error;
share = curl_share_init();
@@ -305,7 +309,7 @@ void thread_init(void *) {
}
// Main event loop. This will not return until the request loop is terminated.
uv_run(&loop, UV_RUN_DEFAULT);
uv_run(loop, UV_RUN_DEFAULT);
curl_multi_cleanup(multi);
multi = nullptr;
@@ -442,9 +446,14 @@ void stop_request(void *const ptr) {
void create_thread() {
uv_mutex_init(&share_mutex);
uv_loop_init(&loop);
uv_messenger_init(&loop, &start_messenger, start_request);
uv_messenger_init(&loop, &stop_messenger, stop_request);
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
loop = uv_loop_new();
#else
loop = new uv_loop_t;
uv_loop_init(loop);
#endif
uv_messenger_init(loop, &start_messenger, start_request);
uv_messenger_init(loop, &stop_messenger, stop_request);
uv_thread_create(&thread, thread_init, nullptr);
}

247
configure vendored
View File

@@ -1,144 +1,131 @@
#!/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()
CONFIG_FILE=${1:-config.gypi}
parser.add_option("--debug",
action="store_true",
dest="debug",
help="Also build debug build")
function finish {
>&2 echo -en "\033[0m";
}
trap finish EXIT
parser.add_option("--node",
action="store",
dest="node",
help="Name of the node executable (defaults to node)")
parser.add_option("--npm",
action="store",
dest="npm",
help="Name of the npm executable (defaults to npm)")
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'
# Install node
if [[ ! -d ~/.nvm ]]; then
git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm
fi
set +u
. ~/.nvm/nvm.sh
if [ ! `nvm use 0.10 > /dev/null; echo $?` = 0 ]; then
>&2 echo -en "\033[1m\033[32m* "
nvm install 0.10
>&2 echo -en "\033[0m";
else
>&2 echo -en "\033[1m\033[32m* "
nvm use 0.10
>&2 echo -en "\033[0m";
fi
def fix_frameworks(libs):
# don't split "-framework Foo"
return re.split('(?<!-framework)\s+', libs.strip())
case $MASON_PLATFORM in
'ios')
SQLITE_VERSION=system
LIBPNG_VERSION=1.6.13
LIBUV_VERSION=0.10.28
ZLIB_VERSION=system
BOOST_VERSION=system
;;
*)
GLFW_VERSION=a21f2377
SQLITE_VERSION=system
LIBPNG_VERSION=system
LIBCURL_VERSION=system
LIBUV_VERSION=0.10.28
ZLIB_VERSION=system
BOOST_VERSION=system
;;
esac
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()
function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; }
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()
NODE=`which node || abort 'Cannot find node'`
NPM=`which npm || abort 'Cannot find npm'`
PYTHON=`which python || abort 'Cannot find python'`
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()
>&2 echo -en "\033[1m\033[32m* Using npm "
>&2 ${NPM} --version
>&2 echo -en "\033[0m";
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()
>&2 echo -en "\033[1m\033[32m* Using "
>&2 ${PYTHON} --version
>&2 echo -en "\033[0m";
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)
LN=$'\n'
write('config.gypi', "# Do not edit. Generated by the configure script.\n" +
pprint.pformat(output, indent=2) + "\n")
CONFIG="# Do not edit. Generated by the configure script.
{
'target_defaults': {
'cflags': [],
'default_configuration': 'Release',
'defines': [],
'include_dirs': [],
'libraries': []
},
'variables': {
'node': '${NODE}',
'npm': '${NPM}',
'python': '${PYTHON}',
"
if [ ! -z ${BOOST_VERSION} ]; then
mason install boost ${BOOST_VERSION}
CONFIG+=" 'boost_root': '$(mason prefix boost ${BOOST_VERSION})',"$LN
fi
if [ ! -z ${LIBCURL_VERSION} ]; then
mason install libcurl ${LIBCURL_VERSION}
CONFIG+=" 'curl_cflags': $(quote_flags $(mason cflags libcurl ${LIBCURL_VERSION})),"$LN
CONFIG+=" 'curl_libraries': $(quote_flags $(mason ldflags libcurl ${LIBCURL_VERSION})),"$LN
fi
if [ ! -z ${GLFW_VERSION} ]; then
mason install glfw ${GLFW_VERSION}
CONFIG+=" 'glfw3_cflags': $(quote_flags $(mason cflags glfw ${GLFW_VERSION})),"$LN
CONFIG+=" 'glfw3_libraries': $(quote_flags $(mason ldflags glfw ${GLFW_VERSION})),"$LN
fi
if [ ! -z ${LIBPNG_VERSION} ]; then
mason install libpng ${LIBPNG_VERSION}
CONFIG+=" 'png_cflags': $(quote_flags $(mason cflags libpng ${LIBPNG_VERSION})),"$LN
CONFIG+=" 'png_libraries': $(quote_flags $(mason ldflags libpng ${LIBPNG_VERSION})),"$LN
fi
if [ ! -z ${SQLITE_VERSION} ]; then
mason install sqlite ${SQLITE_VERSION}
CONFIG+=" 'sqlite3_cflags': $(quote_flags $(mason cflags sqlite ${SQLITE_VERSION})),"$LN
CONFIG+=" 'sqlite3_libraries': $(quote_flags $(mason ldflags sqlite ${SQLITE_VERSION})),"$LN
fi
if [ ! -z ${LIBUV_VERSION} ]; then
mason install libuv ${LIBUV_VERSION}
CONFIG+=" 'uv_cflags': $(quote_flags $(mason cflags libuv ${LIBUV_VERSION})),"$LN
CONFIG+=" 'uv_libraries': $(quote_flags $(mason ldflags libuv ${LIBUV_VERSION})),"$LN
fi
if [ ! -z ${ZLIB_VERSION} ]; then
mason install zlib ${ZLIB_VERSION}
CONFIG+=" 'zlib_cflags': $(quote_flags $(mason cflags zlib ${ZLIB_VERSION})),"$LN
CONFIG+=" 'zlib_libraries': $(quote_flags $(mason ldflags zlib ${ZLIB_VERSION})),"$LN
fi
CONFIG+=" }
}
"
echo "${CONFIG}" > ${CONFIG_FILE}
cat ${CONFIG_FILE}

View File

@@ -31,6 +31,10 @@ _intermediate_var = 'INTERMEDIATE_DIR'
# targets that share the same BUILT_PRODUCTS_DIR.
_shared_intermediate_var = 'SHARED_INTERMEDIATE_DIR'
# ONLY_ACTIVE_ARCH means that only the active architecture should be build for
# Debugging purposes to shorten the build time
_only_active_arch = 'ONLY_ACTIVE_ARCH'
_library_search_paths_var = 'LIBRARY_SEARCH_PATHS'
generator_default_variables = {
@@ -168,6 +172,8 @@ class XcodeProject(object):
xccl.SetBuildSetting(_shared_intermediate_var,
'$(SYMROOT)/DerivedSources/$(CONFIGURATION)')
xccl.ConfigurationNamed('Debug').SetBuildSetting(_only_active_arch, 'YES')
# Set user-specified project-wide build settings and config files. This
# is intended to be used very sparingly. Really, almost everything should
# go into target-specific build settings sections. The project-wide
@@ -604,7 +610,11 @@ def GenerateOutput(target_list, target_dicts, data, params):
if parallel_builds:
pbxp.SetProperty('attributes',
{'BuildIndependentTargetsInParallel': 'YES'})
{
'BuildIndependentTargetsInParallel': 'YES',
'LastUpgradeCheck': '0500'
}
)
if project_version:
xcp.project_file.SetXcodeVersion(project_version)

View File

@@ -2158,6 +2158,7 @@ class XCTarget(XCRemoteObject):
if configs.HasBuildSetting('PRODUCT_NAME') == 0:
configs.SetBuildSetting('PRODUCT_NAME',
self._properties['productName'])
configs.SetBuildSetting('COMBINE_HIDPI_IMAGES', 'YES')
def AddDependency(self, other):
pbxproject = self.PBXProjectAncestor()
@@ -2811,7 +2812,7 @@ class XCProjectFile(XCObject):
_schema.update({
'archiveVersion': [0, int, 0, 1, 1],
'classes': [0, dict, 0, 1, {}],
'objectVersion': [0, int, 0, 1, 45],
'objectVersion': [0, int, 0, 1, 46],
'rootObject': [0, PBXProject, 1, 1],
})

View File

@@ -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();

View File

@@ -65,7 +65,6 @@ constexpr EventSeverity disabledEventSeverities[] = {
#endif
};
constexpr Event disabledEvents[] = {
Event(-1) // Avoid zero size array
};

View File

@@ -5,6 +5,7 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#ifdef __clang__
#pragma GCC diagnostic ignored "-Wdeprecated-register"
#else

View File

@@ -5,8 +5,7 @@
extern "C" {
#endif
typedef struct uv_messenger_s uv_messenger_t;
#include <mbgl/util/uv-messenger.h>
#include <mbgl/util/uv-channel.h>
#include <stdlib.h>

View File

@@ -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 {

View File

@@ -33,6 +33,7 @@
],
'OTHER_LDFLAGS': [
'<@(glfw3_libraries)',
'<@(curl_libraries)',
],
}
},
@@ -46,6 +47,7 @@
'link_settings': {
'libraries': [
'<@(glfw3_libraries)',
'<@(curl_libraries)',
'-lboost_regex'
],
},

View File

@@ -85,7 +85,7 @@ int main() {
// Notify map object when network reachability status changes.
Reachability* reachability = [Reachability reachabilityForInternetConnection];
reachability.reachableBlock = ^(Reachability *reachability) {
reachability.reachableBlock = ^(Reachability *) {
map_ptr->setReachability(true);
};
[reachability startNotifier];

View File

@@ -1,7 +1,6 @@
{
'includes': [
'./common.gypi',
'./config.gypi',
],
'targets': [
{
@@ -139,8 +138,8 @@
'OTHER_CPLUSPLUSFLAGS': [
'<@(png_cflags)',
'<@(uv_cflags)',
'<@(curl_cflags)',
'<@(sqlite3_cflags)',
'<@(zlib_cflags)',
'-I<(boost_root)/include',
],
'OTHER_CFLAGS': [
@@ -151,8 +150,8 @@
'cflags': [
'<@(png_cflags)',
'<@(uv_cflags)',
'<@(curl_cflags)',
'<@(sqlite3_cflags)',
'<@(zlib_cflags)',
'-I<(boost_root)/include',
],
}]
@@ -166,27 +165,23 @@
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [
'<@(uv_cflags)',
'<@(curl_cflags)',
'-I<(boost_root)/include',
],
'OTHER_LDFLAGS': [
'<@(png_libraries)',
'<@(uv_libraries)',
'<@(curl_libraries)',
'<@(sqlite3_libraries)',
'<@(zlib_libraries)',
]
}
}, {
'cflags': [
'<@(uv_cflags)',
'<@(curl_cflags)',
'-I<(boost_root)/include',
],
'libraries': [
'<@(png_libraries)',
'<@(uv_libraries)',
'<@(curl_libraries)',
'<@(sqlite3_libraries)',
'<@(zlib_libraries)',
]
}]
]
@@ -212,8 +207,7 @@
],
'xcode_settings': {
'SDKROOT': 'iphoneos',
'SUPPORTED_PLATFORMS': ['iphonesimulator','iphoneos'],
'ARCHS': [ "armv7", "armv7s", "arm64", "i386", "x86_64" ],
'SUPPORTED_PLATFORMS': 'iphonesimulator iphoneos',
'TARGETED_DEVICE_FAMILY': '1,2',
'CODE_SIGN_IDENTITY': 'iPhone Developer',
'IPHONEOS_DEPLOYMENT_TARGET': '7.0',
@@ -222,8 +216,8 @@
'OTHER_CPLUSPLUSFLAGS': [
'<@(png_cflags)',
'<@(uv_cflags)',
'<@(curl_cflags)',
'<@(sqlite3_cflags)',
'<@(zlib_cflags)',
'-I<(boost_root)/include',
],
},
@@ -238,8 +232,8 @@
'OTHER_LDFLAGS': [
'<@(png_libraries)',
'<@(uv_libraries)',
'<@(curl_libraries)',
'<@(sqlite3_libraries)',
'<@(zlib_libraries)',
],
'OTHER_CPLUSPLUSFLAGS': [
'<@(uv_cflags)',

View File

@@ -6,7 +6,8 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
# use g++ that supports c++11
if [[ ${CXX} == "g++" ]]; then
export CXX="g++-4.8" ;
export CXX="g++-4.8"
export CC="gcc-4.8"
fi
# If building in debug then turn on sanitizers.

View File

@@ -10,18 +10,22 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
if [[ `lsb_release -r` =~ "12.04" ]]; then
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
fi
sudo add-apt-repository --yes ppa:boost-latest/ppa
sudo apt-get update -y
sudo apt-get -y install gcc-4.8 g++-4.8
sudo apt-get -y install git build-essential zlib1g-dev automake \
libtool xutils-dev make cmake pkg-config python-pip
libtool xutils-dev make cmake pkg-config python-pip \
libboost1.55-dev libboost-regex1.55-dev libcurl4-openssl-dev \
libpng-dev libsqlite3-dev
sudo apt-get -y install libxi-dev libglu1-mesa-dev x11proto-randr-dev \
x11proto-xext-dev libxrandr-dev \
x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev
x11proto-xf86vidmode-dev libxxf86vm-dev \
libxcursor-dev libxinerama-dev
sudo pip install awscli
elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then
#
# install OS X dependencies
#
brew install autoconf automake libtool makedepend cmake pkg-config node git
brew install autoconf automake libtool makedepend cmake pkg-config node git boost
sudo pip install awscli
fi

View File

@@ -1,62 +0,0 @@
#!/bin/bash
set -e -u
UNAME=$(uname -s);
MISSING_DEPS=""
function ensure_dep {
if [[ ! `which $1` ]]; then
MISSING_DEPS="$MISSING_DEPS $1"
fi
}
ensure_dep aclocal
ensure_dep cmake
ensure_dep automake
ensure_dep autoconf
ensure_dep pkg-config
ensure_dep node
ensure_dep libtool
ensure_dep gccmakedep
if [[ $MISSING_DEPS != "" ]]; then
if [ ${UNAME} = 'Darwin' ]; then
echo "Missing build deps: ${MISSING_DEPS}"
echo 'Please run "brew install autoconf automake libtool makedepend cmake pkg-config node"'
echo 'and then re-run ./setup-libraries.sh'
elif [ ${UNAME} = 'Linux' ]; then
echo "Missing build deps: ${MISSING_DEPS}"
echo 'Please run "sudo apt-get install git build-essential zlib1g-dev automake libtool xutils-dev make cmake pkg-config nodejs-legacy libxi-dev libglu1-mesa-dev x11proto-randr-dev x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev"'
echo 'and then re-run ./setup-libraries.sh'
fi
exit 1
fi
export SYSROOT=`pwd`/../rootfs
export SDK_PATH=`pwd`/../arm-linux-gnueabi-linaro_4.8.3-2014.04
export V=1
if [ ! -d 'mapnik-packaging/.git' ]; then
git clone --depth=1 https://github.com/mapnik/mapnik-packaging.git
fi
cd mapnik-packaging/osx/
# git pull
export CXX11=true
source Linaro-softfp.sh
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libboost_regex.a ] ; then ./scripts/build_boost.sh --with-regex ; fi
cd ../../
./configure \
--pkg-config-root=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/pkgconfig \
--boost=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp \
--node=`which node`

View File

@@ -1,178 +0,0 @@
#!/bin/bash
set -e -u
UNAME=$(uname -s);
MISSING_DEPS=""
function ensure_dep {
if [[ ! `which $1` ]]; then
MISSING_DEPS="$MISSING_DEPS $1"
fi
}
ensure_dep aclocal
ensure_dep cmake
ensure_dep automake
ensure_dep autoconf
ensure_dep pkg-config
if [ ${UNAME} = 'Darwin' ]; then
ensure_dep makedepend
if [[ ! `which libtool` ]] && [[ ! `which glibtool` ]]; then
MISSING_DEPS="$MISSING_DEPS libtool"
fi
elif [ ${UNAME} = 'Linux' ]; then
ensure_dep libtool
ensure_dep gccmakedep
fi
if [[ $MISSING_DEPS != "" ]]; then
if [ ${UNAME} = 'Darwin' ]; then
echo "Missing build deps: ${MISSING_DEPS}"
echo 'Please run "brew install autoconf automake libtool makedepend cmake pkg-config"'
echo 'and then re-run ./setup-libraries.sh'
elif [ ${UNAME} = 'Linux' ]; then
echo "Missing build deps: ${MISSING_DEPS}"
echo 'Please run "sudo apt-get install git build-essential zlib1g-dev automake libtool xutils-dev make cmake pkg-config libxi-dev libglu1-mesa-dev x11proto-randr-dev x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev"'
echo 'and then re-run ./setup-libraries.sh'
fi
exit 1
fi
# bootstrap node install
if [[ ! -d ~/.nvm ]]; then
git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm
fi
set +u
source ~/.nvm/nvm.sh
nvm install 0.10
set -u
NODE=$(which node)
NPM=$(which npm)
MP_HASH="f543fecbeb0982983593aa0847715d26c323b990"
DIR_HASH=$(echo `pwd` | git hash-object --stdin)
if [ ! -d 'mapnik-packaging/' ]; then
git clone https://github.com/mapnik/mapnik-packaging.git
fi
cd mapnik-packaging
git fetch
git checkout ${MP_HASH}
cd ./osx/
export CXX11=true
if [ ${UNAME} = 'Darwin' ]; then
if [[ -n ${TRAVIS:-} ]]; then
if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then
if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then
rm -rf out/build-cpp11-libcpp-x86_64-macosx
rm -rf out/build-cpp11-libcpp-universal
tar -xzf out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz
tar -xzf out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz
fi
fi
fi
if test -z "${TRAVIS:-}" || ! test -d out/build-cpp11-libcpp-universal; then
source iPhoneOS.sh
if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
echo ' ...done'
source iPhoneOSs.sh
if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
echo ' ...done'
source iPhoneOS64.sh
if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
echo ' ...done'
source iPhoneSimulator.sh
if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
echo ' ...done'
source iPhoneSimulator64.sh
if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
echo ' ...done'
source MacOSX.sh
if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -d out/build-cpp11-libcpp-x86_64-macosx/include/boost ] ; then ./scripts/build_boost.sh `pwd`/../../src/ `pwd`/../../include/ `pwd`/../../linux/ `pwd`/../../common/ ; fi
echo ' ...done'
# setup iOS universal libs
./scripts/make_universal.sh
patch -p0 --forward < patches/curl-ios.diff || true
echo "NOTE: One patch FAILURE is expected. The other should have been applied or ignored."
if [[ ${TRAVIS:-} && ${AWS_ACCESS_KEY_ID:-} && ${AWS_SECRET_ACCESS_KEY:-} ]] ; then
tar -zcf out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-universal
aws s3 cp --acl public-read out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz s3://mapbox-gl-testing/dependencies/
tar -zcf out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-x86_64-macosx
aws s3 cp --acl public-read out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz s3://mapbox-gl-testing/dependencies/
fi
fi
cd ../../
# default to OS X build product symlinking
./mapnik-packaging/osx/darwin_configure.sh osx
elif [ ${UNAME} = 'Linux' ]; then
if [[ ${TRAVIS:-} ]]; then
if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ./out/ ; then
rm -rf out/build-cpp11-libstdcpp-gcc-x86_64-linux
tar -xzf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz
fi
fi
source Linux.sh
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libboost_regex.a ] ; then ./scripts/build_boost.sh --with-regex ; fi
if [[ ${TRAVIS:-} && ${AWS_ACCESS_KEY_ID:-} && ${AWS_SECRET_ACCESS_KEY:-} ]] ; then
if ! tar --compare -zf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ; then
tar -zcf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz out/build-cpp11-libstdcpp-gcc-x86_64-linux
aws s3 cp --acl public-read out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz s3://mapbox-gl-testing/dependencies/
fi
fi
cd ../../
./configure \
--pkg-config-root=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/pkgconfig \
--boost=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-x86_64-linux \
--npm=$NPM \
--node=$NODE
fi

View File

@@ -59,7 +59,7 @@ struct BucketAlloc
static int CreateBucket( struct BucketAlloc* ba )
{
size_t size;
unsigned int size;
Bucket* bucket;
void* freelist;
unsigned char* head;

View File

@@ -209,13 +209,13 @@ PQhandle pqHeapInsert( TESSalloc* alloc, PriorityQHeap *pq, PQkey keyNew )
// If the heap overflows, double its size.
pq->max <<= 1;
pq->nodes = (PQnode *)alloc->memrealloc( alloc->userData, pq->nodes,
(size_t)((pq->max + 1) * sizeof( pq->nodes[0] )));
(unsigned int)((pq->max + 1) * sizeof( pq->nodes[0] )));
if (pq->nodes == NULL) {
pq->nodes = saveNodes; // restore ptr to free upon return
return INV_HANDLE;
}
pq->handles = (PQhandleElem *)alloc->memrealloc( alloc->userData, pq->handles,
(size_t) ((pq->max + 1) * sizeof( pq->handles[0] )));
(unsigned int) ((pq->max + 1) * sizeof( pq->handles[0] )));
if (pq->handles == NULL) {
pq->handles = saveHandles; // restore ptr to free upon return
return INV_HANDLE;
@@ -351,7 +351,7 @@ int pqInit( TESSalloc* alloc, PriorityQ *pq )
(pq->size * sizeof(pq->order[0])) );
*/
pq->order = (PQkey **)alloc->memalloc( alloc->userData,
(size_t)((pq->size+1) * sizeof(pq->order[0])) );
(unsigned int)((pq->size+1) * sizeof(pq->order[0])) );
/* the previous line is a patch to compensate for the fact that IBM */
/* machines return a null on a malloc of zero bytes (unlike SGI), */
/* so we have to put in this defense to guard against a memory */
@@ -438,7 +438,7 @@ PQhandle pqInsert( TESSalloc* alloc, PriorityQ *pq, PQkey keyNew )
// If the heap overflows, double its size.
pq->max <<= 1;
pq->keys = (PQkey *)alloc->memrealloc( alloc->userData, pq->keys,
(size_t)(pq->max * sizeof( pq->keys[0] )));
(unsigned int)(pq->max * sizeof( pq->keys[0] )));
if (pq->keys == NULL) {
pq->keys = saveKey; // restore ptr to free upon return
return INV_HANDLE;

View File

@@ -428,6 +428,8 @@ static void VertexWeights( TESSvertex *isect, TESSvertex *org, TESSvertex *dst,
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
static void GetIntersectData( TESStesselator *tess, TESSvertex *isect,
TESSvertex *orgUp, TESSvertex *dstUp,
TESSvertex *orgLo, TESSvertex *dstLo )
@@ -444,6 +446,7 @@ static void GetIntersectData( TESStesselator *tess, TESSvertex *isect,
VertexWeights( isect, orgUp, dstUp, &weights[0] );
VertexWeights( isect, orgLo, dstLo, &weights[2] );
}
#pragma GCC diagnostic pop
static int CheckForRightSplice( TESStesselator *tess, ActiveRegion *regUp )
/*

View File

@@ -46,17 +46,6 @@
#define Dot(u,v) (u[0]*v[0] + u[1]*v[1] + u[2]*v[2])
static void Normalize( TESSreal v[3] )
{
TESSreal len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
assert( len > 0 );
len = sqrtf( len );
v[0] /= len;
v[1] /= len;
v[2] /= len;
}
#define ABS(x) ((x) < 0 ? -(x) : (x))
static int LongAxis( TESSreal v[3] )
@@ -436,6 +425,8 @@ int tessMeshSetWindingNumber( TESSmesh *mesh, int value,
return 1;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
void* heapAlloc( void* userData, unsigned int size )
{
return malloc( size );
@@ -450,6 +441,7 @@ void heapFree( void* userData, void* ptr )
{
free( ptr );
}
#pragma GCC diagnostic pop
static TESSalloc defaulAlloc =
{

View File

@@ -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);

View File

@@ -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();
}
}
@@ -63,7 +67,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 +75,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 +98,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
}
}
}
@@ -117,8 +134,7 @@ void FileRequestBaton::file_read(uv_fs_t *req) {
}
void FileRequestBaton::file_closed(uv_fs_t *req) {
FileRequestBaton *ptr = (FileRequestBaton *)req->data;
assert(ptr->thread_id == uv_thread_self());
assert(((FileRequestBaton *)req->data)->thread_id == uv_thread_self());
if (req->result < 0) {
// Closing the file failed. But there isn't anything we can do.

View File

@@ -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;

View File

@@ -18,10 +18,10 @@ template <typename T>
T StopsFunction<T>::evaluate(float z) const {
bool smaller = false;
float smaller_z = 0.0f;
T smaller_val {};
T smaller_val = T();
bool larger = false;
float larger_z = 0.0f;
T larger_val {};
T larger_val = T();
for (uint32_t i = 0; i < values.size(); i++) {
float stop_z = values[i].first;

View File

@@ -18,7 +18,7 @@ std::string compress(const std::string &raw) {
}
deflate_stream.next_in = (Bytef *)raw.data();
deflate_stream.avail_in = raw.size();
deflate_stream.avail_in = uInt(raw.size());
std::string result;
char out[16384];
@@ -53,7 +53,7 @@ std::string decompress(const std::string &raw) {
}
inflate_stream.next_in = (Bytef *)raw.data();
inflate_stream.avail_in = raw.size();
inflate_stream.avail_in = uInt(raw.size());
std::string result;
char out[15384];

View File

@@ -208,7 +208,7 @@ int raw_equal(const char *first, const char *second)
int clamp_to_int(long slnum)
{
return slnum > INT_MAX ? INT_MAX : slnum < INT_MIN ? INT_MIN : slnum;
return slnum > INT_MAX ? INT_MAX : slnum < INT_MIN ? INT_MIN : (int)slnum;
}

View File

@@ -8,7 +8,15 @@ typedef struct {
void *queue[2];
} uv__messenger_item_t;
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void uv__messenger_callback(uv_async_t *async, int status) {
#pragma clang diagnostic pop
#else
void uv__messenger_callback(uv_async_t *async) {
#endif
uv_messenger_t *msgr = (uv_messenger_t *)async->data;
uv__messenger_item_t *item;

View File

@@ -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) {

View File

@@ -31,7 +31,7 @@ TEST(Enums, StyleLayerType) {
ASSERT_EQ(StyleLayerTypeClass(StyleLayerType::Raster), StyleLayerTypeClass(StyleLayerType::Raster));
ASSERT_EQ(StyleLayerTypeClass(StyleLayerType::Background), StyleLayerTypeClass(StyleLayerType::Background));
ASSERT_EQ(false, StyleLayerTypeClass("").valid());
ASSERT_EQ(false, StyleLayerTypeClass("Backgrund").valid());
ASSERT_FALSE(StyleLayerTypeClass("").valid());
ASSERT_FALSE(StyleLayerTypeClass("Backgrund").valid());
}

View File

@@ -35,11 +35,17 @@ void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &baton) {
const size_t size = ftell(file);
fseek(file, 0, SEEK_SET);
baton->response->data.resize(size);
fread(&baton->response->data[0], size, 1, file);
const size_t read = fread(&baton->response->data[0], 1, size, file);
fclose(file);
baton->response->code = 200;
baton->type = HTTPResponseType::Successful;
if (read == size) {
baton->response->code = 200;
baton->type = HTTPResponseType::Successful;
} else {
baton->response->code = 500;
baton->type = HTTPResponseType::PermanentError;
baton->response->message = "Read bytes differed from file size";
}
} else {
baton->type = HTTPResponseType::PermanentError;
baton->response->code = 404;

View File

@@ -35,8 +35,8 @@ TEST_P(HeadlessTest, render) {
// Parse style.
rapidjson::Document styleDoc;
styleDoc.Parse<0>((const char *const)style.c_str());
ASSERT_EQ(false, styleDoc.HasParseError());
ASSERT_EQ(true, styleDoc.IsObject());
ASSERT_FALSE(styleDoc.HasParseError());
ASSERT_TRUE(styleDoc.IsObject());
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
@@ -46,16 +46,16 @@ TEST_P(HeadlessTest, render) {
// Parse settings.
rapidjson::Document infoDoc;
infoDoc.Parse<0>((const char *const)info.c_str());
ASSERT_EQ(false, infoDoc.HasParseError());
ASSERT_EQ(true, infoDoc.IsObject());
ASSERT_FALSE(infoDoc.HasParseError());
ASSERT_TRUE(infoDoc.IsObject());
Log::Set<FixtureLogBackend>();
for (auto it = infoDoc.MemberBegin(), end = infoDoc.MemberEnd(); it != end; it++) {
const std::string name { it->name.GetString(), it->name.GetStringLength() };
const rapidjson::Value &value = it->value;
ASSERT_EQ(true, value.IsObject());
if (value.HasMember("center")) ASSERT_EQ(true, value["center"].IsArray());
ASSERT_TRUE(value.IsObject());
if (value.HasMember("center")) ASSERT_TRUE(value["center"].IsArray());
const std::string actual_image = base_directory + "tests/" + base + "/" + name + "/actual.png";
@@ -70,10 +70,10 @@ TEST_P(HeadlessTest, render) {
std::vector<std::string> classes;
if (value.HasMember("classes")) {
const rapidjson::Value &js_classes = value["classes"];
ASSERT_EQ(true, js_classes.IsArray());
ASSERT_TRUE(js_classes.IsArray());
for (rapidjson::SizeType i = 0; i < js_classes.Size(); i++) {
const rapidjson::Value &js_class = js_classes[i];
ASSERT_EQ(true, js_class.IsString());
ASSERT_TRUE(js_class.IsString());
classes.push_back({ js_class.GetString(), js_class.GetStringLength() });
}
}

View File

@@ -34,8 +34,8 @@ TEST_P(StyleParserTest, ParseStyle) {
// Parse settings.
rapidjson::Document doc;
doc.Parse<0>((const char *const)info.c_str());
ASSERT_EQ(false, doc.HasParseError());
ASSERT_EQ(true, doc.IsObject());
ASSERT_FALSE(doc.HasParseError());
ASSERT_TRUE(doc.IsObject());
std::ifstream stylefile(style_path);
ASSERT_TRUE(stylefile.good());

View File

@@ -10,14 +10,9 @@
'direct_dependent_settings': {
'conditions': [
['OS == "mac"', {
'link_settings': {
'libraries': [
'-framework OpenGL',
],
},
'xcode_settings': {
'OTHER_LDFLAGS': [
'-framework OpenGL',
'<@(glfw3_libraries)', # This is a hack since we're not actually using GLFW
],
},
}, {
@@ -62,9 +57,6 @@
"target_name": "rotation_range",
"product_name": "test_rotation_range",
"type": "executable",
"libraries": [
"-lpthread",
],
"sources": [
"./main.cpp",
"./rotation_range.cpp",
@@ -78,9 +70,6 @@
"target_name": "clip_ids",
"product_name": "test_clip_ids",
"type": "executable",
"libraries": [
"-lpthread",
],
"sources": [
"./main.cpp",
"./clip_ids.cpp",
@@ -94,9 +83,6 @@
"target_name": "enums",
"product_name": "test_enums",
"type": "executable",
"libraries": [
"-lpthread",
],
"sources": [
"./main.cpp",
"./enums.cpp",
@@ -110,9 +96,6 @@
"target_name": "style_parser",
"product_name": "test_style_parser",
"type": "executable",
"libraries": [
"-lpthread",
],
"sources": [
"./main.cpp",
"./style_parser.cpp",
@@ -129,9 +112,6 @@
"target_name": "variant",
"product_name": "test_variant",
"type": "executable",
"libraries": [
"-lpthread",
],
"sources": [
"./main.cpp",
"./variant.cpp",
@@ -145,9 +125,6 @@
"target_name": "comparisons",
"product_name": "test_comparisons",
"type": "executable",
"libraries": [
"-lpthread",
],
"sources": [
"./main.cpp",
"./comparisons.cpp",
@@ -161,9 +138,6 @@
"target_name": "tile",
"product_name": "test_tile",
"type": "executable",
"libraries": [
"-lpthread",
],
"sources": [
"./main.cpp",
"./tile.cpp",
@@ -177,9 +151,6 @@
"target_name": "functions",
"product_name": "test_functions",
"type": "executable",
"libraries": [
"-lpthread",
],
"sources": [
"./main.cpp",
"./functions.cpp",
@@ -193,9 +164,6 @@
"target_name": "headless",
"product_name": "test_headless",
"type": "executable",
"libraries": [
"-lpthread",
],
"sources": [
"./main.cpp",
"./headless.cpp",