From 71d127220b2469cc49e61b528e2c5c5548097b93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 17 Apr 2015 17:55:24 +0200 Subject: [PATCH 01/20] rename Mode::Static => Mode::Still --- bin/render.cpp | 2 +- include/mbgl/map/map.hpp | 2 +- src/mbgl/map/map.cpp | 8 ++++---- test/api/repeated_render.cpp | 2 +- test/api/set_style.cpp | 2 +- test/headless/headless.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/render.cpp b/bin/render.cpp index 78cb5b59f..cd7a54f48 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) { HeadlessView view; Map map(view, fileSource); - map.start(Map::Mode::Static); + map.start(Map::Mode::Still); // Set access token if present if (token.size()) { diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 992c12b83..f9738debe 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -51,7 +51,7 @@ public: enum class Mode : uint8_t { None, // we're not doing any processing Continuous, // continually updating map - Static, // a once-off static image. + Still, // a once-off still image. }; explicit Map(View&, FileSource&); diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 5e7473820..e931d09e0 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -247,15 +247,15 @@ void Map::resume() { void Map::renderStill(StillImageCallback fn) { assert(Environment::currentlyOn(ThreadType::Main)); - if (mode != Mode::Static) { - throw util::Exception("Map is not in static render mode"); + if (mode != Mode::Still) { + throw util::Exception("Map is not in still image render mode"); } if (callback) { throw util::Exception("Map is currently rendering an image"); } - assert(mode == Mode::Static); + assert(mode == Mode::Still); callback = std::move(fn); @@ -287,7 +287,7 @@ void Map::run() { uv_run(env->loop, UV_RUN_DEFAULT); checkForPause(); } - } else if (mode == Mode::Static) { + } else if (mode == Mode::Still) { terminating = false; while (!terminating) { uv_run(env->loop, UV_RUN_DEFAULT); diff --git a/test/api/repeated_render.cpp b/test/api/repeated_render.cpp index 16688ec36..25a5d5d28 100644 --- a/test/api/repeated_render.cpp +++ b/test/api/repeated_render.cpp @@ -24,7 +24,7 @@ TEST(API, RepeatedRender) { Map map(view, fileSource); - map.start(Map::Mode::Static); + map.start(Map::Mode::Still); { view.resize(128, 512, 1); diff --git a/test/api/set_style.cpp b/test/api/set_style.cpp index 973989d1c..11921a43c 100644 --- a/test/api/set_style.cpp +++ b/test/api/set_style.cpp @@ -18,7 +18,7 @@ TEST(API, SetStyle) { Map map(view, fileSource); - map.start(Map::Mode::Static); + map.start(Map::Mode::Still); map.setStyleJSON("invalid", "test/suite"); diff --git a/test/headless/headless.cpp b/test/headless/headless.cpp index 4ce9b668f..cccd0d44b 100644 --- a/test/headless/headless.cpp +++ b/test/headless/headless.cpp @@ -145,7 +145,7 @@ TEST_P(HeadlessTest, render) { DefaultFileSource fileSource(nullptr); Map map(view, fileSource); - map.start(Map::Mode::Static); + map.start(Map::Mode::Still); map.setClasses(classes); map.setStyleJSON(style, "test/suite"); From 8b44cfeb7642c74307c4c946fded280fe7e7bbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sat, 18 Apr 2015 22:14:39 -0700 Subject: [PATCH 02/20] Ensure correct spin direction Ported mapbox/mapbox-gl-js#821 as well as `util.wrap()` from mapbox-gl-js. Fixes #1199. --- include/mbgl/util/math.hpp | 6 ++++++ src/mbgl/map/transform.cpp | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/mbgl/util/math.hpp b/include/mbgl/util/math.hpp index e800fc784..647fa5e67 100644 --- a/include/mbgl/util/math.hpp +++ b/include/mbgl/util/math.hpp @@ -98,6 +98,12 @@ T clamp(T value, T min, T max) { return value < min ? min : (value > max ? max : value); } +template +T wrap(T value, T min, T max) { + T d = max - min; + return value == max ? value : std::fmod((std::fmod((value - min), d) + d), d) + min; +} + template T smoothstep(T edge0, T edge1, T x) { T t = clamp((x - edge0) / (edge1 - edge0), T(0), T(1)); diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 10f69e2ed..cb73915e3 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -12,6 +12,21 @@ using namespace mbgl; +/** Converts the given angle (in radians) to be numerically close to the anchor angle, allowing it to be interpolated properly without sudden jumps. */ +static double _normalizeAngle(double angle, double anchorAngle) +{ + angle = util::wrap(angle, -M_PI, M_PI); + double diff = std::abs(angle - anchorAngle); + if (std::abs(angle - util::M2PI - anchorAngle) < diff) { + angle -= util::M2PI; + } + if (std::abs(angle + util::M2PI - anchorAngle) < diff) { + angle += util::M2PI; + } + + return angle; +} + Transform::Transform(View &view_) : view(view_) { @@ -330,12 +345,7 @@ void Transform::_setAngle(double new_angle, const Duration duration) { MapChangeRegionWillChangeAnimated : MapChangeRegionWillChange); - while (new_angle > M_PI) - new_angle -= util::M2PI; - while (new_angle <= -M_PI) - new_angle += util::M2PI; - - final.angle = new_angle; + final.angle = _normalizeAngle(new_angle, current.angle); if (duration == Duration::zero()) { current.angle = final.angle; From 7b080e8fc3100a0a4346f21d039a2737e1187ea1 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 6 Apr 2015 11:23:09 -0400 Subject: [PATCH 03/20] fix style copying for linux app on osx - refs #511 / e69beba4d1 --- gyp/styles.gypi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gyp/styles.gypi b/gyp/styles.gypi index e1cd344fe..2c8772a87 100644 --- a/gyp/styles.gypi +++ b/gyp/styles.gypi @@ -19,7 +19,7 @@ 'hard_dependency': 1, 'dependencies': [ 'touch_styles' ], # required for xcode http://openradar.appspot.com/7232149 'conditions': [ - ['OS == "mac"', { + ['platform_lib == "osx"', { 'direct_dependent_settings': { 'mac_bundle_resources': [ '../styles/styles' ], } From 02735b0e6d5f4469910787ee293ded6aeb3a41ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 20 Apr 2015 11:34:02 +0200 Subject: [PATCH 04/20] default to CGL on OS X --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 434645c81..14f78ed0f 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ ANDROID_ABI ?= arm-v7 ifeq ($(shell uname -s), Darwin) HOST ?= osx +HEADLESS ?= cgl JOBS ?= $(shell sysctl -n hw.ncpu) endif HOST ?= linux From decc493ec8c30d66bcdf3aa19f58972eb045b5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 16 Apr 2015 16:46:12 +0200 Subject: [PATCH 05/20] build on trusty --- .mason | 2 +- .travis.yml | 130 ++++++++---------- Makefile | 21 ++- README.md | 2 +- android/scripts/build-debug.sh | 8 -- android/scripts/build-release.sh | 8 -- android/scripts/common.sh | 40 ------ android/scripts/run-build.sh | 85 ------------ config/defaults.mk | 14 +- configure | 3 +- docker/linux/test.sh | 26 ---- scripts/android/install.sh | 15 ++ scripts/android/run.sh | 61 ++++++++ scripts/android/toolchain.sh | 26 ++++ scripts/android_env.sh | 25 ---- scripts/flags.sh | 32 ----- scripts/install_node.sh | 4 - scripts/{ios_travis => ios}/add-key.sh | 8 +- scripts/{ios_travis => ios}/apple.crt | Bin scripts/ios/install.sh | 13 ++ scripts/{ios_travis => ios}/ios-dist.cer.enc | 0 scripts/{ios_travis => ios}/ios-dist.p12.enc | 0 .../ios-in-house.mobileprovision.enc | 0 scripts/{package_ios.sh => ios/package.sh} | 0 scripts/{publish_ios.sh => ios/publish.sh} | 0 scripts/{ios_travis => ios}/remove-key.sh | 0 scripts/ios/run.sh | 27 ++++ scripts/linux/install.sh | 22 +++ scripts/linux/run.sh | 75 ++++++++++ scripts/local_mason.sh | 5 - scripts/npm_install.sh | 8 -- scripts/osx/install.sh | 13 ++ scripts/osx/run.sh | 27 ++++ scripts/travis_before_install.sh | 53 ------- scripts/travis_helper.sh | 26 ++-- scripts/travis_script.sh | 62 --------- scripts/xcpretty.sh | 3 + test/test.gyp | 3 + 38 files changed, 389 insertions(+), 458 deletions(-) delete mode 100755 android/scripts/build-debug.sh delete mode 100755 android/scripts/build-release.sh delete mode 100755 android/scripts/common.sh delete mode 100755 android/scripts/run-build.sh delete mode 100755 docker/linux/test.sh create mode 100755 scripts/android/install.sh create mode 100755 scripts/android/run.sh create mode 100755 scripts/android/toolchain.sh delete mode 100755 scripts/android_env.sh delete mode 100755 scripts/flags.sh delete mode 100755 scripts/install_node.sh rename scripts/{ios_travis => ios}/add-key.sh (61%) rename scripts/{ios_travis => ios}/apple.crt (100%) create mode 100755 scripts/ios/install.sh rename scripts/{ios_travis => ios}/ios-dist.cer.enc (100%) rename scripts/{ios_travis => ios}/ios-dist.p12.enc (100%) rename scripts/{ios_travis => ios}/ios-in-house.mobileprovision.enc (100%) rename scripts/{package_ios.sh => ios/package.sh} (100%) rename scripts/{publish_ios.sh => ios/publish.sh} (100%) rename scripts/{ios_travis => ios}/remove-key.sh (100%) create mode 100755 scripts/ios/run.sh create mode 100755 scripts/linux/install.sh create mode 100755 scripts/linux/run.sh delete mode 100755 scripts/local_mason.sh delete mode 100755 scripts/npm_install.sh create mode 100755 scripts/osx/install.sh create mode 100755 scripts/osx/run.sh delete mode 100755 scripts/travis_before_install.sh delete mode 100755 scripts/travis_script.sh create mode 100755 scripts/xcpretty.sh diff --git a/.mason b/.mason index 03869fd11..735d2036e 160000 --- a/.mason +++ b/.mason @@ -1 +1 @@ -Subproject commit 03869fd11e4bc619d3ba7e4f8a1f00d4612c90ea +Subproject commit 735d2036e559da68ea7baf3afcbdc23f8ec2af05 diff --git a/.travis.yml b/.travis.yml index 690b2b1b6..8da536ae6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,95 +1,81 @@ -language: cpp +dist: trusty 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++ BUILDTYPE=Release - os: linux - env: CONFIG=debug MASON_PLATFORM=android MASON_ANDROID_ABI=arm-v7 TESTMUNK=no - compiler: clang + env: FLAVOR=linux CXX=clang++ BUILDTYPE=Debug - 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 - 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 + - os: linux + env: FLAVOR=android ANDROID_ABI=arm-v7 BUILDTYPE=Debug + android: + components: + - build-tools-22.0.0 + - android-22 + - extra + - os: linux + env: FLAVOR=android ANDROID_ABI=arm-v8 BUILDTYPE=Release + android: + components: + - build-tools-22.0.0 + - android-22 + - extra + - os: linux + env: FLAVOR=android ANDROID_ABI=x86 BUILDTYPE=Release + android: + components: + - build-tools-22.0.0 + - android-22 + - extra + - os: linux + env: FLAVOR=android ANDROID_ABI=mips BUILDTYPE=Release + android: + components: + - build-tools-22.0.0 + - android-22 + - extra 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=" 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 - -after_script: -- ./scripts/ios_travis/remove-key.sh +- ./scripts/${FLAVOR}/run.sh notifications: slack: secure: HHQYr7sF8M1SzoWSqgKVYtwAgGdLLCyTMsQjFhEEQNYO92ZwURE5s03qWTGH5k8+4Yqn26yrXt3NztLC4JIOpcGervN2mSZyq4dZgFTcWEd61igw0qwSenlwvFfbE1ASK/KYCzfyn9MIfHN+ovwLoRxXZkPwinKDvl3DXjBaFNg= + git: submodules: false diff --git a/Makefile b/Makefile index 14f78ed0f..eb0fc1fee 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,12 @@ 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 #### Library builds ############################################################ @@ -70,8 +74,9 @@ Xcode/test: test/test.gyp config/osx.gypi styles/styles SMCalloutView xtest-proj: Xcode/test open ./build/osx/test/test.xcodeproj +xtest: XCPRETTY := $(shell ./scripts/xcpretty.sh) xtest: Xcode/test - xcodebuild -project ./build/osx/test/test.xcodeproj -configuration $(BUILDTYPE) -target test -jobs $(JOBS) + xcodebuild -project ./build/osx/test/test.xcodeproj -configuration $(BUILDTYPE) -target test -jobs $(JOBS) $(XCPRETTY) xtest-%: xtest ./scripts/run_tests.sh "build/osx/Build/Products/$(BUILDTYPE)/test" --gtest_filter=$* @@ -99,8 +104,9 @@ Xcode/osx: macosx/mapboxgl-app.gyp config/osx.gypi styles/styles xosx-proj: Xcode/osx open ./build/osx/macosx/mapboxgl-app.xcodeproj +xosx: XCPRETTY := $(shell ./scripts/xcpretty.sh) xosx: Xcode/osx - xcodebuild -project ./build/osx/macosx/mapboxgl-app.xcodeproj -configuration $(BUILDTYPE) -target osxapp -jobs $(JOBS) + xcodebuild -project ./build/osx/macosx/mapboxgl-app.xcodeproj -configuration $(BUILDTYPE) -target osxapp -jobs $(JOBS) $(XCPRETTY) run-xosx: xosx "build/osx/Build/Products/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL" @@ -120,14 +126,16 @@ Xcode/ios: ios/app/mapboxgl-app.gyp config/ios.gypi styles/styles SMCalloutView ios-proj: Xcode/ios open ./build/ios/ios/app/mapboxgl-app.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/ios/app/mapboxgl-app.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/ios/app/mapboxgl-app.xcodeproj -configuration Debug -target iosapp -jobs $(JOBS) $(XCPRETTY) ipackage: clean Xcode/ios - ./scripts/package_ios.sh + ./scripts/ios/package.sh # Legacy name iproj: ios-proj @@ -155,8 +163,9 @@ Xcode/linux: linux/mapboxgl-app.gyp config/osx.gypi styles/styles xlinux-proj: Xcode/linux open ./build/osx/linux/mapboxgl-app.xcodeproj +xlinux: XCPRETTY := $(shell ./scripts/xcpretty.sh) xlinux: Xcode/linux - xcodebuild -project ./build/osx/linux/mapboxgl-app.xcodeproj -configuration $(BUILDTYPE) -target linuxapp + xcodebuild -project ./build/osx/linux/mapboxgl-app.xcodeproj -configuration $(BUILDTYPE) -target linuxapp $(XCPRETTY) run-xlinux: xlinux "build/osx/Build/Products/$(BUILDTYPE)/mapbox-gl" diff --git a/README.md b/README.md index c423c21b5..4ca2205fa 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 `./scripts/ios/package.sh`. 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. 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/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..a37000a1b 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') 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/scripts/android/install.sh b/scripts/android/install.sh new file mode 100755 index 000000000..656465cf2 --- /dev/null +++ b/scripts/android/install.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +source ./scripts/travis_helper.sh + +mapbox_time "checkout_mason" \ +git submodule update --init .mason + +export MASON_PLATFORM=android +export MASON_ANDROID_ABI=${ANDROID_ABI} + +mapbox_time "android_toolchain" \ +./scripts/android/toolchain.sh diff --git a/scripts/android/run.sh b/scripts/android/run.sh new file mode 100755 index 000000000..7a909ffe3 --- /dev/null +++ b/scripts/android/run.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +BUILDTYPE=${BUILDTYPE:-Release} +TESTMUNK=${TESTMUNK:-no} +export HOST=android +export MASON_PLATFORM=android +export MASON_ANDROID_ABI=${ANDROID_ABI:-arm-v7} + +source ./scripts/travis_helper.sh + +# Add Mason to PATH +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" + +################################################################################ +# Build +################################################################################ + +mapbox_time "checkout_styles" \ +git submodule update --init styles + +mkdir -p ./android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw +echo "${MAPBOX_ACCESS_TOKEN}" > ./android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt + +mapbox_time "compile_library" \ +make android-lib -j${JOBS} BUILDTYPE=${BUILDTYPE} + +mapbox_time "build_apk" \ +make android -j${JOBS} BUILDTYPE=${BUILDTYPE} + +################################################################################ +# Deploy +################################################################################ + +if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then + # Install and add awscli to PATH for uploading the results + mapbox_time "install_awscli" \ + pip install --user awscli + export PATH="`python -m site --user-base`/bin:${PATH}" + + mapbox_time_start "deploy_results" + echo "Deploying results..." + + S3_PREFIX=s3://mapbox/mapbox-gl-native/android/build/${TRAVIS_JOB_NUMBER} + APK_OUTPUTS=./android/java/MapboxGLAndroidSDKTestApp/build/outputs/apk + + # 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 + + mapbox_time_finish +fi diff --git a/scripts/android/toolchain.sh b/scripts/android/toolchain.sh new file mode 100755 index 000000000..67cd0aa47 --- /dev/null +++ b/scripts/android/toolchain.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +export MASON_PLATFORM=android +export MASON_ANDROID_ABI=${MASON_ANDROID_ABI:-arm-v7} +export PATH="`pwd`/.mason:${PATH}" +export MASON_DIR="`pwd`/.mason" + +export PATH=`mason env PATH` + +echo MASON_PLATFORM=\"${MASON_PLATFORM}\" +echo MASON_ANDROID_ABI=\"${MASON_ANDROID_ABI}\" +echo CXX=\"`which $(mason env CXX)`\" +echo CC=\"`which $(mason env CC)`\" +echo LD=\"`which $(mason env LD)`\" +echo LINK=\"`which $(mason env CXX)`\" +echo AR=\"`which $(mason env AR)`\" +echo RANLIB=\"`which $(mason env RANLIB)`\" +echo STRIP=\"`which $(mason env STRIP)`\" +echo LDFLAGS=\"`mason env LDFLAGS` \${LDFLAGS:-}\" +echo CFLAGS=\"`mason env CFLAGS` \${CFLAGS:-}\" +echo CXXFLAGS=\"`mason env CXXFLAGS` \${CXXFLAGS:-}\" +echo CPPFLAGS=\"`mason env CPPFLAGS` \${CPPFLAGS:-}\" +echo JNIDIR=\"`mason env JNIDIR`\" diff --git a/scripts/android_env.sh b/scripts/android_env.sh deleted file mode 100755 index 93b1452a5..000000000 --- a/scripts/android_env.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -./scripts/local_mason.sh - -export MASON_PLATFORM=android - -export PATH=`.mason/mason env PATH` - -echo MASON_PLATFORM=\"android\" -echo MASON_ANDROID_ABI=\"${MASON_ANDROID_ABI}\" - -echo CXX=\"`which $(.mason/mason env CXX)`\" -echo CC=\"`which $(.mason/mason env CC)`\" -echo LD=\"`which $(.mason/mason env LD)`\" -echo LINK=\"`which $(.mason/mason env CXX)`\" -echo AR=\"`which $(.mason/mason env AR)`\" -echo RANLIB=\"`which $(.mason/mason env RANLIB)`\" -echo STRIP=\"`which $(.mason/mason env STRIP)`\" -echo LDFLAGS=\"`.mason/mason env LDFLAGS` ${LDFLAGS}\" -echo CFLAGS=\"`.mason/mason env CFLAGS` ${CFLAGS}\" -echo CPPFLAGS=\"`.mason/mason env CPPFLAGS` ${CPPFLAGS}\" -echo JNIDIR=\"`.mason/mason env JNIDIR`\" diff --git a/scripts/flags.sh b/scripts/flags.sh deleted file mode 100755 index 10cc88e5c..000000000 --- a/scripts/flags.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then - export DISPLAY=:99.0 - - if [[ ${MASON_PLATFORM} != "android" ]]; then - sh -e /etc/init.d/xvfb start - fi - - # use g++ that supports c++11 - if [[ ${CXX} == "g++" ]]; then - export CXX="g++-4.8" - export CC="gcc-4.8" - fi - - # If building in debug then turn on sanitizers. - # They should both work with latest g++/clang++ - # but it's not worth a standalone matrix so here - # we just test address->gcc and thread->clang for - # some limited coverage - # if [[ ${BUILDTYPE} == "Debug" ]]; then - # if [[ ${CXX} == "g++" ]]; then - # export CXXFLAGS="-fsanitize=address -g ${CXXFLAGS}" - # export CFLAGS="-fsanitize=address -g ${CFLAGS}" - # export LDFLAGS="-fsanitize=address ${LDFLAGS}" - # elif [[ ${CXX} == "clang++" ]]; then - # export CXXFLAGS="-fsanitize=thread -g -fPIC ${CXXFLAGS}" - # export CFLAGS="-fsanitize=thread -g ${CFLAGS}" - # export LDFLAGS="-fsanitize=thread -pie ${LDFLAGS}" - # fi - # fi -fi diff --git a/scripts/install_node.sh b/scripts/install_node.sh deleted file mode 100755 index ecb5b8835..000000000 --- a/scripts/install_node.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -mason install node 0.10.35 -export PATH="`mason prefix node 0.10.35`/bin":"$PATH" diff --git a/scripts/ios_travis/add-key.sh b/scripts/ios/add-key.sh similarity index 61% rename from scripts/ios_travis/add-key.sh rename to scripts/ios/add-key.sh index b58144530..fe963d38e 100755 --- a/scripts/ios_travis/add-key.sh +++ b/scripts/ios/add-key.sh @@ -16,10 +16,10 @@ security unlock-keychain -p travis ios-build.keychain security set-keychain-settings -t 3600 -l ~/Library/Keychains/ios-build.keychain # Add certificates to keychain and allow codesign to access them -security import ./scripts/ios_travis/apple.crt -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign -security import ./scripts/ios_travis/ios-dist.cer -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign -security import ./scripts/ios_travis/ios-dist.p12 -k ~/Library/Keychains/ios-build.keychain -P $IOS_KEY_PASSWORD -T /usr/bin/codesign +security import ./scripts/ios/apple.crt -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign +security import ./scripts/ios/ios-dist.cer -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign +security import ./scripts/ios/ios-dist.p12 -k ~/Library/Keychains/ios-build.keychain -P $IOS_KEY_PASSWORD -T /usr/bin/codesign # Put the provisioning profile in place mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles -cp "./scripts/ios_travis/$IOS_PROFILE_NAME.mobileprovision" ~/Library/MobileDevice/Provisioning\ Profiles/ +cp "./scripts/ios/$IOS_PROFILE_NAME.mobileprovision" ~/Library/MobileDevice/Provisioning\ Profiles/ diff --git a/scripts/ios_travis/apple.crt b/scripts/ios/apple.crt similarity index 100% rename from scripts/ios_travis/apple.crt rename to scripts/ios/apple.crt diff --git a/scripts/ios/install.sh b/scripts/ios/install.sh new file mode 100755 index 000000000..1994d371d --- /dev/null +++ b/scripts/ios/install.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +source ./scripts/travis_helper.sh + +mapbox_time "checkout_mason" \ +git submodule update --init .mason +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" + +mapbox_time "install_xcpretty" \ +gem install xcpretty --no-rdoc --no-ri --no-document --quiet diff --git a/scripts/ios_travis/ios-dist.cer.enc b/scripts/ios/ios-dist.cer.enc similarity index 100% rename from scripts/ios_travis/ios-dist.cer.enc rename to scripts/ios/ios-dist.cer.enc diff --git a/scripts/ios_travis/ios-dist.p12.enc b/scripts/ios/ios-dist.p12.enc similarity index 100% rename from scripts/ios_travis/ios-dist.p12.enc rename to scripts/ios/ios-dist.p12.enc diff --git a/scripts/ios_travis/ios-in-house.mobileprovision.enc b/scripts/ios/ios-in-house.mobileprovision.enc similarity index 100% rename from scripts/ios_travis/ios-in-house.mobileprovision.enc rename to scripts/ios/ios-in-house.mobileprovision.enc diff --git a/scripts/package_ios.sh b/scripts/ios/package.sh similarity index 100% rename from scripts/package_ios.sh rename to scripts/ios/package.sh diff --git a/scripts/publish_ios.sh b/scripts/ios/publish.sh similarity index 100% rename from scripts/publish_ios.sh rename to scripts/ios/publish.sh diff --git a/scripts/ios_travis/remove-key.sh b/scripts/ios/remove-key.sh similarity index 100% rename from scripts/ios_travis/remove-key.sh rename to scripts/ios/remove-key.sh diff --git a/scripts/ios/run.sh b/scripts/ios/run.sh new file mode 100755 index 000000000..6eed14a59 --- /dev/null +++ b/scripts/ios/run.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +BUILDTYPE=${BUILDTYPE:-Release} + +source ./scripts/travis_helper.sh + +# Add Mason to PATH +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" + +################################################################################ +# Build +################################################################################ + +mapbox_time "package_ios" \ +make ipackage + +################################################################################ +# Deploy +################################################################################ + +if [[ -n "$PUBLISH_TAG" ]]; then + mapbox_time "deploy_ios" \ + ./scripts/ios/publish.sh "$PUBLISH_VERSION" +fi diff --git a/scripts/linux/install.sh b/scripts/linux/install.sh new file mode 100755 index 000000000..a47155d69 --- /dev/null +++ b/scripts/linux/install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +source ./scripts/travis_helper.sh + +mapbox_time "update_apt" \ +sudo apt-get -y update + +mapbox_time "install_apt" \ +sudo apt-get -y install mesa-utils llvm-3.4 pkg-config libcurl4-openssl-dev \ + libboost-dev libboost-program-options-dev libxi-dev x11proto-randr-dev \ + x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev \ + libxcursor-dev libxinerama-dev + +mapbox_time "checkout_mason" \ +git submodule update --init .mason +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" + +mapbox_time "install_mesa" \ +mason install mesa 10.4.3 diff --git a/scripts/linux/run.sh b/scripts/linux/run.sh new file mode 100755 index 000000000..c4731b97e --- /dev/null +++ b/scripts/linux/run.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +BUILDTYPE=${BUILDTYPE:-Release} + +source ./scripts/travis_helper.sh + +# Add Mason to PATH +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" + +# Set the core file limit to unlimited so a core file is generated upon crash +ulimit -c unlimited -S + +################################################################################ +# X Server setup +################################################################################ + +# Start the mock X server +if [ -f /etc/init.d/xvfb ] ; then + mapbox_time "start_xvfb" \ + sh -e /etc/init.d/xvfb start + sleep 2 # sometimes, xvfb takes some time to start up +fi + +# Make sure we're connecting to xvfb +export DISPLAY=:99.0 + +# Make sure we're loading the 10.4.3 libs we installed manually +export LD_LIBRARY_PATH="`mason prefix mesa 10.4.3`/lib:${LD_LIBRARY_PATH:-}" + +mapbox_time "glxinfo" \ +glxinfo + +################################################################################ +# Build +################################################################################ + +mapbox_time "checkout_styles" \ +git submodule update --init styles + +mapbox_time "compile_program" \ +make linux -j${JOBS} BUILDTYPE=${BUILDTYPE} + +mapbox_time "compile_tests" \ +make test -j${JOBS} BUILDTYPE=${BUILDTYPE} + +################################################################################ +# Test +################################################################################ + +mapbox_time "checkout_test_suite" \ +git submodule update --init test/suite + +mapbox_time "run_tests" \ +make test-* BUILDTYPE=${BUILDTYPE} + +mapbox_time "compare_results" \ +./scripts/compare_images.sh + +################################################################################ +# Deploy +################################################################################ + +if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then + # Install and add awscli to PATH for uploading the results + mapbox_time "install_awscli" \ + pip install --user awscli + export PATH="`python -m site --user-base`/bin:${PATH}" + + mapbox_time_start "deploy_results" + (cd ./test/suite/ && ./bin/deploy_results.sh) + mapbox_time_finish +fi diff --git a/scripts/local_mason.sh b/scripts/local_mason.sh deleted file mode 100755 index 2d8687a28..000000000 --- a/scripts/local_mason.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -git submodule update --init .mason -PATH=`pwd`/.mason:$PATH -export MASON_DIR=`pwd`/.mason diff --git a/scripts/npm_install.sh b/scripts/npm_install.sh deleted file mode 100755 index 7437af961..000000000 --- a/scripts/npm_install.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -cd bin -$1 install --clang=1 -cd ../ diff --git a/scripts/osx/install.sh b/scripts/osx/install.sh new file mode 100755 index 000000000..1994d371d --- /dev/null +++ b/scripts/osx/install.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +source ./scripts/travis_helper.sh + +mapbox_time "checkout_mason" \ +git submodule update --init .mason +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" + +mapbox_time "install_xcpretty" \ +gem install xcpretty --no-rdoc --no-ri --no-document --quiet diff --git a/scripts/osx/run.sh b/scripts/osx/run.sh new file mode 100755 index 000000000..b84ed04c2 --- /dev/null +++ b/scripts/osx/run.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +BUILDTYPE=${BUILDTYPE:-Release} + +source ./scripts/travis_helper.sh + +# Add Mason to PATH +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" + +# Set the core file limit to unlimited so a core file is generated upon crash +ulimit -c unlimited -S + +################################################################################ +# Build +################################################################################ + +mapbox_time "checkout_styles" \ +git submodule update --init styles + +mapbox_time "compile_program" \ +make xosx -j${JOBS} BUILDTYPE=${BUILDTYPE} + +mapbox_time "compile_tests" \ +make xtest -j${JOBS} BUILDTYPE=${BUILDTYPE} diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh deleted file mode 100755 index f837e7416..000000000 --- a/scripts/travis_before_install.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then - # - # install Linux dependencies - # - 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 - - mapbox_time "apt_update" \ - sudo apt-get update -y - - mapbox_time "install_gcc" \ - sudo apt-get -y install gcc-4.8 g++-4.8 - - mapbox_time "install_build_tools" \ - sudo apt-get -y install git build-essential zlib1g-dev automake gdb \ - libtool xutils-dev make cmake pkg-config python-pip \ - libboost1.55-dev libcurl4-openssl-dev \ - libpng-dev libsqlite3-dev - - if [[ ${MASON_PLATFORM} != "android" ]]; then - mapbox_time "install_opengl" \ - sudo apt-get -y install mesa-utils libxi-dev x11proto-randr-dev \ - x11proto-xext-dev libxrandr-dev \ - x11proto-xf86vidmode-dev libxxf86vm-dev \ - libxcursor-dev libxinerama-dev \ - llvm-3.4 # required for mesa - - mapbox_time "install_mesa" \ - mason install mesa 10.4.3 - fi - - mapbox_time "install_awscli" \ - sudo pip install awscli -elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then - # - # install OS X dependencies - # - mapbox_time "install_build_tools" \ - brew install git - - mapbox_time "install_awscli" \ - sudo pip install awscli - - mapbox_time "install_xcpretty" \ - gem install xcpretty --no-rdoc --no-ri --no-document --quiet -fi diff --git a/scripts/travis_helper.sh b/scripts/travis_helper.sh index c42ce215e..13e1f4497 100755 --- a/scripts/travis_helper.sh +++ b/scripts/travis_helper.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash +case `uname -s` in + 'Darwin') JOBS=$((`sysctl -n hw.ncpu` + 2)) ;; + 'Linux') JOBS=$((`nproc` + 2)) ;; + *) JOBS=2 ;; +esac + function mapbox_time_start { local name=$1 mapbox_timer_name=$name - travis_fold start $name + mapbox_fold start $name mapbox_timer_id=$(printf %08x $(( RANDOM * RANDOM ))) - eval "mapbox_start_time_$mapbox_timer_id=$(travis_nanoseconds)" + eval "mapbox_start_time_$mapbox_timer_id=$(mapbox_nanoseconds)" echo -en "travis_time:start:$mapbox_timer_id\n" } @@ -16,11 +22,11 @@ function mapbox_time_finish { local timer_id=${2:-$mapbox_timer_id} local timer_start="mapbox_start_time_$timer_id" eval local start_time=\${$timer_start} - local end_time=$(travis_nanoseconds) + local end_time=$(mapbox_nanoseconds) local duration=$(($end_time-$start_time)) echo -en "travis_time:end:$timer_id:start=$start_time,finish=$end_time,duration=$duration\n" - travis_fold end $name + mapbox_fold end $name } function mapbox_time { @@ -32,13 +38,13 @@ function mapbox_time { mapbox_time_finish $name $timer_id } -if [[ "${TRAVIS_COMMIT:-false}" == false ]]; then -function travis_fold { +function mapbox_fold { local action=$1 local name=$2 echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}" } -function travis_nanoseconds { + +function mapbox_nanoseconds { local cmd="date" local format="+%s%N" local os=$(uname) @@ -51,11 +57,11 @@ function travis_nanoseconds { $cmd -u $format } -fi +export JOBS export ANSI_CLEAR -export -f travis_fold -export -f travis_nanoseconds +export -f mapbox_fold +export -f mapbox_nanoseconds export -f mapbox_time export -f mapbox_time_start export -f mapbox_time_finish diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh deleted file mode 100755 index 0351f9414..000000000 --- a/scripts/travis_script.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env bash - -COMMIT_MESSAGE=$(git show -s --format=%B $1 | tr -d '\n') -PUBLISH_TAG=$(echo "$COMMIT_MESSAGE" | grep -oE '\[publish [a-z0-9\.\-]+\]' | grep -oE '[a-z0-9\.\-]+' | tail -n1) -PUBLISH_PLATFORM=$(echo "$PUBLISH_TAG" | awk -F '-v' '{ print $1 }') -PUBLISH_VERSION=$(echo "$PUBLISH_TAG" | awk -F '-v' '{ print $2 }') - -set -e -set -o pipefail - -mapbox_time "checkout_styles" \ -git submodule update --init styles - -if [[ $MASON_PLATFORM == "android" ]]; then - ./android/scripts/run-build.sh - -elif [[ ${TRAVIS_OS_NAME} == "linux" ]]; then - # - # build & test Linux - # - mapbox_time "compile_program" \ - make linux -j$JOBS BUILDTYPE=${BUILDTYPE} - - mapbox_time "compile_tests" \ - make test -j$JOBS BUILDTYPE=${BUILDTYPE} - - mapbox_time "checkout_test_suite" \ - git submodule update --init test/suite - - mapbox_time "run_tests" \ - make test-* BUILDTYPE=${BUILDTYPE} - - mapbox_time "compare_results" \ - ./scripts/compare_images.sh - - if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then - mapbox_time_start "deploy_results" - (cd ./test/suite/ && ./bin/deploy_results.sh) - mapbox_time_finish - fi - -elif [[ ${TRAVIS_OS_NAME} == "osx" && ${MASON_PLATFORM} == "osx" ]]; then - # - # build OS X - # - mapbox_time "build_osx" \ - make xosx -j$JOBS - -elif [[ ${TRAVIS_OS_NAME} == "osx" && ${MASON_PLATFORM} == "ios" ]]; then - # - # build & package iOS - # - mapbox_time "package_ios" - make ipackage - # - # conditionally deploy iOS build - # - if [[ -n "$PUBLISH_TAG" ]]; then - mapbox_time "deploy_ios" - ./scripts/publish_ios.sh "$PUBLISH_VERSION" - fi -fi diff --git a/scripts/xcpretty.sh b/scripts/xcpretty.sh new file mode 100755 index 000000000..c39f58822 --- /dev/null +++ b/scripts/xcpretty.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +FN=$(which xcpretty) ; [ ! -z ${FN} ] && echo "| ${FN}" diff --git a/test/test.gyp b/test/test.gyp index 2e89db58b..41918ff42 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -72,15 +72,18 @@ ], 'libraries': [ '<@(uv_static_libs)', + '<@(sqlite3_static_libs)', ], 'variables': { 'cflags_cc': [ '<@(uv_cflags)', '<@(opengl_cflags)', '<@(boost_cflags)', + '<@(sqlite3_cflags)', ], 'ldflags': [ '<@(uv_ldflags)', + '<@(sqlite3_ldflags)', ], }, 'conditions': [ From ddf4dd882dc55366ed3c28605507c44704732c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 20 Apr 2015 14:56:35 +0200 Subject: [PATCH 06/20] [android] never pass garbage info to RegisterNatives() --- android/cpp/jni.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp index 628f24a15..ac5188484 100644 --- a/android/cpp/jni.cpp +++ b/android/cpp/jni.cpp @@ -927,9 +927,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { return JNI_ERR; } - // NOTE: if you get java.lang.UnsatisfiedLinkError you likely forgot to set the size of the - // array correctly (too large) - std::array methods = {{ // Can remove the extra brace in C++14 + const std::vector methods = { {"nativeCreate", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J", reinterpret_cast(&nativeCreate)}, {"nativeDestroy", "(J)V", reinterpret_cast(&nativeDestroy)}, @@ -1014,7 +1012,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { {"nativeLatLngForProjectedMeters", "(JLcom/mapbox/mapboxgl/geometry/ProjectedMeters;)Lcom/mapbox/mapboxgl/geometry/LatLng;", reinterpret_cast(&nativeLatLngForProjectedMeters)}, {"nativePixelForLatLng", "(JLcom/mapbox/mapboxgl/geometry/LatLng;)Landroid/graphics/PointF;", reinterpret_cast(&nativePixelForLatLng)}, {"nativeLatLngForPixel", "(JLandroid/graphics/PointF;)Lcom/mapbox/mapboxgl/geometry/LatLng;", reinterpret_cast(&nativeLatLngForPixel)}, - }}; + }; if (env->RegisterNatives(nativeMapViewClass, methods.data(), methods.size()) < 0) { env->ExceptionDescribe(); From ba8434c917bdf128d2d5de7549055d6d46967c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 20 Apr 2015 15:14:54 +0200 Subject: [PATCH 07/20] bump mason --- .mason | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mason b/.mason index 735d2036e..c43967404 160000 --- a/.mason +++ b/.mason @@ -1 +1 @@ -Subproject commit 735d2036e559da68ea7baf3afcbdc23f8ec2af05 +Subproject commit c43967404c84d020d63f6aba450d97770dfeaebb From e7518d56c52d8f8ffd50ad24246de2a3ad96b0ee Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 20 Apr 2015 10:59:09 -0500 Subject: [PATCH 08/20] #1303 - Enabling Battery Monitoring for app. Formatting battery level to int instead of float. --- platform/ios/MGLMapboxEvents.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 605c6a3fa..e4014d494 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -177,6 +177,9 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [NSTimeZone resetSystemTimeZone]; [_rfc3339DateFormatter setTimeZone:[NSTimeZone systemTimeZone]]; + // Enable Battery Monitoring + [UIDevice currentDevice].batteryMonitoringEnabled = YES; + _isPaused = NO; } return self; @@ -300,7 +303,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [evt setValue:weakSelf.model forKey:@"model"]; [evt setValue:weakSelf.iOSVersion forKey:@"operatingSystem"]; [evt setValue:[weakSelf getDeviceOrientation] forKey:@"orientation"]; - [evt setValue:@(100 * [UIDevice currentDevice].batteryLevel) forKey:@"batteryLevel"]; + [evt setValue:@((int)(100 * [UIDevice currentDevice].batteryLevel)) forKey:@"batteryLevel"]; [evt setValue:@(weakSelf.scale) forKey:@"resolution"]; [evt setValue:weakSelf.carrier forKey:@"carrier"]; From a2883dddc054cb30c7c853867078c0968b0f0006 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 20 Apr 2015 14:28:32 -0500 Subject: [PATCH 09/20] #1306 - Adding api_mapbox_com.der (public key) and nsurlconnection checking infrastructure --- common/api_mapbox_com.der | Bin 0 -> 1969 bytes gyp/certificates.gypi | 2 +- include/mbgl/ios/MGLMapboxEvents.h | 2 +- platform/ios/MGLMapboxEvents.m | 56 +++++++++++++++++++++++++++-- 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 common/api_mapbox_com.der diff --git a/common/api_mapbox_com.der b/common/api_mapbox_com.der new file mode 100644 index 0000000000000000000000000000000000000000..116144bc0ccb71925a4354b5bb2d98f98d8ef35c GIT binary patch literal 1969 zcmXqLVqa^}#5Q#SGZP~dlYm;9_(>P`_E=qm_4##0|2`VlPTyrC1Q%h6JD1#;k_O_)f=nVDE~z<*<%vb9hO!3IAY1u`MFNU4%Mwdc75t0R6Z0~w5=%1k^9%(H z_(0OE!tAC-=Ei2mhNNpi@jTQz4iOQT%;J)w%;XY<{4@pU{G8Iw(s>i*SV} z7H4GUrI!HRAZj2C4lofO-^7BX{0bdNc!?W`g2PLMFR>s~FBdGOmz>Ac;zIX!Ndl2eb6q{;Wf zi>l8mE^(M1S*afN>s0moTlqmiQ>WRvnq|GTs}u#4{7Orl{V$r z2b+ZHo@*Yx$v>@?emnC2T$5>6Ta2>}?XFw8vgtf|mvX7?`ULYug65o(e-5}dSZ~!jbl@n^L{dqgc0Gb01z;wI*+22IQt4H{1ZLs3?crSYIaY>J2lRy%NNHT^<3c3g%swv=HCM(Rs zWWWGUwzB+;jQ?3!n3-4?7-)lhDbJ!}pk$!1KyHCdn^ZsSu?AbVgd{$O=CPp!1kTJzTbIQxh z_0m)GOF$VKY*tZfaeir0a%!=DQEEYcab`(=QKf!PYIE zH9(CqU~Cgc4Vn~iu2O?5V8Ro2CBR%(%fi`&~ zVz9OD2Chts41awmnan%JuCRKi|Ac?1Ip&$(#SLHYnatN!EU*&fd*g&$^Z{!hVA03OaQxqqIlq@) zshf45>20;I%+;$qKF93pF`MKh=(hAhE_>tG*q2;lKa*CR4KOjVf$NrXKa&-*7OSInh>C1}v$L&Qm)CQSr}Kf-XLsDzPM5xOB_MoC zs>CZjAOEc^cM}A39O4R3-Chx-wQEr;M_q&QmV%qsUnkpTFdlG@ntN5M`^wTX_wY$S z%6G0(DDFw@bvACvIIG-yLxoAxa>u-;l{JY;&NYSqIJDf{^<6`*wYOa4iPAdaayRet ztNi`_6ZUJSpUPiUf9PA+tHSyPyCb;8C-X#pKC=AogPe{xd#0RkF|Ay2R?PlzkN=A~ Hi>?9yu%5e9 literal 0 HcmV?d00001 diff --git a/gyp/certificates.gypi b/gyp/certificates.gypi index 1d0c2acf8..fdd818b8d 100644 --- a/gyp/certificates.gypi +++ b/gyp/certificates.gypi @@ -4,7 +4,7 @@ 'type': 'none', 'hard_dependency': 1, 'copies': [{ - 'files': [ '../common/ca-bundle.crt' ], + 'files': [ '../common/api_mapbox_com.der', '../common/ca-bundle.crt' ], 'destination': '<(PRODUCT_DIR)' }], }, diff --git a/include/mbgl/ios/MGLMapboxEvents.h b/include/mbgl/ios/MGLMapboxEvents.h index b68b9b1b3..2c6f8151b 100644 --- a/include/mbgl/ios/MGLMapboxEvents.h +++ b/include/mbgl/ios/MGLMapboxEvents.h @@ -25,7 +25,7 @@ extern NSString *const MGLEventGesturePanStart; extern NSString *const MGLEventGesturePinchStart; extern NSString *const MGLEventGestureRotateStart; -@interface MGLMapboxEvents : NSObject +@interface MGLMapboxEvents : NSObject // You must call these methods from the main thread. // diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index e4014d494..62d4d73fb 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -395,9 +395,12 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [request setHTTPBody:jsonData]; // Send non blocking HTTP Request to server - [NSURLConnection sendAsynchronousRequest:request - queue:nil - completionHandler:nil]; + NSURLConnection *conn = [NSURLConnection connectionWithRequest:request delegate:weakSelf]; + [conn start]; + +// [NSURLConnection sendAsynchronousRequest:request +// queue:nil +// completionHandler:nil]; } }); } @@ -638,4 +641,51 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; return result; } +#pragma mark NSURLConnectionDelegate +- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { + + // Load Local Copy of Server's Public Key + // NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"b.ssl.fastly.net" ofType:@"der"]; + NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com" ofType:@"der"]; + NSData *localCertData = [NSData dataWithContentsOfFile:cerPath]; + + // Get Server's Public Key + SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; + + SecTrustResultType trustResult; + SecTrustEvaluate(serverTrust, &trustResult); + switch (trustResult) { + case kSecTrustResultProceed: + break; + case kSecTrustResultConfirm: + break; + case kSecTrustResultUnspecified: + break; + default: + [[challenge sender] cancelAuthenticationChallenge:challenge]; + return; + } + + long numKeys = SecTrustGetCertificateCount(serverTrust); + NSLog(@"Number of certificaties presented: %ld", numKeys); + + BOOL found = false; + for (int lc = 0; lc < numKeys; lc++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); + NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); + + // Compare Remote Key With Local Version + if ([remoteCertificateData isEqualToData:localCertData]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + found = true; + break; + } + } + + if (!found) { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } +} + @end From fbd610695a9be3248533c0c8130069209aa58994 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 20 Apr 2015 14:55:39 -0500 Subject: [PATCH 10/20] #1306 - Trying strongSelf / weakSelf pattern for delegate --- platform/ios/MGLMapboxEvents.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 62d4d73fb..67108bff4 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -382,10 +382,13 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; __weak MGLMapboxEvents *weakSelf = self; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ + MGLMapboxEvents *strongSelf = weakSelf; + if (!strongSelf) return; + // Setup URL Request - NSString *url = [NSString stringWithFormat:@"%@/events/v1?access_token=%@", MGLMapboxEventsAPIBase, weakSelf.token]; + NSString *url = [NSString stringWithFormat:@"%@/events/v1?access_token=%@", MGLMapboxEventsAPIBase, strongSelf.token]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]]; - [request setValue:[weakSelf getUserAgent] forHTTPHeaderField:@"User-Agent"]; + [request setValue:[strongSelf getUserAgent] forHTTPHeaderField:@"User-Agent"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setHTTPMethod:@"POST"]; @@ -395,7 +398,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [request setHTTPBody:jsonData]; // Send non blocking HTTP Request to server - NSURLConnection *conn = [NSURLConnection connectionWithRequest:request delegate:weakSelf]; + NSURLConnection *conn = [NSURLConnection connectionWithRequest:request delegate:strongSelf]; [conn start]; // [NSURLConnection sendAsynchronousRequest:request From 96a6371fa006b908ef70123b6c632f9b0ad47eb2 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 20 Apr 2015 18:56:42 -0500 Subject: [PATCH 11/20] #1306 - Explicitly scheduling NSURLConnections in mainRunLoop so that delegates and connections stay connected. --- platform/ios/MGLMapboxEvents.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 67108bff4..e4b422fe8 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -398,8 +398,9 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [request setHTTPBody:jsonData]; // Send non blocking HTTP Request to server - NSURLConnection *conn = [NSURLConnection connectionWithRequest:request delegate:strongSelf]; - [conn start]; + NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:strongSelf startImmediately:NO]; + [connection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; + [connection start]; // [NSURLConnection sendAsynchronousRequest:request // queue:nil From 75af3db17dcc8647a3705fb8dee5a23279b2c0b9 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 20 Apr 2015 16:29:18 -0700 Subject: [PATCH 12/20] Use a promise rather than async dance --- test/headless/headless.cpp | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/test/headless/headless.cpp b/test/headless/headless.cpp index cccd0d44b..aac5dda83 100644 --- a/test/headless/headless.cpp +++ b/test/headless/headless.cpp @@ -16,10 +16,10 @@ #include #include -#include - #include +#include + void rewriteLocalScheme(rapidjson::Value &value, rapidjson::Document::AllocatorType &allocator) { ASSERT_TRUE(value.IsString()); auto string = std::string { value.GetString(),value.GetStringLength() }; @@ -154,32 +154,15 @@ TEST_P(HeadlessTest, render) { map.setLatLngZoom(mbgl::LatLng(latitude, longitude), zoom); map.setBearing(bearing); - struct Data { - std::string path; - std::unique_ptr image; - }; + std::promise promise; - uv_async_t *async = new uv_async_t; - async->data = new Data { "test/suite/tests/" + base + "/" + name + "/actual.png", nullptr }; - uv_async_init(uv_default_loop(), async, [](uv_async_t *as, int) { - auto data = std::unique_ptr(reinterpret_cast(as->data)); - as->data = nullptr; - uv_close(reinterpret_cast(as), [](uv_handle_t *handle) { - delete reinterpret_cast(handle); - }); - - assert(data); - const std::string png = util::compress_png(data->image->width, data->image->height, data->image->pixels.get()); - util::write_file(data->path, png); + map.renderStill([&](std::unique_ptr image) { + const std::string png = util::compress_png(image->width, image->height, image->pixels.get()); + util::write_file("test/suite/tests/" + base + "/" + name + "/actual.png", png); + promise.set_value(); }); - map.renderStill([async](std::unique_ptr image) { - reinterpret_cast(async->data)->image = std::move(image); - uv_async_send(async); - }); - - // This loop will terminate once the async was fired. - uv_run(uv_default_loop(), UV_RUN_DEFAULT); + promise.get_future().get(); map.stop(); } From 6f9bcd86af506cd8774eac1c1380e9b50eb72947 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 20 Apr 2015 19:47:24 -0500 Subject: [PATCH 13/20] #1306 - Moving api_mapbox_com.der to iOS Resources directory so that it can be accessed via GL Framework --- gyp/certificates.gypi | 2 +- platform/ios/MGLMapboxEvents.m | 18 +++++++++++++++--- .../ios/resources}/api_mapbox_com.der | Bin 3 files changed, 16 insertions(+), 4 deletions(-) rename {common => platform/ios/resources}/api_mapbox_com.der (100%) diff --git a/gyp/certificates.gypi b/gyp/certificates.gypi index fdd818b8d..1d0c2acf8 100644 --- a/gyp/certificates.gypi +++ b/gyp/certificates.gypi @@ -4,7 +4,7 @@ 'type': 'none', 'hard_dependency': 1, 'copies': [{ - 'files': [ '../common/api_mapbox_com.der', '../common/ca-bundle.crt' ], + 'files': [ '../common/ca-bundle.crt' ], 'destination': '<(PRODUCT_DIR)' }], }, diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index e4b422fe8..90cddba45 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -649,8 +649,21 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { // Load Local Copy of Server's Public Key - // NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"b.ssl.fastly.net" ofType:@"der"]; - NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com" ofType:@"der"]; + NSString *cerPath = nil; + NSArray *bundles = [NSBundle allFrameworks]; + for (int lc = 0; lc < bundles.count; lc++) { + NSBundle *b = [bundles objectAtIndex:lc]; + cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com" ofType:@"der"]; + if (cerPath != nil) { + break; + } + } + if (cerPath == nil) { + NSLog(@"cerPath not found."); + return; + } + +// NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com" ofType:@"der"]; NSData *localCertData = [NSData dataWithContentsOfFile:cerPath]; // Get Server's Public Key @@ -671,7 +684,6 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; } long numKeys = SecTrustGetCertificateCount(serverTrust); - NSLog(@"Number of certificaties presented: %ld", numKeys); BOOL found = false; for (int lc = 0; lc < numKeys; lc++) { diff --git a/common/api_mapbox_com.der b/platform/ios/resources/api_mapbox_com.der similarity index 100% rename from common/api_mapbox_com.der rename to platform/ios/resources/api_mapbox_com.der From 736bdca81e44cc988dfe659ef1e2e26866f9fa42 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 20 Apr 2015 19:59:28 -0500 Subject: [PATCH 14/20] #1306 - Renaming certificate to include geotrust name for easier tracking --- platform/ios/MGLMapboxEvents.m | 7 +------ ...i_mapbox_com.der => api_mapbox_com-geotrust.der} | Bin 2 files changed, 1 insertion(+), 6 deletions(-) rename platform/ios/resources/{api_mapbox_com.der => api_mapbox_com-geotrust.der} (100%) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 90cddba45..b9a138268 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -401,10 +401,6 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:strongSelf startImmediately:NO]; [connection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; [connection start]; - -// [NSURLConnection sendAsynchronousRequest:request -// queue:nil -// completionHandler:nil]; } }); } @@ -653,7 +649,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; NSArray *bundles = [NSBundle allFrameworks]; for (int lc = 0; lc < bundles.count; lc++) { NSBundle *b = [bundles objectAtIndex:lc]; - cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com" ofType:@"der"]; + cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com-geotrust" ofType:@"der"]; if (cerPath != nil) { break; } @@ -663,7 +659,6 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; return; } -// NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com" ofType:@"der"]; NSData *localCertData = [NSData dataWithContentsOfFile:cerPath]; // Get Server's Public Key diff --git a/platform/ios/resources/api_mapbox_com.der b/platform/ios/resources/api_mapbox_com-geotrust.der similarity index 100% rename from platform/ios/resources/api_mapbox_com.der rename to platform/ios/resources/api_mapbox_com-geotrust.der From 7e7f7b827371fd0ee5cb54fbaab5ac1ff59e4874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 21 Apr 2015 15:11:45 +0200 Subject: [PATCH 15/20] copy the styles to the correct location for iOS builds --- gyp/styles.gypi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gyp/styles.gypi b/gyp/styles.gypi index 2c8772a87..8b3032b58 100644 --- a/gyp/styles.gypi +++ b/gyp/styles.gypi @@ -19,7 +19,7 @@ 'hard_dependency': 1, 'dependencies': [ 'touch_styles' ], # required for xcode http://openradar.appspot.com/7232149 'conditions': [ - ['platform_lib == "osx"', { + ['platform_lib == "osx" or platform_lib == "ios"', { 'direct_dependent_settings': { 'mac_bundle_resources': [ '../styles/styles' ], } From a9512295916b8ea70cbd7b5c6cb609f9ec96c82d Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 21 Apr 2015 11:09:22 -0500 Subject: [PATCH 16/20] #1306 - Moving local geoTrustCert to one time setup and cache in immutable NSData object --- platform/ios/MGLMapboxEvents.m | 37 ++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index b9a138268..b4148d067 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -73,6 +73,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; @property (atomic) NSUInteger flushAt; @property (atomic) NSDateFormatter *rfc3339DateFormatter; @property (atomic) CGFloat scale; +@property (atomic) NSData *geoTrustCert; // The isPaused state tracker is only ever accessed from the main thread. @@ -132,11 +133,29 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; _serialQueue = dispatch_queue_create([[NSString stringWithFormat:@"%@.%@.events.serial", _appBundleId, uniqueID] UTF8String], DISPATCH_QUEUE_SERIAL); // Configure Events Infrastructure + // =============================== + + // Load Local Copy of Server's Public Key + NSString *cerPath = nil; + NSArray *bundles = [NSBundle allFrameworks]; + for (int lc = 0; lc < bundles.count; lc++) { + NSBundle *b = [bundles objectAtIndex:lc]; + cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com-geotrust" ofType:@"der"]; + if (cerPath != nil) { + break; + } + } + if (cerPath != nil) { + _geoTrustCert = [NSData dataWithContentsOfFile:cerPath]; + } + + // Events Control _eventQueue = [[NSMutableArray alloc] init]; _flushAt = 20; _flushAfter = 60; _token = nil; _instanceID = [[NSUUID UUID] UUIDString]; + // Dynamic detection of ASIdentifierManager from Mixpanel // https://github.com/mixpanel/mixpanel-iphone/blob/master/LICENSE _advertiserId = @""; @@ -644,23 +663,11 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; #pragma mark NSURLConnectionDelegate - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { - // Load Local Copy of Server's Public Key - NSString *cerPath = nil; - NSArray *bundles = [NSBundle allFrameworks]; - for (int lc = 0; lc < bundles.count; lc++) { - NSBundle *b = [bundles objectAtIndex:lc]; - cerPath = [[NSBundle mainBundle] pathForResource:@"api_mapbox_com-geotrust" ofType:@"der"]; - if (cerPath != nil) { - break; - } - } - if (cerPath == nil) { - NSLog(@"cerPath not found."); + if (_geoTrustCert == nil) { + [[challenge sender] cancelAuthenticationChallenge:challenge]; return; } - NSData *localCertData = [NSData dataWithContentsOfFile:cerPath]; - // Get Server's Public Key SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; @@ -686,7 +693,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); // Compare Remote Key With Local Version - if ([remoteCertificateData isEqualToData:localCertData]) { + if ([remoteCertificateData isEqualToData:_geoTrustCert]) { NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; found = true; From d4add0bfdb9932ac5030c0fcf76383a1ba5673d0 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 21 Apr 2015 11:15:31 -0500 Subject: [PATCH 17/20] #1306 - Removing kSecTrustResultConfirm as it's deprecated --- platform/ios/MGLMapboxEvents.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index b4148d067..4b010463d 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -676,8 +676,6 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; switch (trustResult) { case kSecTrustResultProceed: break; - case kSecTrustResultConfirm: - break; case kSecTrustResultUnspecified: break; default: From 1a43b773af90ece34d7db4a29027efb0abaf3c95 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 21 Apr 2015 17:13:23 -0500 Subject: [PATCH 18/20] #1166 - Initial conversion from NSURLConnection to NSURLSession --- include/mbgl/ios/MGLMapboxEvents.h | 2 +- platform/ios/MGLMapboxEvents.m | 66 ++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/include/mbgl/ios/MGLMapboxEvents.h b/include/mbgl/ios/MGLMapboxEvents.h index 2c6f8151b..7a4c45fe1 100644 --- a/include/mbgl/ios/MGLMapboxEvents.h +++ b/include/mbgl/ios/MGLMapboxEvents.h @@ -25,7 +25,7 @@ extern NSString *const MGLEventGesturePanStart; extern NSString *const MGLEventGesturePinchStart; extern NSString *const MGLEventGestureRotateStart; -@interface MGLMapboxEvents : NSObject +@interface MGLMapboxEvents : NSObject // You must call these methods from the main thread. // diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 4b010463d..42fcaba30 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -73,6 +73,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; @property (atomic) NSUInteger flushAt; @property (atomic) NSDateFormatter *rfc3339DateFormatter; @property (atomic) CGFloat scale; +@property (atomic) NSURLSession *session; @property (atomic) NSData *geoTrustCert; @@ -135,6 +136,8 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; // Configure Events Infrastructure // =============================== + _session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:nil]; + // Load Local Copy of Server's Public Key NSString *cerPath = nil; NSArray *bundles = [NSBundle allFrameworks]; @@ -417,9 +420,17 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [request setHTTPBody:jsonData]; // Send non blocking HTTP Request to server - NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:strongSelf startImmediately:NO]; - [connection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; - [connection start]; + NSURLSessionDataTask *task = [_session dataTaskWithRequest:request + completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) { + + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + NSLog(@"Response Code = %ld", (long)httpResponse.statusCode); + }]; + [task resume]; + +// NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:strongSelf startImmediately:NO]; +// [connection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; +// [connection start]; } }); } @@ -660,6 +671,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; return result; } +/* #pragma mark NSURLConnectionDelegate - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { @@ -703,5 +715,53 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [[challenge sender] cancelAuthenticationChallenge:challenge]; } } +*/ + +#pragma mark NSURLSessionDelegate +- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^) (NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { + + if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + + SecTrustRef serverTrust = [[challenge protectionSpace] serverTrust]; + NSString *domain = [[challenge protectionSpace] host]; + SecTrustResultType trustResult; + + // Validate the certificate chain with the device's trust store anyway + // This *might* give use revocation checking + SecTrustEvaluate(serverTrust, &trustResult); + if (trustResult == kSecTrustResultUnspecified) + { + // Look for a pinned certificate in the server's certificate chain + long numKeys = SecTrustGetCertificateCount(serverTrust); + + BOOL found = false; + for (int lc = 0; lc < numKeys; lc++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); + NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); + + // Compare Remote Key With Local Version + if ([remoteCertificateData isEqualToData:_geoTrustCert]) { + // Found the certificate; continue connecting + completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); + found = true; + break; + } + } + + if (!found) { + // The certificate wasn't found in the certificate chain; cancel the connection + completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); + } + NSLog(@"challenge result = %hhd", found); + } + else + { + // Certificate chain validation failed; cancel the connection + completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); + NSLog(@"challenge chain validation failed"); + } + } + +} @end From d4264edea347cca162ff3c6313db0bf9b00e33e2 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 21 Apr 2015 17:19:37 -0500 Subject: [PATCH 19/20] #1166 - Cleaning up logs and old NSURLConnection code --- platform/ios/MGLMapboxEvents.m | 59 +--------------------------------- 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 42fcaba30..c4bd7cf0b 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -420,17 +420,8 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [request setHTTPBody:jsonData]; // Send non blocking HTTP Request to server - NSURLSessionDataTask *task = [_session dataTaskWithRequest:request - completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) { - - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; - NSLog(@"Response Code = %ld", (long)httpResponse.statusCode); - }]; + NSURLSessionDataTask *task = [_session dataTaskWithRequest:request completionHandler: nil]; [task resume]; - -// NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:strongSelf startImmediately:NO]; -// [connection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; -// [connection start]; } }); } @@ -671,52 +662,6 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; return result; } -/* -#pragma mark NSURLConnectionDelegate -- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { - - if (_geoTrustCert == nil) { - [[challenge sender] cancelAuthenticationChallenge:challenge]; - return; - } - - // Get Server's Public Key - SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; - - SecTrustResultType trustResult; - SecTrustEvaluate(serverTrust, &trustResult); - switch (trustResult) { - case kSecTrustResultProceed: - break; - case kSecTrustResultUnspecified: - break; - default: - [[challenge sender] cancelAuthenticationChallenge:challenge]; - return; - } - - long numKeys = SecTrustGetCertificateCount(serverTrust); - - BOOL found = false; - for (int lc = 0; lc < numKeys; lc++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); - NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); - - // Compare Remote Key With Local Version - if ([remoteCertificateData isEqualToData:_geoTrustCert]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - found = true; - break; - } - } - - if (!found) { - [[challenge sender] cancelAuthenticationChallenge:challenge]; - } -} -*/ - #pragma mark NSURLSessionDelegate - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^) (NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { @@ -752,13 +697,11 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; // The certificate wasn't found in the certificate chain; cancel the connection completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); } - NSLog(@"challenge result = %hhd", found); } else { // Certificate chain validation failed; cancel the connection completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - NSLog(@"challenge chain validation failed"); } } From 87409b12342929d0a52cc7b825bc814f6959e882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 21 Apr 2015 15:58:55 -0700 Subject: [PATCH 20/20] Constrain user dot to superview margins When the screen changes orientation, the user dot should always appear at the correct location. Fixed #1313. --- platform/ios/MGLMapView.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 5acf04ef7..5f5e99b0e 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1701,6 +1701,8 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng) } self.userLocationAnnotationView = [[MGLUserLocationAnnotationView alloc] initInMapView:self]; + self.userLocationAnnotationView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | + UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); self.locationManager = [CLLocationManager new];