diff --git a/.gitignore b/.gitignore index d8959d4f3..833025085 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ /test/build /test/node_modules /test/fixtures/*/*_actual.* +/test/fixtures/database/*.db /include/mbgl/shader/shaders.hpp /src/shader/shaders_gl.cpp /src/shader/shaders_gles2.cpp diff --git a/.gitmodules b/.gitmodules index 9e5265a6a..6a4b1d516 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,7 +12,7 @@ [submodule "test/ios/KIF"] path = test/ios/KIF - url = https://github.com/mapbox/KIF.git + url = https://github.com/kif-framework/KIF.git [submodule "platform/ios/vendor/SMCalloutView"] path = platform/ios/vendor/SMCalloutView diff --git a/.mason b/.mason index 03869fd11..c43967404 160000 --- a/.mason +++ b/.mason @@ -1 +1 @@ -Subproject commit 03869fd11e4bc619d3ba7e4f8a1f00d4612c90ea +Subproject commit c43967404c84d020d63f6aba450d97770dfeaebb diff --git a/.travis.yml b/.travis.yml index 690b2b1b6..a98045c50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,95 +1,99 @@ -language: cpp +language: android + +sudo: false matrix: exclude: - os: linux include: - os: linux - env: CONFIG=release MASON_PLATFORM=android MASON_ANDROID_ABI=arm-v7 TESTMUNK=yes - compiler: clang + env: FLAVOR=linux CXX=g++-4.8 BUILDTYPE=Release + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'gdb', 'g++-4.8', 'gcc-4.8', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ] - os: linux - env: CONFIG=debug MASON_PLATFORM=android MASON_ANDROID_ABI=arm-v7 TESTMUNK=no - compiler: clang + env: FLAVOR=linux CXX=clang++ BUILDTYPE=Debug + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'gdb', 'libgcc-4.8-dev', 'libstdc++-4.8-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ] - os: linux - env: CONFIG=release MASON_PLATFORM=android MASON_ANDROID_ABI=arm-v5 TESTMUNK=no - compiler: clang - - os: linux - env: CONFIG=release MASON_PLATFORM=android MASON_ANDROID_ABI=arm-v8 TESTMUNK=no - compiler: clang - - os: linux - env: CONFIG=release MASON_PLATFORM=android MASON_ANDROID_ABI=x86 TESTMUNK=no - compiler: clang - - os: linux - env: CONFIG=release MASON_PLATFORM=android MASON_ANDROID_ABI=mips TESTMUNK=no - compiler: clang - - os: linux - env: CONFIG=release MASON_PLATFORM=android MASON_ANDROID_ABI=mips-64 TESTMUNK=no - compiler: clang - - os: linux - env: BUILDTYPE=Release JOBS=16 - compiler: clang - - os: linux - env: BUILDTYPE=Debug JOBS=16 - compiler: clang - - os: linux - env: BUILDTYPE=Release JOBS=8 - compiler: gcc + env: FLAVOR=linux CXX=clang++ BUILDTYPE=Release + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'gdb', 'libgcc-4.8-dev', 'libstdc++-4.8-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ] - os: osx - env: BUILDTYPE=Debug JOBS=8 MASON_PLATFORM=osx - compiler: clang + env: FLAVOR=osx BUILDTYPE=Debug - os: osx - env: BUILDTYPE=Release JOBS=8 MASON_PLATFORM=ios - compiler: clang + env: FLAVOR=ios BUILDTYPE=Release + - os: linux + env: FLAVOR=android ANDROID_ABI=arm-v7 BUILDTYPE=Release + android: + components: [ 'build-tools-22.0.0', 'android-22', 'extra' ] + addons: + apt: + packages: [ 'lib32stdc++6' ] + - os: linux + env: FLAVOR=android ANDROID_ABI=arm-v7 BUILDTYPE=Debug + android: + components: [ 'build-tools-22.0.0', 'android-22', 'extra' ] + addons: + apt: + packages: [ 'lib32stdc++6' ] + - os: linux + env: FLAVOR=android ANDROID_ABI=arm-v8 BUILDTYPE=Release + android: + components: [ 'build-tools-22.0.0', 'android-22', 'extra' ] + addons: + apt: + packages: [ 'lib32stdc++6' ] + - os: linux + env: FLAVOR=android ANDROID_ABI=x86 BUILDTYPE=Release + android: + components: [ 'build-tools-22.0.0', 'android-22', 'extra' ] + addons: + apt: + packages: [ 'lib32stdc++6' ] + - os: linux + env: FLAVOR=android ANDROID_ABI=mips BUILDTYPE=Release + android: + components: [ 'build-tools-22.0.0', 'android-22', 'extra' ] + addons: + apt: + packages: [ 'lib32stdc++6' ] env: global: - - secure: "MZHblLZXG/jWf2w0ZFlxCLDwx2qtGgRDODQyg1BR7JIuMz6AtWv8XR/sUczWLbiABCL0a/NzJF1g4v2pI7X69IntcjOdIABBgTh7++6+1TJ0Kp8viEltb55nQG3lHy/R6fOaI7Pj9tuCX0PCRtGA5C/fGnodLGEjy3RVOJ09ln0=" - - secure: "KaSQbhgjtV7ZCkesHmvrNsbQVjk5SPfGKB1VkWenRGYhLF45HpSRNwSxMQddZ566Pg7qIFgF1iWl/B0QW3B6AWL5WmzQ5AOJgwS876pNIc/UT7ubMPtgAtjpvw1bQvQP3B8MrB+3OE5c6tD+a3LhR9krV//dOsfErR5Yy+3Mbkc=" - - ANDROID_BUILD_INSTANCE_PROFILE: arn:aws:iam::234858372212:instance-profile/android-gl-build/travis/instance-profile/travis-mapbox-gl-native-AndroidInstanceProfile-13EA815DD8IQ9 - - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" - - secure: "CHBiUM60TolDbQnn+4IRA/tvOKwKs3g9EDvv8YHSJMg3FuHmjKQkprBasvxf3hnTXg4WLZEubmeDcyJ6RRzPP5mMSr/hksYl0pSjj/6TUecE5fHPVVeN7txVqkpOBf9i45Y+iBUQMjBb1NnDK3pHXxpnAs1Q/pe7vReErj4GF1U=" - - LD_LIBRARY_PATH: '/usr/local/lib' - - TERM: dumb - # begin iOS code signing - - secure: "I6Iu75X1E+js5tzijtKi1EGtIuBcA4/25nDYe0svV4HAtujY71ZJZ4eB6355CKhFXpLXrF3i7eKVX3v+zWS0QROPEWacgsqsvNg+Ba9cnznW/faUSOYekCfhzWd/6reYDM7KzKAQwSUHLk9JIWK/kkmi4r+vVJK7h+tjPllK5YA=" - - IOS_APP_NAME="Mapbox GL" - - 'IOS_DEVELOPER_NAME="iPhone Distribution: Mapbox, Inc."' - - IOS_PROFILE_NAME="ios-in-house" - - secure: "nQqSM8rd7OHtV4MqmNqVnkrVHqxKqQsaWRYk4/nPdhbeVWtTtkk0df711LrF1TUtbEPEewHxYUvTZ/UXmwJNeoKdzTHavI8hnatRkgjyxGERPn1il1Otelht9I+LQQHf+plrpRjVWBrNIW0Zox1B3cqn6d3NglpbXrEQ2EjYGNA=" - # end iOS code signing - -before_install: -- if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then sudo service mysql stop; fi -- if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then sudo service postgresql stop; fi -- source ./scripts/local_mason.sh -- source ./scripts/travis_helper.sh -- source ./scripts/install_node.sh -- source ./scripts/flags.sh -- ./scripts/travis_before_install.sh -- if [[ ${TRAVIS_OS_NAME} == "linux" && ${MASON_PLATFORM} != "android" ]]; then export LD_LIBRARY_PATH=`mason prefix mesa 10.4.3`/lib; fi -- if [[ ${TRAVIS_OS_NAME} == "linux" && ${MASON_PLATFORM} != "android" ]]; then glxinfo; fi + - TERM: dumb + # AWS + - secure: "MZHblLZXG/jWf2w0ZFlxCLDwx2qtGgRDODQyg1BR7JIuMz6AtWv8XR/sUczWLbiABCL0a/NzJF1g4v2pI7X69IntcjOdIABBgTh7++6+1TJ0Kp8viEltb55nQG3lHy/R6fOaI7Pj9tuCX0PCRtGA5C/fGnodLGEjy3RVOJ09ln0=" + - secure: "KaSQbhgjtV7ZCkesHmvrNsbQVjk5SPfGKB1VkWenRGYhLF45HpSRNwSxMQddZ566Pg7qIFgF1iWl/B0QW3B6AWL5WmzQ5AOJgwS876pNIc/UT7ubMPtgAtjpvw1bQvQP3B8MrB+3OE5c6tD+a3LhR9krV//dOsfErR5Yy+3Mbkc=" + # Access Token + - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" + # Testmunk + - secure: "CHBiUM60TolDbQnn+4IRA/tvOKwKs3g9EDvv8YHSJMg3FuHmjKQkprBasvxf3hnTXg4WLZEubmeDcyJ6RRzPP5mMSr/hksYl0pSjj/6TUecE5fHPVVeN7txVqkpOBf9i45Y+iBUQMjBb1NnDK3pHXxpnAs1Q/pe7vReErj4GF1U=" + # iOS code signing + - secure: "I6Iu75X1E+js5tzijtKi1EGtIuBcA4/25nDYe0svV4HAtujY71ZJZ4eB6355CKhFXpLXrF3i7eKVX3v+zWS0QROPEWacgsqsvNg+Ba9cnznW/faUSOYekCfhzWd/6reYDM7KzKAQwSUHLk9JIWK/kkmi4r+vVJK7h+tjPllK5YA=" + - IOS_APP_NAME="Mapbox GL" + - 'IOS_DEVELOPER_NAME="iPhone Distribution: Mapbox, Inc."' + - IOS_PROFILE_NAME="ios-in-house" + - secure: "nQqSM8rd7OHtV4MqmNqVnkrVHqxKqQsaWRYk4/nPdhbeVWtTtkk0df711LrF1TUtbEPEewHxYUvTZ/UXmwJNeoKdzTHavI8hnatRkgjyxGERPn1il1Otelht9I+LQQHf+plrpRjVWBrNIW0Zox1B3cqn6d3NglpbXrEQ2EjYGNA=" + - KIF_SCREENSHOTS="${TRAVIS_BUILD_DIR}/screenshots" install: -- ulimit -c - -before_script: - # Set the core file limit to unlimited so a core file is generated upon crash - - ulimit -c unlimited -S - # begin iOS code signing - - openssl aes-256-cbc -k "$IOS_ENCRYPTION_SECRET" -in scripts/ios_travis/ios-in-house.mobileprovision.enc -d -a -out scripts/ios_travis/ios-in-house.mobileprovision - - openssl aes-256-cbc -k "$IOS_ENCRYPTION_SECRET" -in scripts/ios_travis/ios-dist.cer.enc -d -a -out scripts/ios_travis/ios-dist.cer - - openssl aes-256-cbc -k "$IOS_ENCRYPTION_SECRET" -in scripts/ios_travis/ios-dist.p12.enc -d -a -out scripts/ios_travis/ios-dist.p12 - - ./scripts/ios_travis/add-key.sh - # end iOS code signing +- ./scripts/${FLAVOR}/install.sh script: -- ./scripts/travis_script.sh +- ./scripts/${FLAVOR}/run.sh -after_script: -- ./scripts/ios_travis/remove-key.sh +after_failure: +- "[ -f scripts/${FLAVOR}/run.sh ] && scripts/${FLAVOR}/run.sh" notifications: slack: secure: HHQYr7sF8M1SzoWSqgKVYtwAgGdLLCyTMsQjFhEEQNYO92ZwURE5s03qWTGH5k8+4Yqn26yrXt3NztLC4JIOpcGervN2mSZyq4dZgFTcWEd61igw0qwSenlwvFfbE1ASK/KYCzfyn9MIfHN+ovwLoRxXZkPwinKDvl3DXjBaFNg= + git: submodules: false diff --git a/Makefile b/Makefile index 14f78ed0f..3a2bd75c5 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,16 @@ PREFIX ?= /usr/local ANDROID_ABI ?= arm-v7 ifeq ($(shell uname -s), Darwin) -HOST ?= osx -HEADLESS ?= cgl +HOST = osx +HEADLESS = cgl JOBS ?= $(shell sysctl -n hw.ncpu) endif -HOST ?= linux + +ifeq ($(shell uname -s), Linux) +HOST = linux +JOBS ?= $(shell grep --count processor /proc/cpuinfo) +endif + JOBS ?= 1 all: mbgl @@ -26,52 +31,53 @@ config/%.gypi: configure styles/styles: git submodule update --init styles +ifeq ($(shell uname -s), Darwin) SMCalloutView: git submodule update --init platform/ios/vendor/SMCalloutView +else +SMCalloutView: +endif + +KIF: + git submodule update --init test/ios/KIF + + +#### Build files ############################################################### + +.PRECIOUS: Makefile/project +Makefile/project: config/$(HOST).gypi styles/styles SMCalloutView + deps/run_gyp gyp/$(HOST).gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f make + +.PRECIOUS: Xcode/project +Xcode/project: config/$(HOST).gypi styles/styles SMCalloutView + deps/run_gyp gyp/$(HOST).gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f xcode + #### Library builds ############################################################ -.PRECIOUS: Makefile/mbgl -Makefile/mbgl: config/$(HOST).gypi styles/styles SMCalloutView - deps/run_gyp mbgl.gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f make - -mbgl: Makefile/mbgl +mbgl: Makefile/project $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) everything -standalone: Makefile/mbgl +standalone: Makefile/project LINK=`pwd`/gyp/link.py $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) standalone -install: Makefile/mbgl +install: Makefile/project LINK=`pwd`/gyp/link.py $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) install -.PRECIOUS: Xcode/mbgl -Xcode/mbgl: config/$(HOST).gypi styles/styles SMCalloutView - deps/run_gyp mbgl.gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f xcode ##### Test builds ############################################################## -.PRECIOUS: Makefile/test -Makefile/test: test/test.gyp config/$(HOST).gypi styles/styles SMCalloutView - deps/run_gyp test/test.gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f make - .PHONY: test -test: Makefile/test +test: Makefile/project $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) test test-%: test ./scripts/run_tests.sh "build/$(HOST)/$(BUILDTYPE)/test" --gtest_filter=$* - -.PRECIOUS: Xcode/test -Xcode/test: test/test.gyp config/osx.gypi styles/styles SMCalloutView - deps/run_gyp test/test.gyp $(CONFIG_osx) $(LIBS_osx) --generator-output=./build/osx -f xcode - -.PHONY: lproj lbuild run-xlinux -xtest-proj: Xcode/test - open ./build/osx/test/test.xcodeproj - -xtest: Xcode/test - xcodebuild -project ./build/osx/test/test.xcodeproj -configuration $(BUILDTYPE) -target test -jobs $(JOBS) +.PHONY: xtest +xtest: XCPRETTY := $(shell ./scripts/xcpretty.sh) +xtest: Xcode/project + xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target test -jobs $(JOBS) $(XCPRETTY) xtest-%: xtest ./scripts/run_tests.sh "build/osx/Build/Products/$(BUILDTYPE)/test" --gtest_filter=$* @@ -79,31 +85,23 @@ xtest-%: xtest #### Mac OS X application builds ############################################### -.PRECIOUS: Makefile/osx -Makefile/osx: macosx/mapboxgl-app.gyp config/osx.gypi styles/styles - deps/run_gyp macosx/mapboxgl-app.gyp $(CONFIG_osx) $(LIBS_osx) --generator-output=./build/osx -f make - .PHONY: osx run-osx -osx: Makefile/osx +osx: Makefile/project $(MAKE) -C build/osx BUILDTYPE=$(BUILDTYPE) osxapp run-osx: osx "build/osx/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL" - -.PRECIOUS: Xcode/osx -Xcode/osx: macosx/mapboxgl-app.gyp config/osx.gypi styles/styles - deps/run_gyp macosx/mapboxgl-app.gyp $(CONFIG_osx) $(LIBS_osx) --generator-output=./build/osx -f xcode - .PHONY: xosx-proj xosx run-xosx -xosx-proj: Xcode/osx - open ./build/osx/macosx/mapboxgl-app.xcodeproj +xosx-proj: Xcode/project + open ./build/osx/gyp/osx.xcodeproj -xosx: Xcode/osx - xcodebuild -project ./build/osx/macosx/mapboxgl-app.xcodeproj -configuration $(BUILDTYPE) -target osxapp -jobs $(JOBS) +xosx: XCPRETTY := $(shell ./scripts/xcpretty.sh) +xosx: Xcode/project + xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target osxapp -jobs $(JOBS) $(XCPRETTY) run-xosx: xosx - "build/osx/Build/Products/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL" + "gyp/build/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL" # Legacy name xproj: xosx-proj @@ -113,21 +111,29 @@ xproj: xosx-proj #### iOS application builds #################################################### .PRECIOUS: Xcode/ios -Xcode/ios: ios/app/mapboxgl-app.gyp config/ios.gypi styles/styles SMCalloutView - deps/run_gyp ios/app/mapboxgl-app.gyp $(CONFIG_ios) $(LIBS_ios) --generator-output=./build/ios -f xcode +Xcode/ios: gyp/ios.gyp config/ios.gypi styles/styles SMCalloutView + deps/run_gyp gyp/ios.gyp $(CONFIG_ios) $(LIBS_ios) --generator-output=./build/ios -f xcode .PHONY: ios-proj ios isim ipackage ios-proj: Xcode/ios - open ./build/ios/ios/app/mapboxgl-app.xcodeproj + open ./build/ios/gyp/ios.xcodeproj +ios: XCPRETTY := $(shell ./scripts/xcpretty.sh) ios: Xcode/ios - xcodebuild -sdk iphoneos ARCHS="arm64 armv7 armv7s" PROVISIONING_PROFILE="2b532944-bf3d-4bf4-aa6c-a81676984ae8" -project ./build/ios/ios/app/mapboxgl-app.xcodeproj -configuration Release -target iosapp -jobs $(JOBS) + xcodebuild -sdk iphoneos ARCHS="arm64 armv7 armv7s" PROVISIONING_PROFILE="2b532944-bf3d-4bf4-aa6c-a81676984ae8" -project ./build/ios/gyp/ios.xcodeproj -configuration Release -target iosapp -jobs $(JOBS) $(XCPRETTY) +isim: XCPRETTY := $(shell ./scripts/xcpretty.sh) isim: Xcode/ios - xcodebuild -sdk iphonesimulator ARCHS="x86_64 i386" -project ./build/ios/ios/app/mapboxgl-app.xcodeproj -configuration Debug -target iosapp -jobs $(JOBS) + xcodebuild -sdk iphonesimulator ARCHS="x86_64 i386" -project ./build/ios/gyp/ios.xcodeproj -configuration Debug -target iosapp -jobs $(JOBS) $(XCPRETTY) ipackage: clean Xcode/ios - ./scripts/package_ios.sh + ./scripts/ios/package.sh + +ipackage-sim: clean Xcode/ios + ./scripts/ios/package.sh sim + +itest: ipackage-sim KIF + ./scripts/ios/test.sh # Legacy name iproj: ios-proj @@ -135,34 +141,20 @@ iproj: ios-proj #### Linux application builds ################################################## -.PRECIOUS: Makefile/linux -Makefile/linux: linux/mapboxgl-app.gyp config/$(HOST).gypi styles/styles - deps/run_gyp linux/mapboxgl-app.gyp $(CONFIG_$(HOST)) $(LIBS_linux) --generator-output=./build/$(HOST) -f make - .PHONY: linux run-linux -linux: Makefile/linux +linux: Makefile/project $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) linuxapp run-linux: linux (cd build/$(HOST)/$(BUILDTYPE) && ./mapbox-gl) - -.PRECIOUS: Xcode/linux -Xcode/linux: linux/mapboxgl-app.gyp config/osx.gypi styles/styles - deps/run_gyp linux/mapboxgl-app.gyp $(CONFIG_osx) $(LIBS_linux) --generator-output=./build/osx -f xcode - -.PHONY: lproj lbuild run-xlinux -xlinux-proj: Xcode/linux - open ./build/osx/linux/mapboxgl-app.xcodeproj - -xlinux: Xcode/linux - xcodebuild -project ./build/osx/linux/mapboxgl-app.xcodeproj -configuration $(BUILDTYPE) -target linuxapp +.PHONY: xlinux run-xlinux +xlinux: XCPRETTY := $(shell ./scripts/xcpretty.sh) +xlinux: Xcode/project + xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target linuxapp -jobs $(JOBS) $(XCPRETTY) run-xlinux: xlinux - "build/osx/Build/Products/$(BUILDTYPE)/mapbox-gl" - -# Legacy name -lproj: xlinux-proj + "gyp/build/$(BUILDTYPE)/mapbox-gl" #### Android libaries ######################################################### @@ -194,22 +186,15 @@ android-deploy: $(ANDROID_ABIS) android-project: android-lib + ##### Render builds ############################################################ -.PRECIOUS: Makefile/render -Makefile/render: bin/render.gyp config/$(HOST).gypi - deps/run_gyp bin/render.gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f make - -render: Makefile/render +render: Makefile/project $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) mbgl-render -.PRECIOUS: Xcode/render -Xcode/render: bin/render.gyp config/osx.gypi styles/styles - deps/run_gyp bin/render.gyp $(CONFIG_osx) $(LIBS_osx) --generator-output=./build/osx -f xcode - -.PHONY: xrender-proj -xrender-proj: Xcode/render - open ./build/osx/bin/render.xcodeproj +.PHONY: xrender run-xrender +xrender: Xcode/project + xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target mbgl-render -jobs $(JOBS) ##### Maintenace operations #################################################### diff --git a/README.md b/README.md index c423c21b5..06072f00f 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Target OS X: 10.9+ If you merely want to install the library for iOS and try it out as an Objective-C consumer: 0. Use [Homebrew](http://brew.sh/) to install Boost headers: `brew install boost`. -1. Run `./scripts/package_ios.sh`. The packaging script will produce the statically-linked `libMapboxGL.a`, `MapboxGL.bundle` for resources, and a `Headers` folder. +1. Run `make ipackage`. The packaging script will produce the statically-linked `libMapboxGL.a`, `MapboxGL.bundle` for resources, and a `Headers` folder. 2. Copy the contents of `build/ios/pkg/static` into your project. It should happen automatically, but ensure that: - `Headers` is in your *Header Search Paths* (`HEADER_SEARCH_PATHS`) build setting. - `MapboxGL.bundle` is in your target's *Copy Bundle Resources* build phase. @@ -68,11 +68,13 @@ If you merely want to install the library for iOS and try it out as an Objective 5. [Set the Mapbox API access token](#mapbox-api-access-tokens). 6. `#import "MapboxGL.h"` -If you want to build from source and/or contribute to development of the project, run `make iproj`, which will create and open an Xcode project which can build the entire library from source as well as an Objective-C test app. +If you want to build from source and/or contribute to development of the project, run `make iproj`, which will create and open an Xcode project which can build the entire library from source as well as an Objective-C test app. If you don't have an Apple Developer account, change the destination from "My Mac" to a simulator such as "iPhone 6" before you run and build the app. + +You can run `make itest` to run the included integration tests. Requires `gem install xcpretty`. If you want to run the tests in Xcode instead, first `make ipackage` to create a local static library version, then open `test/ios/ios-tests.xcodeproj`, and lastly `Command + U` on the `Mapbox GL Tests` application target. Target devices: iPhone 4S and above (5, 5c, 5s, 6, 6 Plus) and iPad 2 and above (3, 4, Mini, Air, Mini 2, Air 2). -Target iOS: 7.0 through 8.1 +Target iOS: 7.0 through latest 8.x. ## Linux @@ -84,6 +86,7 @@ Install GCC 4.8+ if you are running Ubuntu 13.10 or older. Alternatively, you ca sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-4.8 g++-4.8 + export CXX=g++-4.8 Ensure you have git and other build essentials: @@ -108,10 +111,6 @@ Otherwise, you can just install sudo apt-get install libboost-dev libboost-program-options-dev -Once you're done installing the build dependencies, you can get started by running - - ./configure - Then, you can then proceed to build the library: git submodule update --init diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp index ac5188484..2c7e75778 100644 --- a/android/cpp/jni.cpp +++ b/android/cpp/jni.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -255,20 +256,6 @@ void JNICALL nativeDestroySurface(JNIEnv *env, jobject obj, jlong nativeMapViewP nativeMapView->destroySurface(); } -void JNICALL nativeStart(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { - mbgl::Log::Debug(mbgl::Event::JNI, "nativeStart"); - assert(nativeMapViewPtr != 0); - NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->start(); -} - -void JNICALL nativeStop(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { - mbgl::Log::Debug(mbgl::Event::JNI, "nativeStop"); - assert(nativeMapViewPtr != 0); - NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->stop(); -} - void JNICALL nativePause(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { mbgl::Log::Debug(mbgl::Event::JNI, "nativePause"); assert(nativeMapViewPtr != 0); @@ -287,14 +274,7 @@ void JNICALL nativeUpdate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeUpdate"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->getMap().triggerUpdate(); -} - -void JNICALL nativeTerminate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { - mbgl::Log::Debug(mbgl::Event::JNI, "nativeTerminate"); - assert(nativeMapViewPtr != 0); - NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->getMap().terminate(); + nativeMapView->getMap().update(); } void JNICALL nativeResize(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jint width, jint height, @@ -310,7 +290,7 @@ void JNICALL nativeResize(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jint assert(fbWidth <= UINT16_MAX); assert(fbHeight <= UINT16_MAX); NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->resize(width, height, ratio, fbWidth, fbHeight); + nativeMapView->getMap().resize(width, height, ratio); } void JNICALL nativeRemoveClass(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jstring clazz) { @@ -938,12 +918,9 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { {"nativeCreateSurface", "(JLandroid/view/Surface;)V", reinterpret_cast(&nativeCreateSurface)}, {"nativeDestroySurface", "(J)V", reinterpret_cast(&nativeDestroySurface)}, - {"nativeStart", "(J)V", reinterpret_cast(&nativeStart)}, - {"nativeStop", "(J)V", reinterpret_cast(&nativeStop)}, {"nativePause", "(J)V", reinterpret_cast(&nativePause)}, {"nativeResume", "(J)V", reinterpret_cast(&nativeResume)}, {"nativeUpdate", "(J)V", reinterpret_cast(&nativeUpdate)}, - {"nativeTerminate", "(J)V", reinterpret_cast(&nativeTerminate)}, {"nativeResize", "(JIIFII)V", reinterpret_cast(static_cast(&nativeResize))}, diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp index 39a777bff..5f6b078a7 100644 --- a/android/cpp/native_map_view.cpp +++ b/android/cpp/native_map_view.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -16,6 +17,7 @@ #include #include +#include pthread_once_t loadGLExtensions = PTHREAD_ONCE_INIT; @@ -59,7 +61,7 @@ NativeMapView::NativeMapView(JNIEnv *env, jobject obj_) : mbgl::View(*this), fileCache(mbgl::android::cachePath + "/mbgl-cache.db"), fileSource(&fileCache), - map(*this, fileSource) { + map(*this, fileSource, MapMode::Continuous, true) { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::NativeMapView"); assert(env != nullptr); @@ -121,11 +123,11 @@ void NativeMapView::deactivate() { } } -void NativeMapView::invalidate() { +void NativeMapView::invalidate(std::function render) { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::invalidate"); if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE)) { - map.render(); + render(); if (!eglSwapBuffers(display, surface)) { mbgl::Log::Error(mbgl::Event::OpenGL, "eglSwapBuffers() returned error %d", @@ -576,23 +578,6 @@ EGLConfig NativeMapView::chooseConfig(const EGLConfig configs[], EGLint numConfi return configId; } -void NativeMapView::start() { - mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::start"); - - if (display == EGL_NO_DISPLAY) { - initializeDisplay(); - } - - if (context == EGL_NO_CONTEXT) { - initializeContext(); - } - - assert(display != EGL_NO_DISPLAY); - assert(context != EGL_NO_CONTEXT); - - map.start(true); -} - void loadExtensions() { const GLubyte *str = glGetString(GL_EXTENSIONS); if (str == nullptr) { @@ -689,14 +674,6 @@ void loadExtensions() { } } -void NativeMapView::stop() { - mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::stop"); - - if ((display != EGL_NO_DISPLAY) && (context != EGL_NO_CONTEXT)) { - map.stop(); - } -} - void NativeMapView::pause(bool waitForPause) { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::pause %s", (waitForPause) ? "true" : "false"); @@ -824,9 +801,5 @@ void NativeMapView::updateFps() { env = nullptr; } -void NativeMapView::resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight) { - View::resize(width, height, ratio, fbWidth, fbHeight); -} - } } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index f865f9144..da4b40c4c 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -419,7 +419,6 @@ public class MapView extends SurfaceView { mNativeMapView.initializeDisplay(); mNativeMapView.initializeContext(); - mNativeMapView.start(); } // Called when we need to save instance state @@ -441,7 +440,6 @@ public class MapView extends SurfaceView { // Called when we need to clean up // Must be called from Activity onDestroy public void onDestroy() { - mNativeMapView.stop(); mNativeMapView.terminateContext(); mNativeMapView.terminateDisplay(); } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java index 4dcd5ef8e..7f074c6db 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java @@ -73,14 +73,6 @@ class NativeMapView { nativeDestroySurface(mNativeMapViewPtr); } - public void start() { - nativeStart(mNativeMapViewPtr); - } - - public void stop() { - nativeStop(mNativeMapViewPtr); - } - public void pause() { nativePause(mNativeMapViewPtr); } @@ -386,18 +378,12 @@ class NativeMapView { private native void nativeDestroySurface(long nativeMapViewPtr); - private native void nativeStart(long nativeMapViewPtr); - - private native void nativeStop(long nativeMapViewPtr); - private native void nativePause(long nativeMapViewPtr); private native void nativeResume(long nativeMapViewPtr); private native void nativeUpdate(long nativeMapViewPtr); - private native void nativeTerminate(long nativeMapViewPtr); - private native void nativeResize(long nativeMapViewPtr, int width, int height, float ratio, int fbWidth, int fbHeight); diff --git a/android/scripts/build-debug.sh b/android/scripts/build-debug.sh deleted file mode 100755 index 450820a11..000000000 --- a/android/scripts/build-debug.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -export BUILDTYPE=Debug - -./android/scripts/common.sh $1 diff --git a/android/scripts/build-release.sh b/android/scripts/build-release.sh deleted file mode 100755 index 73c7fab81..000000000 --- a/android/scripts/build-release.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -export BUILDTYPE=Release - -./android/scripts/common.sh $1 diff --git a/android/scripts/common.sh b/android/scripts/common.sh deleted file mode 100755 index 0d610909b..000000000 --- a/android/scripts/common.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -NAME=$1 - -case `uname -s` in - 'Darwin') export JOBS=`sysctl -n hw.ncpu` ;; - 'Linux') export JOBS=`nproc` ;; - *) export JOBS=1 ;; -esac - - -export CC=clang CXX=clang++ -export MASON_PLATFORM=android - -mkdir -p ./android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw/ -echo "${MAPBOX_ACCESS_TOKEN}" >> ./android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt - -make android -j$JOBS BUILDTYPE=$BUILDTYPE JOBS=$JOBS - -S3_PREFIX=s3://mapbox/mapbox-gl-native/android/build/${NAME} -APK_OUTPUTS=./android/java/MapboxGLAndroidSDKTestApp/build/outputs/apk - -# Upload the shared object. -aws s3 cp \ - ./build/android-${ANDROID_ABI}/${BUILDTYPE}/lib.target/libmapbox-gl.so \ - ${S3_PREFIX}/libmapbox-gl.so - -# Upload either the debug or the release build -if [ ${BUILDTYPE} == "Debug" ] ; then - aws s3 cp \ - ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-debug.apk \ - ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-debug.apk -elif [ ${BUILDTYPE} == "Release" ] ; then - aws s3 cp \ - ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-release-unsigned.apk \ - ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-release-unsigned.apk -fi diff --git a/android/scripts/run-build.sh b/android/scripts/run-build.sh deleted file mode 100755 index 9fa15a02b..000000000 --- a/android/scripts/run-build.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -cwd=$(pwd) - -region="us-east-1" -region_ami="ami-022e0c6a" -sleep=10 -instance_name="android-gl-build-$TRAVIS_REPO_SLUG-$TRAVIS_JOB_NUMBER" -echo $ami_name - -NAME=$TRAVIS_JOB_ID - -user_data="#!/bin/bash - cd /android - git clone git://github.com/mapbox/mapbox-gl-native.git - - pushd mapbox-gl-native - if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then - git checkout $TRAVIS_COMMIT - else - git fetch origin +refs/pull/$TRAVIS_PULL_REQUEST/merge: - git checkout FETCH_HEAD - fi - git submodule update --init --recursive - - export ANDROID_NDK_PATH=/android/android-ndk-r10d - export JAVA_HOME=/android/jdk1.7.0_71 - export ANDROID_HOME=/android/android-sdk-linux - export PATH=\$PATH:/android/jdk1.7.0_71/bin - export MAPBOX_ACCESS_TOKEN=$MAPBOX_ACCESS_TOKEN - export TESTMUNK_KEY=$TESTMUNK_KEY - export TESTMUNK=$TESTMUNK - export MASON_ANDROID_ABI=$MASON_ANDROID_ABI - export ANDROID_ABI=$MASON_ANDROID_ABI - - if ./android/scripts/build-$CONFIG.sh $NAME &>../build.log; then - echo 'ANDROID BUILD PASSED' - else - echo 'ANDROID BUILD FAILED' - fi - popd - - aws s3 cp --region us-east-1 build.log s3://mapbox/mapbox-gl-native/android/build/${NAME}/build-log.txt - shutdown -P now" - -id=$(aws ec2 run-instances \ - --region $region \ - --image-id $region_ami \ - --count 1 \ - --instance-type m3.large \ - --iam-instance-profile Arn="$ANDROID_BUILD_INSTANCE_PROFILE" \ - --instance-initiated-shutdown-behavior terminate \ - --user-data "$user_data" | jq -r '.Instances[0].InstanceId') - -echo "Instance: $region $id" - -sleep 10 - -result=$(aws ec2 create-tags --region $region --resources $id --tags "Key=Name,Value=$instance_name") - -instance_status_terminated=$(aws ec2 describe-instances --region $region --instance-id $id | jq -r '.Reservations[0].Instances[0].State.Name') - -until [ "$instance_status_terminated" = "terminated" ]; do - instance_status_terminated=$(aws ec2 describe-instances --region $region --instance-id $id | jq -r '.Reservations[0].Instances[0].State.Name') - echo "Instance terminating status $region $id: $instance_status_terminated" - sleep $sleep -done - -echo "Build finished" - -output=$(aws ec2 get-console-output --region $region --instance-id $id | jq -r '.Output') - -aws s3 cp --region $region s3://mapbox/mapbox-gl-native/android/build/${NAME}/build-log.txt build.log -cat build.log - -if [[ $output == *"ANDROID BUILD PASSED"* ]]; then - echo "ANDROID BUILD PASSED" - exit 0 -else - echo "ANDROID BUILD FAILED" - exit 1 -fi diff --git a/bin/render.gyp b/bin/render.gypi similarity index 100% rename from bin/render.gyp rename to bin/render.gypi diff --git a/config/defaults.mk b/config/defaults.mk index 2aa11ccbe..1449bf8e1 100644 --- a/config/defaults.mk +++ b/config/defaults.mk @@ -31,32 +31,32 @@ LIBS_linux += -Dcache_lib=$(word 1,$(CACHE) sqlite) LIBS_linux += --depth=. -Goutput_dir=. ANDROID_ABIS += android-lib-arm-v8 -ENV_android-arm-v8 = $(shell MASON_ANDROID_ABI=arm-v8 ./scripts/android_env.sh) +ENV_android-arm-v8 = $(shell MASON_ANDROID_ABI=arm-v8 ./scripts/android/toolchain.sh) CONFIG_android-arm-v8 = -Dhost=android -Iconfig/android-arm-v8.gypi ANDROID_ABIS += android-lib-arm-v7 -ENV_android-arm-v7 = $(shell MASON_ANDROID_ABI=arm-v7 ./scripts/android_env.sh) +ENV_android-arm-v7 = $(shell MASON_ANDROID_ABI=arm-v7 ./scripts/android/toolchain.sh) CONFIG_android-arm-v7 = -Dhost=android -Iconfig/android-arm-v7.gypi ANDROID_ABIS += android-lib-arm-v5 -ENV_android-arm-v5 = $(shell MASON_ANDROID_ABI=arm-v5 ./scripts/android_env.sh) +ENV_android-arm-v5 = $(shell MASON_ANDROID_ABI=arm-v5 ./scripts/android/toolchain.sh) CONFIG_android-arm-v5 = -Dhost=android -Iconfig/android-arm-v5.gypi ANDROID_ABIS += android-lib-x86 -ENV_android-x86 = $(shell MASON_ANDROID_ABI=x86 ./scripts/android_env.sh) +ENV_android-x86 = $(shell MASON_ANDROID_ABI=x86 ./scripts/android/toolchain.sh) CONFIG_android-x86 = -Dhost=android -Iconfig/android-x86.gypi # OpenSSL build is incomplete. # ANDROID_ABIS += android-lib-x86-64 -# ENV_android-x86-64 = $(shell MASON_ANDROID_ABI=x86-64 ./scripts/android_env.sh) +# ENV_android-x86-64 = $(shell MASON_ANDROID_ABI=x86-64 ./scripts/android/toolchain.sh) # CONFIG_android-x86-64 = -Dhost=android -Iconfig/android-x86-64.gypi ANDROID_ABIS += android-lib-mips -ENV_android-mips = $(shell MASON_ANDROID_ABI=mips ./scripts/android_env.sh) +ENV_android-mips = $(shell MASON_ANDROID_ABI=mips ./scripts/android/toolchain.sh) CONFIG_android-mips = -Dhost=android -Iconfig/android-mips.gypi ANDROID_ABIS += android-lib-mips-64 -ENV_android-mips-64 = $(shell MASON_ANDROID_ABI=mips-64 ./scripts/android_env.sh) +ENV_android-mips-64 = $(shell MASON_ANDROID_ABI=mips-64 ./scripts/android/toolchain.sh) CONFIG_android-mips-64 = -Dhost=android -Iconfig/android-mips-64.gypi LIBS_android = -Dheadless_lib=none diff --git a/configure b/configure index 1d68f5e54..f49ea2189 100755 --- a/configure +++ b/configure @@ -15,7 +15,8 @@ function finish { trap finish EXIT # Install mason -. ./scripts/local_mason.sh +git submodule update --init .mason +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" case ${MASON_PLATFORM} in 'ios') @@ -44,7 +45,7 @@ case ${MASON_PLATFORM} in LIBCURL_VERSION=system LIBUV_VERSION=0.10.28 ZLIB_VERSION=system - BOOST_VERSION=system + BOOST_VERSION=1.57.0 NUNICODE_VERSION=1.5.1 LIBZIP_VERSION=0.11.2 ;; diff --git a/docker/linux/test.sh b/docker/linux/test.sh deleted file mode 100755 index 9ef9bf51f..000000000 --- a/docker/linux/test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -export TRAVIS_OS_NAME=linux - -cd build - -source ./scripts/local_mason.sh -mason install mesa 10.4.3 -export LD_LIBRARY_PATH=`mason prefix mesa 10.4.3`/lib - -export DISPLAY=:99.0 -Xvfb :99 -ac -screen 0 1024x768x24 & - -if [[ ${CXX} == "g++" ]]; then - export CXX="g++-4.8" - export CC="gcc-4.8" -fi - -source ./scripts/install_node.sh - -make linux -j`nproc` -make test-* -j`nproc` -./scripts/compare_images.sh diff --git a/gyp/ios.gyp b/gyp/ios.gyp new file mode 100644 index 000000000..989f34cb7 --- /dev/null +++ b/gyp/ios.gyp @@ -0,0 +1,5 @@ +{ + 'includes': [ + '../ios/app/mapboxgl-app.gypi', + ], +} diff --git a/gyp/linux.gyp b/gyp/linux.gyp new file mode 100644 index 000000000..0f7126934 --- /dev/null +++ b/gyp/linux.gyp @@ -0,0 +1,7 @@ +{ + 'includes': [ + '../linux/mapboxgl-app.gypi', + '../test/test.gypi', + '../bin/render.gypi', + ], +} diff --git a/gyp/osx.gyp b/gyp/osx.gyp new file mode 100644 index 000000000..64663540b --- /dev/null +++ b/gyp/osx.gyp @@ -0,0 +1,8 @@ +{ + 'includes': [ + '../macosx/mapboxgl-app.gypi', + '../linux/mapboxgl-app.gypi', + '../test/test.gypi', + '../bin/render.gypi', + ], +} diff --git a/gyp/platform-android.gypi b/gyp/platform-android.gypi index bfaac7d4f..7701393bb 100644 --- a/gyp/platform-android.gypi +++ b/gyp/platform-android.gypi @@ -12,6 +12,7 @@ 'sources': [ '../platform/android/log_android.cpp', '../platform/android/asset_root.cpp', + '../platform/default/thread.cpp', '../platform/default/string_stdlib.cpp', '../platform/default/image.cpp', '../platform/default/image_reader.cpp', diff --git a/gyp/platform-ios.gypi b/gyp/platform-ios.gypi index 305fd5284..1f96f9470 100644 --- a/gyp/platform-ios.gypi +++ b/gyp/platform-ios.gypi @@ -15,6 +15,7 @@ '../platform/darwin/application_root.mm', '../platform/darwin/asset_root.mm', '../platform/darwin/image.mm', + '../platform/darwin/nsthread.mm', '../platform/darwin/reachability.m', '../include/mbgl/ios/MapboxGL.h', '../include/mbgl/ios/MGLMapboxEvents.h', @@ -22,6 +23,8 @@ '../include/mbgl/ios/MGLMapView.h', '../include/mbgl/ios/MGLMapView+IBAdditions.h', '../platform/ios/MGLMapView.mm', + '../platform/ios/MGLFileCache.h', + '../platform/ios/MGLFileCache.mm', '../include/mbgl/ios/MGLAccountManager.h', '../platform/ios/MGLAccountManager.m', '../include/mbgl/ios/MGLAnnotation.h', @@ -33,6 +36,9 @@ '../include/mbgl/ios/MGLMetricsLocationManager.h', '../platform/ios/MGLMetricsLocationManager.m', '../include/mbgl/ios/MGLTypes.h', + '../platform/ios/NSBundle+MGLAdditions.h', + '../platform/ios/NSBundle+MGLAdditions.m', + '../platform/ios/NSException+MGLAdditions.h', '../platform/ios/NSProcessInfo+MGLAdditions.h', '../platform/ios/NSProcessInfo+MGLAdditions.m', '../platform/ios/NSString+MGLAdditions.h', diff --git a/gyp/platform-linux.gypi b/gyp/platform-linux.gypi index 30715f828..394433870 100644 --- a/gyp/platform-linux.gypi +++ b/gyp/platform-linux.gypi @@ -14,6 +14,7 @@ '../platform/default/string_stdlib.cpp', '../platform/default/application_root.cpp', '../platform/default/asset_root.cpp', + '../platform/default/thread.cpp', '../platform/default/image.cpp', '../platform/default/image_reader.cpp', '../platform/default/png_reader.cpp', diff --git a/gyp/platform-osx.gypi b/gyp/platform-osx.gypi index 6d6c35b29..ae5194761 100644 --- a/gyp/platform-osx.gypi +++ b/gyp/platform-osx.gypi @@ -15,6 +15,7 @@ '../platform/darwin/application_root.mm', '../platform/darwin/asset_root.mm', '../platform/darwin/image.mm', + '../platform/darwin/nsthread.mm', ], 'variables': { diff --git a/include/mbgl/android/native_map_view.hpp b/include/mbgl/android/native_map_view.hpp index 14ccaba3f..a050ad149 100644 --- a/include/mbgl/android/native_map_view.hpp +++ b/include/mbgl/android/native_map_view.hpp @@ -23,7 +23,7 @@ public: void activate() override; void deactivate() override; void notify() override; - void invalidate() override; + void invalidate(std::function render) override; void notifyMapChange(mbgl::MapChange change, Duration delay = Duration::zero()) override; @@ -39,17 +39,12 @@ public: void createSurface(ANativeWindow *window); void destroySurface(); - void start(); - void stop(); - void resume(); void pause(bool waitForPause = false); void enableFps(bool enable); void updateFps(); - void resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight); - private: EGLConfig chooseConfig(const EGLConfig configs[], EGLint numConfigs); diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h index e6aaee9a0..cf1eeb8a7 100644 --- a/include/mbgl/ios/MGLMapView.h +++ b/include/mbgl/ios/MGLMapView.h @@ -49,11 +49,6 @@ IB_DESIGNABLE /** @name Managing Constraints */ -/** A view controller whose top and bottom layout guides to use for proper setup of constraints in the map view internals. -* -* Certain components of the map view, such as the heading compass and the data attribution button, need to be aware of the view controller layout in order to avoid positioning content under a top navigation bar or a bottom toolbar. */ -@property (nonatomic, weak) IBOutlet UIViewController *viewControllerForLayoutGuides; - #pragma mark - Accessing Map Properties /** @name Accessing Map Properties */ diff --git a/include/mbgl/ios/MGLMapboxEvents.h b/include/mbgl/ios/MGLMapboxEvents.h index 7a4c45fe1..c70c7cb33 100644 --- a/include/mbgl/ios/MGLMapboxEvents.h +++ b/include/mbgl/ios/MGLMapboxEvents.h @@ -4,6 +4,7 @@ extern NSString *const MGLEventTypeMapLoad; extern NSString *const MGLEventTypeMapTap; extern NSString *const MGLEventTypeMapDragEnd; extern NSString *const MGLEventTypeLocation; +extern NSString *const MGLEventTypeVisit; extern NSString *const MGLEventKeyLatitude; extern NSString *const MGLEventKeyLongitude; @@ -16,6 +17,8 @@ extern NSString *const MGLEventKeyVerticalAccuracy; extern NSString *const MGLEventKeyPushEnabled; extern NSString *const MGLEventKeyEmailEnabled; extern NSString *const MGLEventKeyGestureID; +extern NSString *const MGLEventKeyArrivalDate; +extern NSString *const MGLEventKeyDepartureDate; extern NSString *const MGLEventGestureSingleTap; extern NSString *const MGLEventGestureDoubleTap; @@ -32,6 +35,7 @@ extern NSString *const MGLEventGestureRotateStart; + (void) setToken:(NSString *)token; + (void) setAppName:(NSString *)appName; + (void) setAppVersion:(NSString *)appVersion; ++ (void) setAppBuildNumber:(NSString *)appBuildNumber; + (void) pauseMetricsCollection; + (void) resumeMetricsCollection; diff --git a/include/mbgl/ios/MGLMetricsLocationManager.h b/include/mbgl/ios/MGLMetricsLocationManager.h index 5f3b56818..f02c76f53 100644 --- a/include/mbgl/ios/MGLMetricsLocationManager.h +++ b/include/mbgl/ios/MGLMetricsLocationManager.h @@ -5,7 +5,9 @@ // These methods can be called from any thread. // + (instancetype)sharedManager; -+ (void) startUpdatingLocation; -+ (void) stopUpdatingLocation; +- (void) startUpdatingLocation; +- (void) stopUpdatingLocation; +- (void) startMonitoringVisits; +- (void) stopMonitoringVisits; @end diff --git a/include/mbgl/map/environment.hpp b/include/mbgl/map/environment.hpp index 1cd33a5e6..07554a7a9 100644 --- a/include/mbgl/map/environment.hpp +++ b/include/mbgl/map/environment.hpp @@ -54,11 +54,6 @@ public: // Only call this while the OpenGL context is exclusive to this thread. void performCleanup(); - // ############################################################################################# - - // Request to terminate the environment. - void terminate(); - private: unsigned id; FileSource& fileSource; @@ -67,9 +62,6 @@ private: std::vector abandonedVAOs; std::vector abandonedBuffers; std::vector abandonedTextures; - -public: - uv_loop_t* const loop; }; class EnvironmentScope final { diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index f9738debe..a15da5178 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -1,96 +1,57 @@ #ifndef MBGL_MAP_MAP #define MBGL_MAP_MAP -#include #include #include +#include #include -#include #include -#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include - -namespace uv { class async; } +#include +#include namespace mbgl { -class Painter; -class GlyphStore; -class LayerDescription; -class Sprite; -class Style; -class StyleLayer; -class TexturePool; class FileSource; class View; -class GlyphAtlas; -class SpriteAtlas; -class LineAtlas; -class Environment; -class EnvironmentScope; -class AnnotationManager; class MapData; -class Worker; +class MapContext; class StillImage; +namespace util { +template class Thread; +} + class Map : private util::noncopyable { friend class View; public: - enum class Mode : uint8_t { - None, // we're not doing any processing - Continuous, // continually updating map - Still, // a once-off still image. - }; - - explicit Map(View&, FileSource&); + explicit Map(View&, FileSource&, + MapMode mode = MapMode::Continuous, + bool startPaused = false); ~Map(); - // Start the map render thread. It is asynchronous. - void start(bool startPaused = false, Mode mode = Mode::Continuous); - inline void start(Mode renderMode) { start(false, renderMode); } - - // Stop the map render thread. This call will block until the map rendering thread stopped. - // The optional callback function will be invoked repeatedly until the map thread is stopped. - // The callback function should wait until it is woken up again by view.notify(), otherwise - // this will be a busy waiting loop. - void stop(std::function callback = std::function()); - // Pauses the render thread. The render thread will stop running but will not be terminated and will not lose state until resumed. void pause(bool waitForPause = false); // Resumes a paused render thread void resume(); + // Register a callback that will get called (on the render thread) when all resources have + // been loaded and a complete render occurs. using StillImageCallback = std::function)>; void renderStill(StillImageCallback callback); // Triggers a synchronous or asynchronous render. void renderSync(); - - // Unconditionally performs a render with the current map state. May only be called from the Map - // thread. - void render(); + void renderAsync(); // Notifies the Map thread that the state has changed and an update might be necessary. - void triggerUpdate(Update = Update::Nothing); - - // Triggers a render. Can be called from any thread. - void triggerRender(); - - // Releases resources immediately - void terminate(); + void update(Update update = Update::Nothing); // Styling void addClass(const std::string&); @@ -134,18 +95,23 @@ public: double getBearing() const; void resetNorth(); + // Size + void resize(uint16_t width, uint16_t height, float ratio = 1); + uint16_t getWidth() const; + uint16_t getHeight() const; + // API void setAccessToken(const std::string &token); std::string getAccessToken() const; // Projection - inline void getWorldBoundsMeters(ProjectedMeters &sw, ProjectedMeters &ne) const { Projection::getWorldBoundsMeters(sw, ne); } - inline void getWorldBoundsLatLng(LatLng &sw, LatLng &ne) const { Projection::getWorldBoundsLatLng(sw, ne); } - inline double getMetersPerPixelAtLatitude(const double lat, const double zoom) const { return Projection::getMetersPerPixelAtLatitude(lat, zoom); } - inline const ProjectedMeters projectedMetersForLatLng(const LatLng latLng) const { return Projection::projectedMetersForLatLng(latLng); } - inline const LatLng latLngForProjectedMeters(const ProjectedMeters projectedMeters) const { return Projection::latLngForProjectedMeters(projectedMeters); } - inline const vec2 pixelForLatLng(const LatLng latLng) const { return state.pixelForLatLng(latLng); } - inline const LatLng latLngForPixel(const vec2 pixel) const { return state.latLngForPixel(pixel); } + void getWorldBoundsMeters(ProjectedMeters &sw, ProjectedMeters &ne) const; + void getWorldBoundsLatLng(LatLng &sw, LatLng &ne) const; + double getMetersPerPixelAtLatitude(const double lat, const double zoom) const; + const ProjectedMeters projectedMetersForLatLng(const LatLng latLng) const; + const LatLng latLngForProjectedMeters(const ProjectedMeters projectedMeters) const; + const vec2 pixelForLatLng(const LatLng latLng) const; + const LatLng latLngForPixel(const vec2 pixel) const; // Annotations void setDefaultPointAnnotationSymbol(const std::string&); @@ -160,7 +126,6 @@ public: // Memory void setSourceTileCacheSize(size_t); - size_t getSourceTileCacheSize() const { return sourceCacheSize; } void onLowMemory(); // Debug @@ -168,104 +133,9 @@ public: void toggleDebug(); bool getDebug() const; - inline const TransformState &getState() const { return state; } - TimePoint getTime() const; - inline AnnotationManager& getAnnotationManager() const { return *annotationManager; } - private: - // Runs the map event loop. ONLY run this function when you want to get render a single frame - // with this map object. It will *not* spawn a separate thread and instead block until the - // frame is completely rendered. - void run(); - - // This may only be called by the View object. - void resize(uint16_t width, uint16_t height, float ratio = 1); - void resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight); - - util::ptr getSprite(); - Worker& getWorker(); - - // Checks if render thread needs to pause - void checkForPause(); - - // Setup - void setup(); - - void updateTiles(); - - // Triggered by triggerUpdate(); - void update(); - - // Loads the style set in the data object. Called by Update::StyleInfo - void reloadStyle(); - void loadStyleJSON(const std::string& json, const std::string& base); - - // Prepares a map render by updating the tiles we need for the current view, as well as updating - // the stylesheet. - void prepare(); - - // Runs the function in the map thread. - void invokeTask(std::function&&); - template auto invokeSyncTask(const Fn& fn) -> decltype(fn()); - - void processTasks(); - - void updateAnnotationTiles(const std::vector&); - - size_t sourceCacheSize; - - Mode mode = Mode::None; - - const std::unique_ptr env; - std::unique_ptr scope; - View &view; - -private: - std::unique_ptr workers; - std::thread thread; - std::unique_ptr asyncTerminate; - std::unique_ptr asyncUpdate; - std::unique_ptr asyncInvoke; - std::unique_ptr asyncRender; - - bool terminating = false; - bool pausing = false; - bool isPaused = false; - std::mutex mutexRun; - std::condition_variable condRun; - std::mutex mutexPause; - std::condition_variable condPause; - - // Used to signal that rendering completed. - bool rendered = false; - std::condition_variable condRendered; - std::mutex mutexRendered; - - // Stores whether the map thread has been stopped already. - std::atomic_bool isStopped; - - Transform transform; - TransformState state; - - FileSource& fileSource; - - util::ptr