diff --git a/.gitmodules b/.gitmodules index 863c7f66f..ac1fc38e6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "vendor/mbgl"] path = vendor/mbgl - url = https://github.com/mapbox/mapbox-gl-native.git + url = git@github.com:mapbox/mapbox-gl-native.git diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..b1cbefbf3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +language: cpp + +matrix: + include: + - os: linux + compiler: clang + - os: linux + compiler: gcc + env: JOBS=8 + - os: osx + compiler: clang + +env: + global: + - NODE_NVM_VERSION: "0.10" + - LD_LIBRARY_PATH: "/usr/local/lib" + - secure: jkwZnKr5dcM9MQ6mOytnp6FHkbydSfa1L8d4jFp4v4K6Ee/iQh1YIq9c/J1zC0WLyuGokVGaijkKr6CW4nGZ5H8ygBtPo09imnRyH8X0bO5mEjl+KhbpdFqkXVLerpnAGMO7D6+6BtWJlK5uTDWhpeS7YayB3YfETVkllf4n6F8= + - secure: ZBiq+KPVM72MF0rtvpui5l7curGXckz4Pefc1L04U6dd/MPa22StvCgXBG7DKhLwI5OgHE1da769asQ3rub/pDOonxAi7fHo3+r/ocbSBZeeaj+p5i5wavppOzD27gCLrpOnSQBk0DfoD+xOM8ZCfIttBbOBMRZ1dpWFG98bJ4c= + +before_install: +- ./scripts/install_nvm.sh +- cd ./vendor/mbgl && source ./scripts/local_mason.sh && cd ../../ +- source ./vendor/mbgl/scripts/travis_helper.sh +- source ./vendor/mbgl/scripts/flags.sh +- source ./vendor/mbgl/scripts/travis_before_install.sh +- if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then export LD_LIBRARY_PATH=`mason prefix mesa 10.4.3`/lib:$LD_LIBRARY_PATH; glxinfo; fi + +install: +- npm install + +before_script: +# Set the core file limit to unlimited so a core file is generated upon crash +- ulimit -c unlimited -S + +script: +- ./scripts/travis_test.sh + +after_success: +- ./scripts/travis_publish.sh + +git: + submodules: true diff --git a/Makefile b/Makefile index 71586c843..b1756f017 100644 --- a/Makefile +++ b/Makefile @@ -8,12 +8,16 @@ endif ifeq ($(shell uname -s), Darwin) HOST ?= osx +ifeq ($(JOBS),) JOBS = $(shell sysctl -n hw.ncpu) endif +endif ifeq ($(shell uname -s), Linux) HOST ?= linux +ifeq ($(JOBS),) JOBS = $(shell nproc) endif +endif # Explicitly disable the default FileSource implementation ASSET = none @@ -26,7 +30,7 @@ global: build .PHONY: build build: build/Makefile - @node-gyp build $(DEBUG_FLAG) -- -j$(JOBS) + @node-gyp build $(DEBUG_FLAG) --clang -- -j$(JOBS) .PHONY: vendor/mbgl vendor/mbgl: @@ -34,7 +38,7 @@ vendor/mbgl: .PHONY: build/Makefile build/Makefile: $(MBGL)/config/$(HOST).gypi - @node-gyp configure -- \ + @node-gyp configure --clang -- \ -Dmbgl=$(MBGL) \ -Dhost=$(HOST) \ -I$(MBGL)/config/$(HOST).gypi \ @@ -52,4 +56,4 @@ test: build .PHONY: clean clean: rm -rf build - rm $(MBGL)/config.gypi + rm -f $(MBGL)/config/$(HOST).gypi diff --git a/binding.gyp b/binding.gyp index 0d4922fad..fb1839390 100644 --- a/binding.gyp +++ b/binding.gyp @@ -23,24 +23,27 @@ 'variables': { 'cflags_cc': [ - '-std=c++11', - '-stdlib=libc++', - '-Wno-unused-parameter' + '-Wno-unused-parameter', ], }, 'conditions': [ ['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.7', 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], - 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES' + 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', } }, { 'cflags_cc': [ - '<@(cflags_cc)', + '-std=c++11', '-fexceptions', + '<@(cflags_cc)', ], + 'libraries': [ '<@(glfw3_ldflags)' ], }] ], }, @@ -56,4 +59,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/scripts/deploy_results.sh b/scripts/deploy_results.sh new file mode 100755 index 000000000..6a5bbd0ff --- /dev/null +++ b/scripts/deploy_results.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then + (cd ./node_modules/mapbox-gl-test-suite/ && ./bin/deploy_results.sh) +fi diff --git a/scripts/install_nvm.sh b/scripts/install_nvm.sh new file mode 100755 index 000000000..1f68af710 --- /dev/null +++ b/scripts/install_nvm.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +git clone git@github.com:creationix/nvm.git ../.nvm +source ../.nvm/nvm.sh +nvm install $NODE_NVM_VERSION +nvm use $NODE_NVM_VERSION +node --version +npm --version diff --git a/scripts/travis_publish.sh b/scripts/travis_publish.sh new file mode 100755 index 000000000..17f4b1f17 --- /dev/null +++ b/scripts/travis_publish.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e + +# Inspect binary. +if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then + ldd ./lib/mbgl.node +else + otool -L ./lib/mbgl.node +fi + +COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n') + +if test "${COMMIT_MESSAGE#*'[publish binary]'}" != "$COMMIT_MESSAGE" && [[ $CXX == "clang++" ]]; then + npm install aws-sdk + + ./node_modules/.bin/node-pre-gyp package + + if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then + ./node_modules/.bin/node-pre-gyp testpackage + fi + + ./node_modules/.bin/node-pre-gyp publish info + + if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then + rm -rf build + rm -rf lib + npm install --fallback-to-build=false + npm test + fi +fi diff --git a/scripts/travis_test.sh b/scripts/travis_test.sh new file mode 100755 index 000000000..707293505 --- /dev/null +++ b/scripts/travis_test.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +# Travis OS X has no GPU +if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then + npm test + # ./scripts/deploy_results.sh +fi diff --git a/src/node_map_render_worker.cpp b/src/node_map_render_worker.cpp index d117a6c9a..6079e8a8c 100644 --- a/src/node_map_render_worker.cpp +++ b/src/node_map_render_worker.cpp @@ -19,7 +19,6 @@ void NodeMap::RenderWorker::Execute() { try { nodeMap->view.resize(options->width, options->height, options->ratio); nodeMap->map.setAccessToken(options->accessToken); - nodeMap->map.resize(options->width, options->height, options->ratio); nodeMap->map.setClasses(options->classes); nodeMap->map.setLonLatZoom(options->longitude, options->latitude, options->zoom); nodeMap->map.setBearing(options->bearing); diff --git a/travis/travis-resources.template b/travis/travis-resources.template new file mode 100644 index 000000000..8f07f1cf2 --- /dev/null +++ b/travis/travis-resources.template @@ -0,0 +1,108 @@ + +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Description": "node-mapbox-gl-native travis resources", + "Resources": { + "BuildUser": { + "Type": "AWS::IAM::User", + "Properties": { + "Policies": [ + { + "PolicyName": "build", + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:DeleteObject", + "s3:GetObject", + "s3:GetObjectAcl", + "s3:PutObject", + "s3:PutObjectAcl" + ], + "Resource": [ + "arn:aws:s3:::mapbox-node-binary/mapbox-gl-native/*" + ], + "Effect": "Allow" + } + ] + } + }, + { + "PolicyName": "build-testing", + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:DeleteObject", + "s3:GetObject", + "s3:GetObjectAcl", + "s3:PutObject", + "s3:PutObjectAcl" + ], + "Effect": "Allow", + "Resource": [ + "arn:aws:s3:::mapbox-gl-testing/*" + ] + } + ] + } + }, + "PolicyName": "list", + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:ListBucket" + ], + "Resource": [ + "arn:aws:s3:::mapbox-node-binary" + ], + "Effect": "Allow" + } + ] + } + { + "PolicyName": "list-testing", + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:ListBucket" + ], + "Effect": "Allow", + "Resource": [ + "arn:aws:s3:::mapbox-gl-testing" + ] + } + ] + } + } + ] + } + }, + "BuildUserKey": { + "Type": "AWS::IAM::AccessKey", + "Properties": { + "UserName": { + "Ref": "BuildUser" + } + } + } + }, + "Outputs": { + "AccessKeyId": { + "Value": { + "Ref": "BuildUserKey" + } + }, + "SecretAccessKey": { + "Value": { + "Fn::GetAtt": [ + "BuildUserKey", + "SecretAccessKey" + ] + } + } + } +} + diff --git a/vendor/mbgl b/vendor/mbgl index 8422b8b8a..eac5f6f45 160000 --- a/vendor/mbgl +++ b/vendor/mbgl @@ -1 +1 @@ -Subproject commit 8422b8b8a84d10f9c69c9295d1070eeb22d46db8 +Subproject commit eac5f6f4540d8adb29230ef07ac46a3306abb421