From f964e40e7e9220d08751d8607af61ac5a7c0794c Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sun, 3 Apr 2016 15:16:49 -0700 Subject: [build] Refactor and simplify build system * Main gyp files are now standardized as platform//platform.gyp. * Each platform gyp file defines appropriate loop_lib and headless_lib variables. * Each platform gyp file includes mbgl.gypi, which defines base targets which may be useful to all platforms. * CI targets are consistent across platforms: `make $(PLATFORM) && make test-$(PLATFORM)`. * Renamed the "linux" test app to "glfw". It's now built in OS X CI. * Android build flakiness is fixed. * iOS CI builds the bench and iosapp targets. * Mesa version is now in one place. * CI scripts use bash "strict mode" and correct error handling. * All build output goes to the build directory. * Removed vestigial iOS/OS X/Android Travis scripts. --- .gitignore | 29 +-- .travis.yml | 111 ++++----- Makefile | 202 ++++++--------- bin/glfw.cpp | 176 +++++++++++++ bin/glfw.gypi | 62 +++++ bin/offline.gypi | 42 ++-- bin/render.gypi | 48 ++-- binding.gyp | 74 +++++- configure | 26 +- docker/clang-tidy/tidy.sh | 3 +- docker/linux/test.sh | 5 +- gyp/android.gyp | 5 - gyp/asset-fs.gypi | 52 ---- gyp/asset-zip.gypi | 74 ------ gyp/certificates.gypi | 12 - gyp/common.gypi | 139 ----------- gyp/core.gypi | 80 ------ gyp/headless-cgl.gypi | 19 -- gyp/headless-eagl.gypi | 19 -- gyp/headless-glx.gypi | 25 -- gyp/http-android.gypi | 53 ---- gyp/http-curl.gypi | 78 ------ gyp/http-nsurl.gypi | 45 ---- gyp/ios.gyp | 8 - gyp/linux.gyp | 11 - gyp/mbgl.gyp | 83 ------- gyp/none.gypi | 20 -- gyp/osx.gyp | 14 -- gyp/platform-android.gypi | 92 ------- gyp/platform-ios.gypi | 141 ----------- gyp/platform-linux.gypi | 97 -------- gyp/platform-osx.gypi | 122 --------- gyp/shaders.gypi | 32 --- gyp/target-ios-bundle.gypi | 5 - gyp/target-ios.gypi | 27 -- gyp/version.gypi | 29 --- mbgl.gypi | 293 ++++++++++++++++++++++ package.json | 7 +- platform/android/.gitignore | 1 - platform/android/bitrise.yml | 53 +--- platform/android/mapboxgl-app.gypi | 148 ----------- platform/android/platform.gyp | 151 ++++++++++++ platform/android/scripts/defaults.mk | 11 - platform/android/scripts/install.sh | 13 - platform/android/scripts/run.sh | 56 ----- platform/ios/app/mapboxgl-app.gypi | 81 ------ platform/ios/benchmark/benchmark-ios.gypi | 78 ------ platform/ios/bitrise.yml | 9 +- platform/ios/framework/framework-ios.gypi | 71 ------ platform/ios/platform.gyp | 382 +++++++++++++++++++++++++++++ platform/ios/scripts/after_failure.sh | 13 - platform/ios/scripts/defaults.mk | 9 - platform/ios/scripts/install.sh | 20 -- platform/ios/scripts/package.sh | 46 ++-- platform/ios/scripts/run.sh | 52 ---- platform/ios/scripts/setup.sh | 5 - platform/ios/scripts/test.sh | 7 - platform/linux/README.md | 7 +- platform/linux/main.cpp | 176 ------------- platform/linux/mapboxgl-app.gypi | 66 ----- platform/linux/platform.gyp | 97 ++++++++ platform/linux/scripts/after_script.sh | 10 +- platform/linux/scripts/coveralls.sh | 23 +- platform/linux/scripts/defaults.mk | 5 - platform/linux/scripts/install.sh | 11 - platform/linux/scripts/run.sh | 31 --- platform/linux/scripts/setup.sh | 28 --- platform/linux/scripts/tidy.sh | 17 -- platform/node/bitrise.yml | 21 +- platform/node/scripts/after_script.sh | 50 +--- platform/node/scripts/install.sh | 24 -- platform/node/scripts/run.sh | 15 -- platform/osx/app/mapboxgl-app.gypi | 77 ------ platform/osx/bitrise.yml | 12 +- platform/osx/platform.gyp | 328 +++++++++++++++++++++++++ platform/osx/scripts/configure.sh | 2 - platform/osx/scripts/defaults.mk | 5 - platform/osx/scripts/install.sh | 7 - platform/osx/scripts/osxsdk.xcscheme | 99 -------- platform/osx/scripts/osxtest.xcscheme | 56 +++++ platform/osx/scripts/package.sh | 56 ----- platform/osx/scripts/run.sh | 21 -- platform/osx/scripts/setup.sh | 8 - platform/osx/scripts/test.sh | 19 -- platform/osx/sdk/framework-osx.gypi | 68 ----- platform/osx/test/osxtest.gypi | 84 ------- scripts/clang-tidy.sh | 2 +- scripts/collect-coverage.sh | 18 +- scripts/coveralls.sh | 37 --- scripts/flock.py | 29 --- scripts/main.mk | 198 ++++++--------- scripts/run_tests.sh | 32 --- scripts/set_compiler.sh | 27 -- scripts/tidy.sh | 17 ++ scripts/travis_setup.sh | 56 +++++ test/api/render_missing.cpp | 10 +- test/storage/http_error.cpp | 11 - test/storage/http_retry_network_status.cpp | 11 - test/test.gypi | 41 +--- 99 files changed, 2034 insertions(+), 3444 deletions(-) create mode 100644 bin/glfw.cpp create mode 100644 bin/glfw.gypi delete mode 100644 gyp/android.gyp delete mode 100644 gyp/asset-fs.gypi delete mode 100644 gyp/asset-zip.gypi delete mode 100644 gyp/certificates.gypi delete mode 100644 gyp/common.gypi delete mode 100644 gyp/core.gypi delete mode 100644 gyp/headless-cgl.gypi delete mode 100644 gyp/headless-eagl.gypi delete mode 100644 gyp/headless-glx.gypi delete mode 100644 gyp/http-android.gypi delete mode 100644 gyp/http-curl.gypi delete mode 100644 gyp/http-nsurl.gypi delete mode 100644 gyp/ios.gyp delete mode 100644 gyp/linux.gyp delete mode 100644 gyp/mbgl.gyp delete mode 100644 gyp/none.gypi delete mode 100644 gyp/osx.gyp delete mode 100644 gyp/platform-android.gypi delete mode 100644 gyp/platform-ios.gypi delete mode 100644 gyp/platform-linux.gypi delete mode 100644 gyp/platform-osx.gypi delete mode 100644 gyp/shaders.gypi delete mode 100644 gyp/target-ios-bundle.gypi delete mode 100644 gyp/target-ios.gypi delete mode 100644 gyp/version.gypi create mode 100644 mbgl.gypi delete mode 100644 platform/android/mapboxgl-app.gypi create mode 100644 platform/android/platform.gyp delete mode 100644 platform/android/scripts/defaults.mk delete mode 100755 platform/android/scripts/install.sh delete mode 100755 platform/android/scripts/run.sh delete mode 100644 platform/ios/app/mapboxgl-app.gypi delete mode 100644 platform/ios/benchmark/benchmark-ios.gypi delete mode 100644 platform/ios/framework/framework-ios.gypi create mode 100644 platform/ios/platform.gyp delete mode 100755 platform/ios/scripts/after_failure.sh delete mode 100644 platform/ios/scripts/defaults.mk delete mode 100755 platform/ios/scripts/install.sh delete mode 100755 platform/ios/scripts/run.sh delete mode 100644 platform/ios/scripts/setup.sh delete mode 100755 platform/ios/scripts/test.sh delete mode 100644 platform/linux/main.cpp delete mode 100644 platform/linux/mapboxgl-app.gypi create mode 100644 platform/linux/platform.gyp delete mode 100644 platform/linux/scripts/defaults.mk delete mode 100755 platform/linux/scripts/install.sh delete mode 100755 platform/linux/scripts/run.sh delete mode 100755 platform/linux/scripts/setup.sh delete mode 100755 platform/linux/scripts/tidy.sh delete mode 100755 platform/node/scripts/install.sh delete mode 100755 platform/node/scripts/run.sh delete mode 100644 platform/osx/app/mapboxgl-app.gypi create mode 100644 platform/osx/platform.gyp delete mode 100644 platform/osx/scripts/defaults.mk delete mode 100755 platform/osx/scripts/install.sh delete mode 100644 platform/osx/scripts/osxsdk.xcscheme create mode 100644 platform/osx/scripts/osxtest.xcscheme delete mode 100755 platform/osx/scripts/package.sh delete mode 100755 platform/osx/scripts/run.sh delete mode 100755 platform/osx/scripts/setup.sh delete mode 100755 platform/osx/scripts/test.sh delete mode 100644 platform/osx/sdk/framework-osx.gypi delete mode 100644 platform/osx/test/osxtest.gypi delete mode 100755 scripts/coveralls.sh delete mode 100755 scripts/flock.py delete mode 100755 scripts/run_tests.sh delete mode 100755 scripts/set_compiler.sh create mode 100755 scripts/tidy.sh create mode 100755 scripts/travis_setup.sh diff --git a/.gitignore b/.gitignore index 68e242a31b..218297e317 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,14 @@ .DS_Store -*.xcodeproj -*.o -*.actual.png -*.diff.png *.pyc *.gcno *.gcda +*~ offline.db -/platform/android/debug -/platform/android/sdk -/platform/android/**/.classpath -/platform/android/**/.project -/platform/android/**/.settings/ +/platform/node/test/actual +/platform/node/test/diff /mason_packages -/config/*.gypi /build /lib -/ios/build -/ios/app/build -/test/build -/gyp/build -/gyp/java /test/node_modules /test/fixtures/*/*_actual.* /test/fixtures/api/1.png @@ -30,15 +18,4 @@ offline.db /test/fixtures/**/actual.png /test/fixtures/**/diff.png /test/output -/include/mbgl/shader/shaders.hpp -/src/shader/shaders_gl.cpp -/src/shader/shaders_gles2.cpp -/bin/style.bin.js /node_modules -*~ - -/ios/benchmark/assets/tiles/mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v6/ -/ios/benchmark/assets/glyphs/DIN Offc Pro*/ - -/platform/node/test/actual -/platform/node/test/diff diff --git a/.travis.yml b/.travis.yml index 79090a21a7..cf2d04abd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ -language: cpp - sudo: false +git: + submodules: false + # Save common build configurations as shortcuts, so we can reference them later. addons_shortcuts: addons_clang35: &clang35 @@ -15,39 +16,69 @@ addons_shortcuts: packages: [ 'gdb', 'g++-4.9', 'gcc-4.9', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ] +env: + global: + - TERM: dumb + - CCACHE: 1 + # 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=" + +install: + - source ./scripts/travis_helper.sh + - source ./scripts/travis_setup.sh +before_script: + - ccache --zero-stats +script: + - make linux + - make test-linux +after_script: + - ccache --show-stats + - ./platform/linux/scripts/after_script.sh ${TRAVIS_JOB_NUMBER} ${TRAVIS_TAG:-} + matrix: - exclude: - - os: linux include: - - # Linux/Node.js 4 - Clang 3.5 - Release - - os: linux + # Clang 3.5 - Release - Node + - language: node compiler: ": node4-clang35-release" - env: FLAVOR=node BUILDTYPE=Release NODE_VERSION=4 _CXX=clang++-3.5 _CC=clang-3.5 CCACHE=1 + env: BUILDTYPE=Release _CXX=clang++-3.5 _CC=clang-3.5 addons: *clang35 - - # Linux - GCC 4.9 - Debug - - os: linux + script: + - nvm install 4 + - nvm use 4 + - make node + - make test-node + after_script: + - ccache --show-stats + - ./platform/node/scripts/after_script.sh ${TRAVIS_JOB_NUMBER} ${TRAVIS_TAG:-} + + # GCC 4.9 - Debug - Coverage + - language: cpp compiler: ": linux-gcc49-debug" - env: FLAVOR=linux ACTION=coveralls _CXX=g++-4.9 _CC=gcc-4.9 CCACHE=1 + env: BUILDTYPE=Debug _CXX=g++-4.9 _CC=gcc-4.9 ENABLE_COVERAGE=1 addons: *gcc49 + after_script: + - ccache --show-stats + - ./platform/linux/scripts/coveralls.sh - # Linux - GCC 4.9 - Release - - os: linux + # GCC 4.9 - Release + - language: cpp compiler: ": linux-gcc49-release" - env: FLAVOR=linux BUILDTYPE=Release _CXX=g++-4.9 _CC=gcc-4.9 CCACHE=1 + env: BUILDTYPE=Release _CXX=g++-4.9 _CC=gcc-4.9 addons: *gcc49 - # Linux - Clang 3.5 - Debug - - os: linux + # Clang 3.5 - Debug + - language: cpp compiler: ": linux-clang35-debug" - env: FLAVOR=linux BUILDTYPE=Debug _CXX=clang++-3.5 _CC=clang-3.5 CCACHE=1 + env: BUILDTYPE=Debug _CXX=clang++-3.5 _CC=clang-3.5 addons: *clang35 - # Linux - Clang 3.5 - Release - - os: linux + # Clang 3.5 - Release + - language: cpp compiler: ": linux-clang35-release" - env: FLAVOR=linux BUILDTYPE=Release _CXX=clang++-3.5 _CC=clang-3.5 CCACHE=1 + env: BUILDTYPE=Release _CXX=clang++-3.5 _CC=clang-3.5 addons: *clang35 cache: @@ -57,44 +88,6 @@ cache: - $HOME/build/mapbox/mapbox-gl-native/.binaries - $HOME/build/mapbox/mapbox-gl-native/.scripts -env: - global: - - 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=" - -before_install: -- source ./scripts/set_compiler.sh -- source ./scripts/travis_helper.sh -- if [[ ${ACTION:-0} == 'coveralls' ]]; then - rvm install 2.3.0; - rvm use 2.3.0; - rvm rubygems latest --force; - gem install coveralls-lcov; - fi - -install: -- ./platform/${FLAVOR}/scripts/install.sh - -before_script: -- if command -v ccache >/dev/null 2>&1; then ccache --zero-stats ; fi - -script: -- ./platform/${FLAVOR}/scripts/${ACTION:-run}.sh - -after_failure: -- "[ -f ./platform/${FLAVOR}/scripts/after_failure.sh ] && ./platform/${FLAVOR}/scripts/after_failure.sh" - -after_script: -- if command -v ccache >/dev/null 2>&1; then ccache --show-stats ; fi -- "[ -f ./platform/${FLAVOR}/scripts/after_script.sh ] && ./platform/${FLAVOR}/scripts/after_script.sh" - notifications: slack: secure: HHQYr7sF8M1SzoWSqgKVYtwAgGdLLCyTMsQjFhEEQNYO92ZwURE5s03qWTGH5k8+4Yqn26yrXt3NztLC4JIOpcGervN2mSZyq4dZgFTcWEd61igw0qwSenlwvFfbE1ASK/KYCzfyn9MIfHN+ovwLoRxXZkPwinKDvl3DXjBaFNg= - -git: - submodules: false diff --git a/Makefile b/Makefile index f9dc5b4981..4ea77aa310 100644 --- a/Makefile +++ b/Makefile @@ -1,147 +1,92 @@ export BUILDTYPE ?= Release -export BUILD_TEST ?= 1 -export BUILD_RENDER ?= 1 -export BUILD_OFFLINE ?= 1 export ENABLE_COVERAGE ?= 0 -# Determine build platform ifeq ($(shell uname -s), Darwin) -export BUILD = osx -export JOBS ?= $(shell sysctl -n hw.ncpu) + export JOBS ?= $(shell sysctl -n hw.ncpu) else ifeq ($(shell uname -s), Linux) -export BUILD = linux -export JOBS ?= $(shell grep --count processor /proc/cpuinfo) + export JOBS ?= $(shell grep --count processor /proc/cpuinfo) else -$(error Cannot determine build platform) + $(error Cannot determine host platform) endif -export BUILD_VERSION = $(shell uname -m) - -RUN = +$(MAKE) -f scripts/main.mk +RUN = +$(MAKE) -f scripts/main.mk default: @printf "You must specify a valid target\n" #### OS X targets ############################################################## -.PHONY: osx -osx: - $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/osxapp - -.PHONY: run-osx -run-osx: osx - "gyp/build/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL" - -.PHONY: Xcode/osx -Xcode/osx: - $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/__project__ +OSX_PROJ_PATH = build/osx-x86_64/platform/osx/platform.xcodeproj -.PHONY: xproj -xproj: Xcode/osx - open ./build/osx-x86_64/gyp/osx.xcodeproj +osx: + $(RUN) PLATFORM=osx Xcode/All -.PHONY: xpackage -xpackage: Xcode/osx - ./platform/osx/scripts/package.sh +$(OSX_PROJ_PATH): + $(RUN) PLATFORM=osx Xcode/__project__ -.PHONY: xpackage-strip -xpackage-strip: Xcode/osx - ./platform/osx/scripts/package.sh strip +xproj: $(OSX_PROJ_PATH) + open $(OSX_PROJ_PATH) -.PHONY: xtest -xtest: - $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/test +$(OSX_PROJ_PATH)/xcshareddata/xcschemes/osxtest.xcscheme: platform/osx/scripts/osxtest.xcscheme $(OSX_PROJ_PATH) + mkdir -p $(basename $@) + cp $< $@ -.PHONY: xctest -xctest: Xcode/osx - ./platform/osx/scripts/test.sh +test-osx: $(OSX_PROJ_PATH)/xcshareddata/xcschemes/osxtest.xcscheme node_modules/express + xcodebuild -project $(OSX_PROJ_PATH) -configuration $(BUILDTYPE) -target test build + build/osx-x86_64/$(BUILDTYPE)/test + xcodebuild -project $(OSX_PROJ_PATH) -configuration $(BUILDTYPE) -scheme osxtest test #### iOS targets ############################################################## -.PHONY: Xcode/ios -Xcode/ios: - $(RUN) HOST=ios Xcode/__project__ - -.PHONY: iproj -iproj: Xcode/ios - open ./build/ios-all/gyp/ios.xcodeproj +IOS_PROJ_PATH = build/ios-all/platform/ios/platform.xcodeproj -.PHONY: ios ios: - $(RUN) HOST=ios XCODEBUILD_ARGS='-sdk iphoneos ARCHS="arm64 armv7 armv7s"' Xcode/iosapp + $(RUN) PLATFORM=ios Xcode/All -.PHONY: isim -isim: - $(RUN) HOST=ios XCODEBUILD_ARGS='-sdk iphonesimulator ARCHS="x86_64 i386"' Xcode/iosapp +$(IOS_PROJ_PATH): + $(RUN) PLATFORM=ios Xcode/__project__ -.PHONY: ibench -ibench: - $(RUN) HOST=ios XCODEBUILD_ARGS='-sdk iphoneos ARCHS="arm64"' Xcode/ios-bench +iproj: $(IOS_PROJ_PATH) + open $(IOS_PROJ_PATH) -.PHONY: ipackage -ipackage: Xcode/ios +test-ios: + # Currently nothing + +ipackage: $(IOS_PROJ_PATH) BITCODE=$(BITCODE) FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=$(SYMBOLS) \ BUNDLE_RESOURCES=YES PLACE_RESOURCE_BUNDLES_OUTSIDE_FRAMEWORK=YES \ ./platform/ios/scripts/package.sh -.PHONY: ipackage-strip -ipackage-strip: Xcode/ios +ipackage-strip: $(IOS_PROJ_PATH) BITCODE=$(BITCODE) FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=NO \ BUNDLE_RESOURCES=YES PLACE_RESOURCE_BUNDLES_OUTSIDE_FRAMEWORK=YES \ ./platform/ios/scripts/package.sh -.PHONY: ipackage-sim -ipackage-sim: Xcode/ios +ipackage-sim: $(IOS_PROJ_PATH) BUILDTYPE=Debug BITCODE=$(BITCODE) FORMAT=dynamic BUILD_DEVICE=false SYMBOLS=$(SYMBOLS) \ BUNDLE_RESOURCES=YES PLACE_RESOURCE_BUNDLES_OUTSIDE_FRAMEWORK=YES \ ./platform/ios/scripts/package.sh -.PHONY: iframework -iframework: Xcode/ios +iframework: $(IOS_PROJ_PATH) BITCODE=$(BITCODE) FORMAT=dynamic BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=$(SYMBOLS) \ ./platform/ios/scripts/package.sh -.PHONY: ifabric -ifabric: Xcode/ios +ifabric: $(IOS_PROJ_PATH) BITCODE=$(BITCODE) FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=NO BUNDLE_RESOURCES=YES \ ./platform/ios/scripts/package.sh -.PHONY: itest -itest: ipackage-sim - ./platform/ios/scripts/test.sh - -.PHONY: idocument idocument: OUTPUT=$(OUTPUT) ./platform/ios/scripts/document.sh -#### Linux targets ##################################################### - -.PHONY: linux -linux: - $(RUN) Makefile/linuxapp - -.PHONY: nlinux -nlinux: - $(RUN) Ninja/linuxapp - -.PHONY: run-linux -run-linux: linux - (cd build/$(BUILD)-$(BUILD_VERSION)/$(BUILDTYPE) && ./mapbox-gl) - -.PHONY: run-valgrind-linux -run-valgrind-linux: linux - (cd build/$(BUILD)-$(BUILD_VERSION)/$(BUILDTYPE) && valgrind --leak-check=full --suppressions=../../../scripts/valgrind.sup ./mapbox-gl) - #### Android targets ##################################################### # Builds a particular android architecture. android-lib-%: - $(RUN) HOST=android HOST_VERSION=$* Makefile/androidapp + $(RUN) PLATFORM=android SUBPLATFORM=$* Makefile/all # Builds the default Android library .PHONY: android-lib -android-lib: - $(RUN) HOST=android Makefile/androidapp +android-lib: android-lib-arm-v7 # Builds the selected/default Android library .PHONY: android @@ -153,42 +98,64 @@ android: android-lib apackage: android-lib-arm-v5 android-lib-arm-v7 android-lib-arm-v8 android-lib-x86 android-lib-x86-64 android-lib-mips cd platform/android && ./gradlew --parallel-threads=$(JOBS) assemble$(BUILDTYPE) +test-android: + cd platform/android && ./gradlew testReleaseUnitTest --continue + #### Node targets ##################################################### -# Builds the Node.js library -.PHONY: node -node: - $(RUN) LOOP=uv HTTP=none ASSET=none Makefile/node +node_modules: package.json + npm update # Install dependencies but don't run our own install script. -.PHONY: Xcode/node -Xcode/node: - $(RUN) LOOP=uv HTTP=none ASSET=none Xcode/node +.PHONY: node +node: node_modules + $(RUN) PLATFORM=node Makefile/node .PHONY: xnode -xnode: Xcode/node +xnode: + $(RUN) Xcode/node + ./platform/node/scripts/create_node_scheme.sh "node test" "`npm bin tape`/tape platform/node/test/js/**/*.test.js" + ./platform/node/scripts/create_node_scheme.sh "npm run test-suite" "platform/node/test/render.test.js" open ./build/binding.xcodeproj -.PHONY: nproj -nproj: - $(RUN) LOOP=uv HTTP=none ASSET=none node/xproj - open ./build/binding.xcodeproj +.PHONY: test-node +test-node: node + npm test + npm run test-suite #### Miscellaneous targets ##################################################### +.PHONY: linux +linux: glfw-app render offline + +.PHONY: test-linux +test-linux: test-* + +.PHONY: glfw-app +glfw-app: + $(RUN) Makefile/glfw-app + +.PHONY: run-glfw-app +run-glfw-app: + $(RUN) run-glfw-app + +.PHONY: run-valgrind-glfw-app +run-valgrind-glfw-app: + $(RUN) run-valgrind-glfw-app + .PHONY: test test: $(RUN) Makefile/test -test-%: +test-%: node_modules/express $(RUN) test-$* +node_modules/express: + npm install express@4.11.1 + .PHONY: check check: $(RUN) BUILDTYPE=Debug ENABLE_COVERAGE=1 check -coveralls: - $(RUN) BUILDTYPE=Debug ENABLE_COVERAGE=1 coveralls - .PHONY: render render: $(RUN) Makefile/mbgl-render @@ -197,10 +164,6 @@ render: offline: $(RUN) Makefile/mbgl-offline -.PHONY: config -config: - $(RUN) config - # Generates a compilation database with ninja for use in clang tooling .PHONY: compdb compdb: @@ -210,32 +173,13 @@ compdb: tidy: $(RUN) tidy -.PHONY: clear_xcode_cache -clear_xcode_cache: -ifeq ($(BUILD), osx) - @CUSTOM_DD=`defaults read com.apple.dt.Xcode IDECustomDerivedDataLocation 2>/dev/null`; \ - if [ $$CUSTOM_DD ]; then \ - echo clearing files in $$CUSTOM_DD older than one day; \ - find $$CUSTOM_DD/mapboxgl-app-* -mtime +1 | xargs rm -rf; \ - find $$CUSTOM_DD/osxapp-* -mtime +1 | xargs rm -rf; \ - fi; \ - if [ -d ~/Library/Developer/Xcode/DerivedData/ ] && [ ! $$CUSTOM_DD ]; then \ - echo 'clearing files in ~/Library/Developer/Xcode/DerivedData/{mapboxgl-app,osxapp}-* older than one day'; \ - find ~/Library/Developer/Xcode/DerivedData/mapboxgl-app-* -mtime +1 | xargs rm -rf; \ - find ~/Library/Developer/Xcode/DerivedData/osxapp-* -mtime +1 | xargs rm -rf; \ - fi -endif - -clean: clear_xcode_cache +clean: -find ./deps/gyp -name "*.pyc" -exec rm {} \; -find ./build -type f -not -path '*/*.xcodeproj/*' -exec rm {} \; - -rm -rf ./gyp/build/ - -rm -rf ./config/*.gypi -rm -rf ./platform/android/MapboxGLAndroidSDK/build \ ./platform/android/MapboxGLAndroidSDKTestApp/build \ ./platform/android/MapboxGLAndroidSDK/src/main/jniLibs \ ./platform/android/MapboxGLAndroidSDKTestApp/src/main/jniLibs \ - ./platform/android/MapboxGLAndroidSDK/src/main/obj.target \ ./platform/android/MapboxGLAndroidSDK/src/main/assets distclean: clean diff --git a/bin/glfw.cpp b/bin/glfw.cpp new file mode 100644 index 0000000000..98fb32075e --- /dev/null +++ b/bin/glfw.cpp @@ -0,0 +1,176 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace { + +std::unique_ptr view; + +} + +void quit_handler(int) { + if (view) { + mbgl::Log::Info(mbgl::Event::Setup, "waiting for quit..."); + view->setShouldClose(); + } else { + exit(0); + } +} + +int main(int argc, char *argv[]) { + bool fullscreen = false; + bool benchmark = false; + std::string style; + double latitude = 0, longitude = 0; + double bearing = 0, zoom = 1, pitch = 0; + bool skipConfig = false; + + const struct option long_options[] = { + {"fullscreen", no_argument, 0, 'f'}, + {"benchmark", no_argument, 0, 'b'}, + {"style", required_argument, 0, 's'}, + {"lon", required_argument, 0, 'x'}, + {"lat", required_argument, 0, 'y'}, + {"zoom", required_argument, 0, 'z'}, + {"bearing", required_argument, 0, 'r'}, + {"pitch", required_argument, 0, 'p'}, + {0, 0, 0, 0} + }; + + while (true) { + int option_index = 0; + int opt = getopt_long(argc, argv, "fbs:", long_options, &option_index); + if (opt == -1) break; + switch (opt) + { + case 0: + if (long_options[option_index].flag != 0) + break; + case 'f': + fullscreen = true; + break; + case 'b': + benchmark = true; + break; + case 's': + style = std::string("asset://") + std::string(optarg); + break; + case 'x': + longitude = atof(optarg); + skipConfig = true; + break; + case 'y': + latitude = atof(optarg); + skipConfig = true; + break; + case 'z': + zoom = atof(optarg); + skipConfig = true; + break; + case 'r': + bearing = atof(optarg); + skipConfig = true; + break; + case 'p': + pitch = atof(optarg); + skipConfig = true; + break; + default: + break; + } + + } + + // sigint handling + struct sigaction sigIntHandler; + sigIntHandler.sa_handler = quit_handler; + sigemptyset(&sigIntHandler.sa_mask); + sigIntHandler.sa_flags = 0; + sigaction(SIGINT, &sigIntHandler, NULL); + + if (benchmark) { + mbgl::Log::Info(mbgl::Event::General, "BENCHMARK MODE: Some optimizations are disabled."); + } + + view = std::make_unique(fullscreen, benchmark); + + mbgl::DefaultFileSource fileSource("/tmp/mbgl-cache.db", "."); + + // Set access token if present + const char *token = getenv("MAPBOX_ACCESS_TOKEN"); + if (token == nullptr) { + mbgl::Log::Warning(mbgl::Event::Setup, "no access token set. mapbox.com tiles won't work."); + } else { + fileSource.setAccessToken(std::string(token)); + } + + mbgl::Map map(*view, fileSource); + + // Load settings + mbgl::Settings_JSON settings; + + if (skipConfig) { + map.setLatLngZoom(mbgl::LatLng(latitude, longitude), zoom); + map.setBearing(bearing); + map.setPitch(pitch); + mbgl::Log::Info(mbgl::Event::General, "Location: %f/%f (z%.2f, %.2f deg)", latitude, longitude, zoom, bearing); + } else { + map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom); + map.setBearing(settings.bearing); + map.setPitch(settings.pitch); + map.setDebug(mbgl::MapDebugOptions(settings.debug)); + } + + view->setChangeStyleCallback([&map] () { + static uint8_t currentStyleIndex; + + if (++currentStyleIndex == mbgl::util::default_styles::numOrderedStyles) { + currentStyleIndex = 0; + } + + mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[currentStyleIndex]; + map.setStyleURL(newStyle.url); + view->setWindowTitle(newStyle.name); + + mbgl::Log::Info(mbgl::Event::Setup, "Changed style to: %s", newStyle.name); + }); + + // Load style + if (style.empty()) { + mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[0]; + style = newStyle.url; + view->setWindowTitle(newStyle.name); + } + + map.setStyleURL(style); + + view->run(); + + // Save settings + mbgl::LatLng latLng = map.getLatLng(); + settings.latitude = latLng.latitude; + settings.longitude = latLng.longitude; + settings.zoom = map.getZoom(); + settings.bearing = map.getBearing(); + settings.pitch = map.getPitch(); + settings.debug = mbgl::EnumType(map.getDebug()); + if (!skipConfig) { + settings.save(); + } + mbgl::Log::Info(mbgl::Event::General, + "Exit location: --lat=\"%f\" --lon=\"%f\" --zoom=\"%f\" --bearing \"%f\"", + settings.latitude, settings.longitude, settings.zoom, settings.bearing); + + return 0; +} diff --git a/bin/glfw.gypi b/bin/glfw.gypi new file mode 100644 index 0000000000..548c5c2d4d --- /dev/null +++ b/bin/glfw.gypi @@ -0,0 +1,62 @@ +{ + 'targets': [ + { + 'target_name': 'glfw-app', + 'product_name': 'mapbox-glfw', + 'type': 'executable', + + 'dependencies': [ + 'platform-lib', + 'copy_certificate_bundle', + ], + + 'include_dirs': [ + '../platform/default', + '../include', + '../src', + ], + + 'sources': [ + 'glfw.cpp', + '../platform/default/settings_json.cpp', + '../platform/default/glfw_view.hpp', + '../platform/default/glfw_view.cpp', + '../platform/default/log_stderr.cpp', + ], + + 'variables': { + 'cflags_cc': [ + '<@(glfw_cflags)', + '<@(variant_cflags)', + '<@(boost_cflags)', + ], + 'ldflags': [ + '<@(glfw_ldflags)', + ], + 'libraries': [ + '<@(glfw_static_libs)', + ], + }, + + 'conditions': [ + ['OS == "mac"', { + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], + }, + }, { + 'cflags_cc': [ '<@(cflags_cc)' ], + }], + ], + 'link_settings': { + 'conditions': [ + ['OS == "mac"', { + 'libraries': [ '<@(libraries)' ], + 'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(ldflags)' ] } + }, { + 'libraries': [ '<@(libraries)', '<@(ldflags)' ], + }] + ], + }, + }, + ], +} diff --git a/bin/offline.gypi b/bin/offline.gypi index 885a199b36..acdd17a749 100644 --- a/bin/offline.gypi +++ b/bin/offline.gypi @@ -1,49 +1,39 @@ { - 'includes': [ - '../gyp/common.gypi', - ], 'targets': [ - { 'target_name': 'mbgl-offline', + { + 'target_name': 'mbgl-offline', 'product_name': 'mbgl-offline', 'type': 'executable', 'dependencies': [ - 'mbgl.gyp:core', - 'mbgl.gyp:platform-<(platform_lib)', - 'mbgl.gyp:headless-<(headless_lib)', - 'mbgl.gyp:http-<(http_lib)', - 'mbgl.gyp:asset-<(asset_lib)', - 'mbgl.gyp:copy_certificate_bundle', + 'platform-lib', + 'copy_certificate_bundle', ], 'include_dirs': [ + '../include', '../src', ], 'sources': [ - './offline.cpp', + 'offline.cpp', ], - 'variables' : { - 'cflags_cc': [ - '<@(boost_cflags)', - ], + 'cflags_cc': [ + '<@(boost_cflags)', + ], + + 'link_settings': { 'libraries': [ '<@(boost_libprogram_options_static_libs)' ], }, - 'conditions': [ - ['OS == "mac"', { - 'libraries': [ '<@(libraries)' ], - 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], - } - }, { - 'cflags_cc': [ '<@(cflags_cc)' ], - 'libraries': [ '<@(libraries)' ], - }] - ], + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ + '<@(boost_cflags)', + ], + } }, ], } diff --git a/bin/render.gypi b/bin/render.gypi index 1a44d7a9ce..31815d3c44 100644 --- a/bin/render.gypi +++ b/bin/render.gypi @@ -1,55 +1,39 @@ { - 'includes': [ - '../gyp/common.gypi', - ], 'targets': [ - { 'target_name': 'mbgl-render', + { + 'target_name': 'mbgl-render', 'product_name': 'mbgl-render', 'type': 'executable', 'dependencies': [ - 'mbgl.gyp:core', - 'mbgl.gyp:platform-<(platform_lib)', - 'mbgl.gyp:headless-<(headless_lib)', - 'mbgl.gyp:http-<(http_lib)', - 'mbgl.gyp:asset-<(asset_lib)', - 'mbgl.gyp:copy_certificate_bundle', + 'platform-lib', + 'copy_certificate_bundle', ], 'include_dirs': [ + '../include', '../src', ], 'sources': [ - './render.cpp', + 'render.cpp', ], - 'variables' : { - 'cflags_cc': [ - '<@(glfw_cflags)', - '<@(boost_cflags)', - ], - 'ldflags': [ - '<@(glfw_ldflags)', - ], + 'cflags_cc': [ + '<@(boost_cflags)', + ], + + 'link_settings': { 'libraries': [ - '<@(glfw_static_libs)', '<@(boost_libprogram_options_static_libs)' ], }, - 'conditions': [ - ['OS == "mac"', { - 'libraries': [ '<@(libraries)' ], - 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], - 'OTHER_LDFLAGS': [ '<@(ldflags)' ], - } - }, { - 'cflags_cc': [ '<@(cflags_cc)' ], - 'libraries': [ '<@(libraries)', '<@(ldflags)' ], - }] - ], + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ + '<@(boost_cflags)', + ], + } }, ], } diff --git a/binding.gyp b/binding.gyp index 6cf0d1cd6f..10ed677ba3 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,18 +1,30 @@ { + 'variables': { + 'loop_lib': 'uv', + 'headless_lib': 'glx', + }, + 'conditions': [ + ['OS == "mac"', { + 'variables': { + 'headless_lib': 'cgl', + } + }], + ], 'includes': [ - 'gyp/common.gypi', + 'mbgl.gypi', ], 'targets': [ - { 'target_name': '<(module_name)', + { + 'target_name': '<(module_name)', 'dependencies': [ - 'gyp/mbgl.gyp:core', - 'gyp/mbgl.gyp:platform-<(platform_lib)', - 'gyp/mbgl.gyp:headless-<(headless_lib)', + 'core', ], 'include_dirs': [ '<(node_root_dir)/include/node', "&2 echo -e "\033[1m\033[33m$1\033[0m"; } function warn { >&2 echo -e "\033[1m\033[33m$1\033[0m"; } if [ -e "`pwd`/.git" ]; then - info "This build is within a git repository" - git submodule update --init export MASON_DIR="`pwd`/.mason" export PATH="${MASON_DIR}:${PATH}" else - info "This build is NOT within a git repository" which mason || abort "You must install mason to build mapbox-gl-native (https://github.com/mapbox/mason)" export MASON_DIR="$(dirname $(readlink $(which mason)))" fi @@ -41,6 +43,9 @@ function print_flags { done else warn "* Not using ${NAME}" + for FLAGS in "$@" ; do + CONFIG+=" '${NAME}_${FLAGS}%': [],"$LN + done fi fi } @@ -55,10 +60,7 @@ function print_opengl_flags { } # Load dependencies -source platform/${MASON_PLATFORM}/scripts/configure.sh -if [ -e platform/${MASON_PLATFORM}/scripts/${MASON_PLATFORM_VERSION}/configure.sh ]; then - source platform/${MASON_PLATFORM}/scripts/${MASON_PLATFORM_VERSION}/configure.sh -fi +source ${INPUT_FILE} PYTHON=`which python || abort 'Cannot find python'` @@ -113,6 +115,6 @@ CONFIG+=" } } " -mkdir -p $(dirname "${CONFIG_FILE}") -echo "${CONFIG}" > ${CONFIG_FILE} -cat ${CONFIG_FILE} +mkdir -p $(dirname "${OUTPUT_FILE}") +echo "${CONFIG}" > ${OUTPUT_FILE} +cat ${OUTPUT_FILE} diff --git a/docker/clang-tidy/tidy.sh b/docker/clang-tidy/tidy.sh index 222bd263f8..4c1b74595a 100755 --- a/docker/clang-tidy/tidy.sh +++ b/docker/clang-tidy/tidy.sh @@ -3,7 +3,6 @@ # set -e # set -o pipefail -export FLAVOR=linux export CXX=clang++-3.8 export BUILDTYPE=Release @@ -13,7 +12,7 @@ cd build source ./scripts/travis_helper.sh # install -./platform/${FLAVOR}/scripts/install.sh +./platform/linux/scripts/install.sh export CLANG_TIDY=clang-tidy-3.8 make tidy diff --git a/docker/linux/test.sh b/docker/linux/test.sh index f9d0b5daec..3afb73366c 100755 --- a/docker/linux/test.sh +++ b/docker/linux/test.sh @@ -3,7 +3,6 @@ # set -e # set -o pipefail -export FLAVOR=linux export CXX=g++-4.9 export BUILDTYPE=Release @@ -20,7 +19,7 @@ cd build source ./scripts/travis_helper.sh # install -./platform/${FLAVOR}/scripts/install.sh +./platform/linux/scripts/install.sh # script -./platform/${FLAVOR}/scripts/run.sh +./platform/linux/scripts/run.sh diff --git a/gyp/android.gyp b/gyp/android.gyp deleted file mode 100644 index fbeb4a647b..0000000000 --- a/gyp/android.gyp +++ /dev/null @@ -1,5 +0,0 @@ -{ - 'includes': [ - '../platform/android/mapboxgl-app.gypi', - ], -} diff --git a/gyp/asset-fs.gypi b/gyp/asset-fs.gypi deleted file mode 100644 index 30dc9e07aa..0000000000 --- a/gyp/asset-fs.gypi +++ /dev/null @@ -1,52 +0,0 @@ -{ - 'targets': [ - { 'target_name': 'asset-fs', - 'product_name': 'mbgl-asset-fs', - 'type': 'static_library', - 'standalone_static_library': 1, - 'hard_dependency': 1, - - 'sources': [ - '../platform/default/asset_file_source.cpp', - ], - - 'include_dirs': [ - '../include', - '../src', - ], - - 'variables': { - 'cflags_cc': [ - '<@(boost_cflags)', - ], - 'defines': [ - '-DMBGL_ASSET_FS' - ], - }, - - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], - }, - }, { - 'cflags_cc': [ '<@(cflags_cc)' ], - }], - ], - - 'direct_dependent_settings': { - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_CFLAGS': [ '<@(defines)' ], - 'OTHER_CPLUSPLUSFLAGS': [ '<@(defines)' ], - } - }, { - 'cflags': [ '<@(defines)' ], - 'cflags_cc': [ '<@(defines)' ], - }] - ], - }, - }, - ], -} diff --git a/gyp/asset-zip.gypi b/gyp/asset-zip.gypi deleted file mode 100644 index 9011981f6c..0000000000 --- a/gyp/asset-zip.gypi +++ /dev/null @@ -1,74 +0,0 @@ -{ - 'targets': [ - { 'target_name': 'asset-zip', - 'product_name': 'mbgl-asset-zip', - 'type': 'static_library', - 'standalone_static_library': 1, - 'hard_dependency': 1, - - 'sources': [ - '../platform/android/src/asset_file_source.cpp', - ], - - 'include_dirs': [ - '../include', - '../src', - ], - - 'variables': { - 'cflags': [ - '<@(libzip_cflags)', - ], - 'cflags_cc': [ - '<@(libzip_cflags)', - ], - 'ldflags': [ - '<@(libzip_ldflags)', - ], - 'libraries': [ - '<@(libzip_static_libs)', - ], - 'defines': [ - '-DMBGL_ASSET_ZIP' - ], - }, - - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_CFLAGS': [ '<@(cflags)' ], - 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], - }, - }, { - 'cflags': [ '<@(cflags)' ], - 'cflags_cc': [ '<@(cflags_cc)' ], - }], - ], - - 'direct_dependent_settings': { - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_CFLAGS': [ '<@(defines)' ], - 'OTHER_CPLUSPLUSFLAGS': [ '<@(defines)' ], - } - }, { - 'cflags': [ '<@(defines)' ], - 'cflags_cc': [ '<@(defines)' ], - }] - ], - }, - - 'link_settings': { - 'conditions': [ - ['OS == "mac"', { - 'libraries': [ '<@(libraries)' ], - 'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(ldflags)' ] } - }, { - 'libraries': [ '<@(libraries)', '<@(ldflags)' ], - }] - ], - }, - }, - ], -} diff --git a/gyp/certificates.gypi b/gyp/certificates.gypi deleted file mode 100644 index 1d0c2acf86..0000000000 --- a/gyp/certificates.gypi +++ /dev/null @@ -1,12 +0,0 @@ -{ - 'targets': [ - { 'target_name': 'copy_certificate_bundle', - 'type': 'none', - 'hard_dependency': 1, - 'copies': [{ - 'files': [ '../common/ca-bundle.crt' ], - 'destination': '<(PRODUCT_DIR)' - }], - }, - ] -} diff --git a/gyp/common.gypi b/gyp/common.gypi deleted file mode 100644 index 3972c8f6f9..0000000000 --- a/gyp/common.gypi +++ /dev/null @@ -1,139 +0,0 @@ -{ - 'target_defaults': { - 'default_configuration': 'Release', - 'conditions': [ - ['OS=="mac"', { - 'xcode_settings': { - 'CLANG_CXX_LIBRARY': 'libc++', - 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', - 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', - 'GCC_ENABLE_CPP_RTTI': 'YES', - 'OTHER_CPLUSPLUSFLAGS': [ - '-std=c++14', - '-Werror', - '-Wall', - '-Wextra', - '-Wshadow', - '-Wno-variadic-macros', - '-frtti', - '-fexceptions', - '${CFLAGS}', - ], - 'GCC_WARN_PEDANTIC': 'YES', - 'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE', - 'MACOSX_DEPLOYMENT_TARGET': '10.10', - }, - }, { - 'cflags_cc': [ - '-std=c++14', - '-Werror', - '-Wall', - '-Wextra', - '-Wshadow', - '-Wno-variadic-macros', - '-Wno-error=unused-parameter', - '-frtti', - '-fexceptions', - '${CFLAGS}', - ], - }], - ['OS=="linux"', { - 'cflags_cc': [ - '-Wno-unknown-pragmas', # We are using '#pragma mark', but it is only available on Darwin. - ], - 'conditions': [ - ['cxx_host != "clang"', { - 'cflags_cc': [ - '-fabi-version=0', - ], - }], - ] - }], - ], - 'target_conditions': [ - ['_type == "static_library"', { - 'conditions': [ - ['OS=="mac"', { - 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS': [ '-fPIC' ], - 'SKIP_INSTALL': 'YES', - }, - }, { - 'cflags_cc': [ '-fPIC' ], - }], - ['host == "ios"', { - 'xcode_settings': { - 'SDKROOT': 'iphoneos', - 'SUPPORTED_PLATFORMS': 'iphonesimulator iphoneos', - 'IPHONEOS_DEPLOYMENT_TARGET': '7.0', - 'TARGETED_DEVICE_FAMILY': '1,2', - 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', - 'CODE_SIGN_IDENTITY': 'iPhone Developer', - }, - 'configurations': { - 'Release': { - 'xcode_settings': { - 'ARCHS': [ "armv7", "armv7s", "arm64", "i386", "x86_64" ], - }, - }, - }, - }], - ], - }], - ], - 'configurations': { - 'Debug': { - 'conditions': [ - ['OS=="mac"', { - 'xcode_settings': { - 'GCC_OPTIMIZATION_LEVEL': '0', - 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES', - 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES', - 'DEAD_CODE_STRIPPING': 'NO', - 'OTHER_CPLUSPLUSFLAGS': [ '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ], - 'conditions': [ - ['coverage', { - 'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS': 'YES', - 'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES', - 'OTHER_CPLUSPLUSFLAGS': [ '--coverage' ], - }], - ], - }, - }, { - 'cflags_cc': [ '-g', '-O0', '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ], - 'conditions': [ - ['coverage', { 'cflags_cc': [ '--coverage' ] }], - ], - }], - ], - 'defines': [ 'DEBUG' ], - 'target_conditions': [ - ['_type == "executable"', { - 'conditions': [ - ['OS=="mac" and coverage', { - 'xcode_settings': { 'OTHER_LDFLAGS': [ '--coverage' ] }, - }, { - 'ldflags': [ '--coverage' ], - }], - ], - }], - ], - }, - 'Release': { - 'defines': [ 'NDEBUG' ], - 'conditions': [ - ['OS=="mac"', { - 'xcode_settings': { - 'GCC_OPTIMIZATION_LEVEL': '3', - 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES', - 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES', - 'DEAD_CODE_STRIPPING': 'NO', - }, - }, { - 'cflags_cc': [ '-g', '-O3' ], - }], - ], - }, - }, - } -} diff --git a/gyp/core.gypi b/gyp/core.gypi deleted file mode 100644 index 06497710d3..0000000000 --- a/gyp/core.gypi +++ /dev/null @@ -1,80 +0,0 @@ -{ - 'targets': [ - { 'target_name': 'core', - 'product_name': 'mbgl-core', - 'type': 'static_library', - 'standalone_static_library': 1, - 'hard_dependency': 1, - 'dependencies': [ - 'shaders', - 'version', - ], - - 'sources': [ - '> platform/android/MapboxGLAndroidSDK/gradle.properties - opts: - is_expand: true - - script: - title: Build Mapbox Android SDK For All ABI - inputs: - - content: |- - #!/bin/bash make apackage -j4 - - script: - title: Publish To Maven Central - inputs: - - content: |- - #!/bin/bash cd platform/android - ./gradlew uploadArchives \ No newline at end of file + ./gradlew uploadArchives diff --git a/platform/android/mapboxgl-app.gypi b/platform/android/mapboxgl-app.gypi deleted file mode 100644 index f9644c8d99..0000000000 --- a/platform/android/mapboxgl-app.gypi +++ /dev/null @@ -1,148 +0,0 @@ -{ - 'includes': [ - '../../gyp/common.gypi', - ], - 'targets': [ - { 'target_name': 'android-lib', - 'product_name': 'mapbox-gl', - 'type': 'shared_library', - 'hard_dependency': 1, - - 'dependencies': [ - 'mbgl.gyp:core', - 'mbgl.gyp:platform-<(platform_lib)', - 'mbgl.gyp:http-<(http_lib)', - 'mbgl.gyp:asset-<(asset_lib)', - ], - - 'include_dirs': [ - '../src', - ], - - 'sources': [ - './src/native_map_view.cpp', - './src/jni.cpp', - './src/attach_env.cpp', - ], - - 'cflags_cc': [ - '<@(boost_cflags)', - '<@(variant_cflags)', - '<@(jni.hpp_cflags)', - ], - 'libraries': [ - '<@(libpng_static_libs)', - '<@(libjpeg-turbo_static_libs)', - '<@(sqlite_static_libs)', - '<@(nunicode_static_libs)', - '<@(libzip_static_libs)', - ], - 'variables': { - 'ldflags': [ - '-llog', - '-landroid', - '-lEGL', - '-lGLESv2', - '-lstdc++', - '-latomic', - '<@(libpng_ldflags)', - '<@(libjpeg-turbo_ldflags)', - '<@(sqlite_ldflags)', - '<@(zlib_ldflags)', - '<@(libzip_ldflags)', - ], - }, - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_LDFLAGS': [ '<@(ldflags)' ], - } - }, { - 'libraries': [ '<@(ldflags)' ], - }] - ], - }, - - { 'target_name': 'example-custom-layer-lib', - 'product_name': 'example-custom-layer', - 'type': 'shared_library', - 'hard_dependency': 1, - - 'sources': [ - './src/example_custom_layer.cpp', - ], - - 'include_dirs': [ - '../../include', - ], - - 'variables': { - 'ldflags': [ - '-llog', - '-landroid', - '-lEGL', - '-lGLESv2', - '-lstdc++', - '-latomic', - ], - }, - - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_LDFLAGS': [ '<@(ldflags)' ], - } - }, { - 'libraries': [ '<@(ldflags)' ], - }] - ], - }, - - { 'target_name': 'androidapp', - 'type': 'none', - 'hard_dependency': 1, - - 'dependencies': [ - 'android-lib', - 'example-custom-layer-lib', - ], - - 'variables': { - 'pwd': ' ./platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt - -mapbox_time "compile_library" \ -make android-lib HOST_VERSION=${ANDROID_ABI} -j${JOBS} BUILDTYPE=${BUILDTYPE} - -mapbox_time "build_apk" \ -make android HOST_VERSION=${ANDROID_ABI} -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=./platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk - JNILIB=`mason env JNIDIR` - - # ARM64 does not build APK for now - if [ ${JNIDIR} != "arm64-v8a" ] ; then - # Upload either the debug or the release build - if [ ${BUILDTYPE} == "Debug" ] ; then - aws s3 cp \ - ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-${JNILIB}-debug.apk \ - ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-debug.apk - elif [ ${BUILDTYPE} == "Release" ] ; then - aws s3 cp \ - ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-${JNILIB}-release-unsigned.apk \ - ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-release-unsigned.apk - fi - fi - - mapbox_time_finish -fi diff --git a/platform/ios/app/mapboxgl-app.gypi b/platform/ios/app/mapboxgl-app.gypi deleted file mode 100644 index 864755829f..0000000000 --- a/platform/ios/app/mapboxgl-app.gypi +++ /dev/null @@ -1,81 +0,0 @@ -{ - 'includes': [ - '../../../gyp/common.gypi', - ], - 'targets': [ - { - 'target_name': 'iosapp', - 'product_name': 'Mapbox GL', - 'type': 'executable', - 'product_extension': 'app', - 'mac_bundle': 1, - 'mac_bundle_resources': [ - ' /dev/null - -echo http://mapbox.s3.amazonaws.com/$REPO_NAME/ios/tests/$TRAVIS_JOB_NUMBER/index.html diff --git a/platform/ios/scripts/defaults.mk b/platform/ios/scripts/defaults.mk deleted file mode 100644 index 9debff4ce0..0000000000 --- a/platform/ios/scripts/defaults.mk +++ /dev/null @@ -1,9 +0,0 @@ -HEADLESS = eagl -PLATFORM ?= ios -ASSET ?= fs -HTTP ?= nsurl -LOOP ?= darwin - -HOST_VERSION = all - -PROVISIONING_PROFILE ?= 19324a54-7455-4f0b-8e1c-e6957c718ebc diff --git a/platform/ios/scripts/install.sh b/platform/ios/scripts/install.sh deleted file mode 100755 index 437193b1f2..0000000000 --- a/platform/ios/scripts/install.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -git fetch --tags - -mapbox_time "checkout_mason" \ -git submodule update --init .mason - -mapbox_time "install_recent_git" \ -brew install git - -mapbox_time "install_awscli" \ -brew install awscli - -mapbox_time "install_jazzy" \ -gem install jazzy - -mkdir -p ${KIF_SCREENSHOTS} diff --git a/platform/ios/scripts/package.sh b/platform/ios/scripts/package.sh index b0f63478df..02a454aaf7 100755 --- a/platform/ios/scripts/package.sh +++ b/platform/ios/scripts/package.sh @@ -72,12 +72,6 @@ echo ${HASH} echo ${HASH} >> ${VERSION} -step "Creating build files…" -export MASON_PLATFORM=ios -export BUILDTYPE=${BUILDTYPE:-Release} -export HOST=ios -make Xcode/ios - PROJ_VERSION=$(git rev-list --count HEAD) if [[ "${BUILD_FOR_DEVICE}" == true ]]; then @@ -91,13 +85,9 @@ if [[ "${BUILD_FOR_DEVICE}" == true ]]; then DEPLOYMENT_POSTPROCESSING=YES \ CODE_SIGNING_REQUIRED=NO \ CODE_SIGN_IDENTITY= \ - -project ./build/ios-all/gyp/mbgl.xcodeproj \ + -project ./build/ios-all/platform/ios/platform.xcodeproj \ -configuration ${BUILDTYPE} \ - -target core \ - -target platform-ios \ - -target http-nsurl \ - -target asset-fs \ - -target headless-eagl \ + -target platform-lib \ -jobs ${JOBS} fi @@ -112,7 +102,7 @@ if [[ "${BUILD_FOR_DEVICE}" == true ]]; then CURRENT_PROJECT_VERSION=${PROJ_VERSION} \ CODE_SIGNING_REQUIRED=NO \ CODE_SIGN_IDENTITY= \ - -project ./build/ios-all/gyp/ios.xcodeproj \ + -project ./build/ios-all/platform/ios/platform.xcodeproj \ -configuration ${BUILDTYPE} \ -target iossdk \ -jobs ${JOBS} @@ -125,13 +115,9 @@ if [[ ${BUILD_STATIC} == true ]]; then ARCHS="x86_64 i386" \ ONLY_ACTIVE_ARCH=NO \ GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \ - -project ./build/ios-all/gyp/mbgl.xcodeproj \ + -project ./build/ios-all/platform/ios/platform.xcodeproj \ -configuration ${BUILDTYPE} \ - -target core \ - -target platform-ios \ - -target http-nsurl \ - -target asset-fs \ - -target headless-eagl \ + -target platform-lib \ -jobs ${JOBS} fi @@ -143,13 +129,13 @@ if [[ ${BUILD_DYNAMIC} == true ]]; then GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \ ENABLE_BITCODE=${ENABLE_BITCODE} \ CURRENT_PROJECT_VERSION=${PROJ_VERSION} \ - -project ./build/ios-all/gyp/ios.xcodeproj \ + -project ./build/ios-all/platform/ios/platform.xcodeproj \ -configuration ${BUILDTYPE} \ -target iossdk \ -jobs ${JOBS} fi -LIBS=(core.a platform-ios.a asset-fs.a http-nsurl.a) +LIBS=(core.a platform-ios.a) # https://medium.com/@syshen/create-an-ios-universal-framework-148eb130a46c if [[ "${BUILD_FOR_DEVICE}" == true ]]; then @@ -159,22 +145,22 @@ if [[ "${BUILD_FOR_DEVICE}" == true ]]; then libtool -static -no_warning_for_no_symbols \ `find mason_packages/ios-${IOS_SDK_VERSION} -type f -name libgeojsonvt.a` \ -o ${OUTPUT}/static/${NAME}.framework/${NAME} \ - ${LIBS[@]/#/gyp/build/${BUILDTYPE}-iphoneos/libmbgl-} \ - ${LIBS[@]/#/gyp/build/${BUILDTYPE}-iphonesimulator/libmbgl-} + ${LIBS[@]/#/build/ios-all/${BUILDTYPE}-iphoneos/libmbgl-} \ + ${LIBS[@]/#/build/ios-all/${BUILDTYPE}-iphonesimulator/libmbgl-} fi if [[ ${BUILD_DYNAMIC} == true ]]; then step "Copying dynamic framework into place for iOS devices" cp -r \ - gyp/build/${BUILDTYPE}-iphoneos/${NAME}.framework \ + build/ios-all/${BUILDTYPE}-iphoneos/${NAME}.framework \ ${OUTPUT}/dynamic/ - cp -r gyp/build/${BUILDTYPE}-iphoneos/${NAME}.framework.dSYM \ + cp -r build/ios-all/${BUILDTYPE}-iphoneos/${NAME}.framework.dSYM \ ${OUTPUT}/dynamic/ step "Merging simulator dynamic library into device dynamic library…" lipo \ - gyp/build/${BUILDTYPE}-iphoneos/${NAME}.framework/${NAME} \ - gyp/build/${BUILDTYPE}-iphonesimulator/${NAME}.framework/${NAME} \ + build/ios-all/${BUILDTYPE}-iphoneos/${NAME}.framework/${NAME} \ + build/ios-all/${BUILDTYPE}-iphonesimulator/${NAME}.framework/${NAME} \ -create -output ${OUTPUT}/dynamic/${NAME}.framework/${NAME} | echo fi else @@ -184,15 +170,15 @@ else libtool -static -no_warning_for_no_symbols \ `find mason_packages/ios-${IOS_SDK_VERSION} -type f -name libgeojsonvt.a` \ -o ${OUTPUT}/static/${NAME}.framework/${NAME} \ - ${LIBS[@]/#/gyp/build/${BUILDTYPE}-iphonesimulator/libmbgl-} + ${LIBS[@]/#/build/ios-all/${BUILDTYPE}-iphonesimulator/libmbgl-} fi if [[ ${BUILD_DYNAMIC} == true ]]; then step "Copying dynamic framework into place for iOS Simulator…" cp -r \ - gyp/build/${BUILDTYPE}-iphonesimulator/${NAME}.framework \ + build/ios-all/${BUILDTYPE}-iphonesimulator/${NAME}.framework \ ${OUTPUT}/dynamic/${NAME}.framework - cp -r gyp/build/${BUILDTYPE}-iphonesimulator/${NAME}.framework.dSYM \ + cp -r build/ios-all/${BUILDTYPE}-iphonesimulator/${NAME}.framework.dSYM \ ${OUTPUT}/dynamic/ fi fi diff --git a/platform/ios/scripts/run.sh b/platform/ios/scripts/run.sh deleted file mode 100755 index 44c21e7562..0000000000 --- a/platform/ios/scripts/run.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail -set -u - -source ./platform/ios/scripts/setup.sh - -BUILDTYPE=${BUILDTYPE:-Release} - -PUBLISH_TAG=($(git show -s --format=%B | sed -n 's/.*\[publish \([a-z]\{1,\}\)-v\([0-9a-z.\-]\{1,\}\)\].*/\1 \2/p')) -PUBLISH_PLATFORM=${PUBLISH_TAG[0],-} -PUBLISH_VERSION=${PUBLISH_TAG[1],-} - - -################################################################################ -# Build -################################################################################ - -if [[ ${PUBLISH_PLATFORM} = 'ios' ]]; then - # default, with debug symbols - mapbox_time "package_ios_symbols" \ - make ipackage - - mapbox_time "deploy_ios_symbols" - ./platform/ios/scripts/publish.sh "${PUBLISH_VERSION}" symbols - - # no debug symbols, for smaller distribution - mapbox_time "package_ios_stripped" \ - make ipackage-strip - - mapbox_time "deploy_ios_stripped" - ./platform/ios/scripts/publish.sh "${PUBLISH_VERSION}" - - # dynamic, with debug symbols - mapbox_time "package_ios_dynamic" \ - make iframework - - mapbox_time "deploy_ios_dynamic" - ./platform/ios/scripts/publish.sh "${PUBLISH_VERSION}" symbols-dynamic - - # dynamic, without debug symbols - mapbox_time "package_ios_dynamic_stripped" \ - make iframework SYMBOLS=NO - - mapbox_time "deploy_ios_dynamic_stripped" - ./platform/ios/scripts/publish.sh "${PUBLISH_VERSION}" dynamic -else - # build & test iOS - mapbox_time "run_ios_tests" \ - make itest -fi diff --git a/platform/ios/scripts/setup.sh b/platform/ios/scripts/setup.sh deleted file mode 100644 index d115cf9020..0000000000 --- a/platform/ios/scripts/setup.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -# This script is sourced; do not set -e or -o pipefail here. - -# Ensure mason is on the PATH -export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" diff --git a/platform/ios/scripts/test.sh b/platform/ios/scripts/test.sh deleted file mode 100755 index a2515e6fea..0000000000 --- a/platform/ios/scripts/test.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail -set -u - -# No tests for now. KIF tests are too unreliable. diff --git a/platform/linux/README.md b/platform/linux/README.md index 55f3e71dba..910edcb9a6 100644 --- a/platform/linux/README.md +++ b/platform/linux/README.md @@ -33,14 +33,13 @@ Set the environment variable `MAPBOX_ACCESS_TOKEN` to your [Mapbox access token] export MAPBOX_ACCESS_TOKEN=MYTOKEN -Then, you can then proceed to build the library: +Then, you can then proceed to build the test application: - git submodule update --init - make linux + make glfw-app Set an access token as described below, and then run: - make run-linux + make run-glfw-app ### Test diff --git a/platform/linux/main.cpp b/platform/linux/main.cpp deleted file mode 100644 index 98fb32075e..0000000000 --- a/platform/linux/main.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace { - -std::unique_ptr view; - -} - -void quit_handler(int) { - if (view) { - mbgl::Log::Info(mbgl::Event::Setup, "waiting for quit..."); - view->setShouldClose(); - } else { - exit(0); - } -} - -int main(int argc, char *argv[]) { - bool fullscreen = false; - bool benchmark = false; - std::string style; - double latitude = 0, longitude = 0; - double bearing = 0, zoom = 1, pitch = 0; - bool skipConfig = false; - - const struct option long_options[] = { - {"fullscreen", no_argument, 0, 'f'}, - {"benchmark", no_argument, 0, 'b'}, - {"style", required_argument, 0, 's'}, - {"lon", required_argument, 0, 'x'}, - {"lat", required_argument, 0, 'y'}, - {"zoom", required_argument, 0, 'z'}, - {"bearing", required_argument, 0, 'r'}, - {"pitch", required_argument, 0, 'p'}, - {0, 0, 0, 0} - }; - - while (true) { - int option_index = 0; - int opt = getopt_long(argc, argv, "fbs:", long_options, &option_index); - if (opt == -1) break; - switch (opt) - { - case 0: - if (long_options[option_index].flag != 0) - break; - case 'f': - fullscreen = true; - break; - case 'b': - benchmark = true; - break; - case 's': - style = std::string("asset://") + std::string(optarg); - break; - case 'x': - longitude = atof(optarg); - skipConfig = true; - break; - case 'y': - latitude = atof(optarg); - skipConfig = true; - break; - case 'z': - zoom = atof(optarg); - skipConfig = true; - break; - case 'r': - bearing = atof(optarg); - skipConfig = true; - break; - case 'p': - pitch = atof(optarg); - skipConfig = true; - break; - default: - break; - } - - } - - // sigint handling - struct sigaction sigIntHandler; - sigIntHandler.sa_handler = quit_handler; - sigemptyset(&sigIntHandler.sa_mask); - sigIntHandler.sa_flags = 0; - sigaction(SIGINT, &sigIntHandler, NULL); - - if (benchmark) { - mbgl::Log::Info(mbgl::Event::General, "BENCHMARK MODE: Some optimizations are disabled."); - } - - view = std::make_unique(fullscreen, benchmark); - - mbgl::DefaultFileSource fileSource("/tmp/mbgl-cache.db", "."); - - // Set access token if present - const char *token = getenv("MAPBOX_ACCESS_TOKEN"); - if (token == nullptr) { - mbgl::Log::Warning(mbgl::Event::Setup, "no access token set. mapbox.com tiles won't work."); - } else { - fileSource.setAccessToken(std::string(token)); - } - - mbgl::Map map(*view, fileSource); - - // Load settings - mbgl::Settings_JSON settings; - - if (skipConfig) { - map.setLatLngZoom(mbgl::LatLng(latitude, longitude), zoom); - map.setBearing(bearing); - map.setPitch(pitch); - mbgl::Log::Info(mbgl::Event::General, "Location: %f/%f (z%.2f, %.2f deg)", latitude, longitude, zoom, bearing); - } else { - map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom); - map.setBearing(settings.bearing); - map.setPitch(settings.pitch); - map.setDebug(mbgl::MapDebugOptions(settings.debug)); - } - - view->setChangeStyleCallback([&map] () { - static uint8_t currentStyleIndex; - - if (++currentStyleIndex == mbgl::util::default_styles::numOrderedStyles) { - currentStyleIndex = 0; - } - - mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[currentStyleIndex]; - map.setStyleURL(newStyle.url); - view->setWindowTitle(newStyle.name); - - mbgl::Log::Info(mbgl::Event::Setup, "Changed style to: %s", newStyle.name); - }); - - // Load style - if (style.empty()) { - mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[0]; - style = newStyle.url; - view->setWindowTitle(newStyle.name); - } - - map.setStyleURL(style); - - view->run(); - - // Save settings - mbgl::LatLng latLng = map.getLatLng(); - settings.latitude = latLng.latitude; - settings.longitude = latLng.longitude; - settings.zoom = map.getZoom(); - settings.bearing = map.getBearing(); - settings.pitch = map.getPitch(); - settings.debug = mbgl::EnumType(map.getDebug()); - if (!skipConfig) { - settings.save(); - } - mbgl::Log::Info(mbgl::Event::General, - "Exit location: --lat=\"%f\" --lon=\"%f\" --zoom=\"%f\" --bearing \"%f\"", - settings.latitude, settings.longitude, settings.zoom, settings.bearing); - - return 0; -} diff --git a/platform/linux/mapboxgl-app.gypi b/platform/linux/mapboxgl-app.gypi deleted file mode 100644 index 533f0b85d2..0000000000 --- a/platform/linux/mapboxgl-app.gypi +++ /dev/null @@ -1,66 +0,0 @@ -{ - 'includes': [ - '../../gyp/common.gypi', - ], - 'targets': [ - { 'target_name': 'linuxapp', - 'product_name': 'mapbox-gl', - 'type': 'executable', - - 'dependencies': [ - 'mbgl.gyp:core', - 'mbgl.gyp:platform-<(platform_lib)', - 'mbgl.gyp:http-<(http_lib)', - 'mbgl.gyp:asset-<(asset_lib)', - 'mbgl.gyp:copy_certificate_bundle', - ], - - 'sources': [ - 'main.cpp', - '../default/settings_json.cpp', - '../default/glfw_view.hpp', - '../default/glfw_view.cpp', - '../default/log_stderr.cpp', - ], - - 'variables' : { - 'cflags_cc': [ - '<@(opengl_cflags)', - '<@(boost_cflags)', - '<@(glfw_cflags)', - '<@(variant_cflags)', - ], - 'ldflags': [ - '<@(glfw_ldflags)', - ], - 'libraries': [ - '<@(glfw_static_libs)', - ], - }, - - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'SDKROOT': 'macosx', - 'SUPPORTED_PLATFORMS':'macosx', - 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], - 'MACOSX_DEPLOYMENT_TARGET': '10.10', - }, - }, { - 'cflags_cc': [ '<@(cflags_cc)' ], - }] - ], - - 'link_settings': { - 'conditions': [ - ['OS == "mac"', { - 'libraries': [ '<@(libraries)' ], - 'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(ldflags)' ] } - }, { - 'libraries': [ '<@(libraries)', '<@(ldflags)' ], - }] - ], - }, - }, - ], -} diff --git a/platform/linux/platform.gyp b/platform/linux/platform.gyp new file mode 100644 index 0000000000..0adbd2a2e6 --- /dev/null +++ b/platform/linux/platform.gyp @@ -0,0 +1,97 @@ +{ + 'variables': { + 'loop_lib': 'uv', + 'headless_lib': 'glx', + }, + 'conditions': [ + ['OS == "mac"', { + 'variables': { + 'headless_lib': 'cgl', + } + }], + ], + 'includes': [ + '../../mbgl.gypi', + '../../test/test.gypi', + '../../bin/glfw.gypi', + '../../bin/render.gypi', + '../../bin/offline.gypi', + ], + 'targets': [ + { + 'target_name': 'platform-lib', + 'product_name': 'mbgl-platform-linux', + 'type': 'static_library', + 'standalone_static_library': 1, + 'hard_dependency': 1, + 'dependencies': [ + 'core', + ], + + 'include_dirs': [ + '../default', + '../../include', + '../../src', # TODO: eliminate + ], + + 'sources': [ + '../default/log_stderr.cpp', + '../default/string_stdlib.cpp', + '../default/thread.cpp', + '../default/image.cpp', + '../default/webp_reader.cpp', + '../default/png_reader.cpp', + '../default/jpeg_reader.cpp', + '../default/asset_file_source.cpp', + '../default/http_request_curl.cpp', + '../default/default_file_source.cpp', + '../default/online_file_source.cpp', + '../default/mbgl/storage/offline.hpp', + '../default/mbgl/storage/offline.cpp', + '../default/mbgl/storage/offline_database.hpp', + '../default/mbgl/storage/offline_database.cpp', + '../default/mbgl/storage/offline_download.hpp', + '../default/mbgl/storage/offline_download.cpp', + '../default/sqlite3.hpp', + '../default/sqlite3.cpp', + ], + + 'cflags_cc': [ + '<@(boost_cflags)', + '<@(nunicode_cflags)', + '<@(sqlite_cflags)', + '<@(rapidjson_cflags)', + '<@(variant_cflags)', + '<@(libcurl_cflags)', + '<@(libpng_cflags)', + '<@(libjpeg-turbo_cflags)', + '<@(webp_cflags)', + ], + + 'link_settings': { + 'libraries': [ + '<@(nunicode_ldflags)', + '<@(nunicode_static_libs)', + '<@(sqlite_ldflags)', + '<@(sqlite_static_libs)', + '<@(zlib_ldflags)', + '<@(zlib_static_libs)', + '<@(libcurl_ldflags)', + '<@(libcurl_static_libs)', + '<@(libpng_ldflags)', + '<@(libpng_static_libs)', + '<@(libjpeg-turbo_ldflags)', + '<@(libjpeg-turbo_static_libs)', + '<@(webp_ldflags)', + '<@(webp_static_libs)', + ], + }, + + 'direct_dependent_settings': { + 'include_dirs': [ + '../include', + ], + }, + }, + ], +} diff --git a/platform/linux/scripts/after_script.sh b/platform/linux/scripts/after_script.sh index b5397f1df2..4989f0c444 100755 --- a/platform/linux/scripts/after_script.sh +++ b/platform/linux/scripts/after_script.sh @@ -3,13 +3,9 @@ set -e set -o pipefail -if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then - # Install and add awscli to PATH for uploading the results - pip install --user awscli - export PATH="`python -m site --user-base`/bin:${PATH}" - - REPO_NAME=$(basename $TRAVIS_REPO_SLUG) +JOB=$1 +if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then aws s3 cp --recursive --acl public-read --exclude "*" --include "*/actual.png" test/fixtures \ - s3://mapbox/$REPO_NAME/render-tests/$TRAVIS_JOB_NUMBER + s3://mapbox/mapbox-gl-native/render-tests/$JOB fi diff --git a/platform/linux/scripts/coveralls.sh b/platform/linux/scripts/coveralls.sh index 468fa4774b..1d8d9f060a 100755 --- a/platform/linux/scripts/coveralls.sh +++ b/platform/linux/scripts/coveralls.sh @@ -3,11 +3,22 @@ set -e set -o pipefail -source ./platform/linux/scripts/setup.sh +mapbox_time "install_lcov" \ +mason install lcov 1.12 -################################################################################ -# Coveralls -################################################################################ +# Collect coverage data and save it into coverage.info +mapbox_time "lcov_capture" \ +`mason prefix lcov 1.12`/usr/bin/lcov \ + --quiet \ + --capture \ + --no-external \ + --gcov-tool "gcov-4.9" \ + --directory "src/mbgl" \ + --directory "platform" \ + --directory "include/mbgl" \ + --directory "build/linux-x86_64/${BUILDTYPE}" \ + --base-directory "build/linux-x86_64/${BUILDTYPE}" \ + --output-file "build/linux-x86_64/${BUILDTYPE}/coverage.info" -mapbox_time "make_coveralls" \ -make coveralls -j${JOBS} +mapbox_time "coveralls_upload" \ +coveralls-lcov "build/linux-x86_64/${BUILDTYPE}/coverage.info" diff --git a/platform/linux/scripts/defaults.mk b/platform/linux/scripts/defaults.mk deleted file mode 100644 index 80f1346533..0000000000 --- a/platform/linux/scripts/defaults.mk +++ /dev/null @@ -1,5 +0,0 @@ -HEADLESS ?= glx -PLATFORM ?= linux -ASSET ?= fs -HTTP ?= curl -LOOP ?= uv diff --git a/platform/linux/scripts/install.sh b/platform/linux/scripts/install.sh deleted file mode 100755 index a254d312ec..0000000000 --- a/platform/linux/scripts/install.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -mapbox_time "checkout_mason" \ -git submodule update --init .mason - -PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" \ -mapbox_time "install_mesa" \ -mason install mesa 10.4.3 diff --git a/platform/linux/scripts/run.sh b/platform/linux/scripts/run.sh deleted file mode 100755 index 1c0c13968a..0000000000 --- a/platform/linux/scripts/run.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -source ./platform/linux/scripts/setup.sh - -BUILDTYPE=${BUILDTYPE:-Release} - -################################################################################ -# Build -################################################################################ - -mapbox_time "compile_program" \ -make linux -j${JOBS} BUILDTYPE=${BUILDTYPE} - -mapbox_time "compile_render_binary" \ -make render -j${JOBS} BUILDTYPE=${BUILDTYPE} - -mapbox_time "compile_offline_binary" \ -make offline -j${JOBS} BUILDTYPE=${BUILDTYPE} - -mapbox_time "compile_tests" \ -make test -j${JOBS} BUILDTYPE=${BUILDTYPE} - -################################################################################ -# Test -################################################################################ - -mapbox_time "run_tests" \ -make test-* BUILDTYPE=${BUILDTYPE} diff --git a/platform/linux/scripts/setup.sh b/platform/linux/scripts/setup.sh deleted file mode 100755 index af0eafb5cf..0000000000 --- a/platform/linux/scripts/setup.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# This script is sourced; do not set -e or -o pipefail here. - -# Ensure mason is on the 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 diff --git a/platform/linux/scripts/tidy.sh b/platform/linux/scripts/tidy.sh deleted file mode 100755 index 424c82c3cd..0000000000 --- a/platform/linux/scripts/tidy.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -# Ensure mason is on the PATH -export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" - -BUILDTYPE=${BUILDTYPE:-Release} - -export CLANG_TIDY=clang-tidy-3.8 - -mapbox_time "config" \ -make config - -mapbox_time "tidy" \ -make tidy diff --git a/platform/node/bitrise.yml b/platform/node/bitrise.yml index 9b9b4ca064..0b09192ee3 100644 --- a/platform/node/bitrise.yml +++ b/platform/node/bitrise.yml @@ -22,25 +22,20 @@ workflows: else envman add --key SKIPCI --value false fi - - select-xcode-version: - title: Select Xcode version - run_if: '{{enveq "SKIPCI" "false"}}' - script: title: Run build script run_if: '{{enveq "SKIPCI" "false"}}' inputs: - content: |- #!/bin/bash - export TRAVIS_OS_NAME=osx - export TRAVIS_TAG=$BITRISE_GIT_TAG - export TRAVIS_JOB_NUMBER=$BITRISE_BUILD_NUMBER - export NODE_VERSION=4 - export CXX=clang++ - export CC=clang - source ./scripts/set_compiler.sh - ./platform/node/scripts/install.sh - ./platform/node/scripts/run.sh - ./platform/node/scripts/after_script.sh + set -eu -o pipefail + brew unlink node + brew install awscli homebrew/versions/node4-lts + brew link homebrew/versions/node4-lts + make node + make test-node || result=$? + ./platform/node/scripts/after_script.sh ${BITRISE_BUILD_NUMBER} ${BITRISE_GIT_TAG:-} + exit ${result:-0} - slack: title: Post to Slack run_if: '{{enveq "SKIPCI" "false"}}' diff --git a/platform/node/scripts/after_script.sh b/platform/node/scripts/after_script.sh index ae8480e02a..905055ad11 100755 --- a/platform/node/scripts/after_script.sh +++ b/platform/node/scripts/after_script.sh @@ -3,50 +3,20 @@ set -e set -o pipefail -# Inspect binary. -if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then - ldd ./lib/mapbox-gl-native.node -else - otool -L ./lib/mapbox-gl-native.node -fi +JOB=$1 +TAG=$2 -PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)") +if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then + gzip --stdout node_modules/mapbox-gl-test-suite/render-tests/index.html | \ + aws s3 cp --acl public-read --content-encoding gzip --content-type text/html \ + - s3://mapbox/mapbox-gl-native/render-tests/$JOB/index.html -if [[ ${TRAVIS_TAG} == node-v${PACKAGE_JSON_VERSION} ]]; then - source ~/.nvm/nvm.sh - nvm use $NODE_VERSION + echo http://mapbox.s3.amazonaws.com/mapbox-gl-native/render-tests/$JOB/index.html +fi - npm install aws-sdk +PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)") +if [[ $TAG == node-v${PACKAGE_JSON_VERSION} ]]; then ./node_modules/.bin/node-pre-gyp package - - if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then - ./node_modules/.bin/node-pre-gyp testpackage - fi - ./node_modules/.bin/node-pre-gyp publish info - - if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then - source ./platform/linux/scripts/setup.sh - - rm -rf build - rm -rf lib - npm install --fallback-to-build=false - npm test - fi -fi - -if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then - if [[ ${TRAVIS_OS_NAME} == "linux" ]] ; then - pip install --user awscli - export PATH="`python -m site --user-base`/bin:${PATH}" - else - brew install awscli - fi - - gzip --stdout node_modules/mapbox-gl-test-suite/render-tests/index.html | \ - aws s3 cp --acl public-read --content-encoding gzip --content-type text/html \ - - s3://mapbox/mapbox-gl-native/render-tests/$TRAVIS_JOB_NUMBER/index.html - - echo http://mapbox.s3.amazonaws.com/mapbox-gl-native/render-tests/$TRAVIS_JOB_NUMBER/index.html fi diff --git a/platform/node/scripts/install.sh b/platform/node/scripts/install.sh deleted file mode 100755 index b550933cd9..0000000000 --- a/platform/node/scripts/install.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -git submodule update --init .mason - -export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" - -if [ ${TRAVIS_OS_NAME} == "linux" ]; then - mason install mesa 10.4.3 -fi - -if [ ! -d ~/.nvm ]; then - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.28.0/install.sh | bash -fi - -source ~/.nvm/nvm.sh - -nvm install $NODE_VERSION -nvm alias default $NODE_VERSION - -node --version -npm --version diff --git a/platform/node/scripts/run.sh b/platform/node/scripts/run.sh deleted file mode 100755 index 73578b110a..0000000000 --- a/platform/node/scripts/run.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -source ./platform/${TRAVIS_OS_NAME}/scripts/setup.sh - -BUILDTYPE=${BUILDTYPE:-Release} - -source ~/.nvm/nvm.sh -nvm use $NODE_VERSION -npm install --build-from-source - -npm test -npm run test-suite diff --git a/platform/osx/app/mapboxgl-app.gypi b/platform/osx/app/mapboxgl-app.gypi deleted file mode 100644 index 8b8cc17276..0000000000 --- a/platform/osx/app/mapboxgl-app.gypi +++ /dev/null @@ -1,77 +0,0 @@ -{ - 'includes': [ - '../../../gyp/common.gypi', - ], - 'targets': [ - { - 'target_name': 'osxapp', - 'product_name': 'Mapbox GL', - 'type': 'executable', - 'product_extension': 'app', - 'mac_bundle': 1, - 'mac_bundle_resources': [ - 'Credits.rtf', - 'Icon.icns', - 'MainMenu.xib', - 'MapDocument.xib', - ], - - 'dependencies': [ - 'osxsdk', - ], - - 'sources': [ - './AppDelegate.h', - './AppDelegate.m', - './DroppedPinAnnotation.h', - './DroppedPinAnnotation.m', - './LocationCoordinate2DTransformer.h', - './LocationCoordinate2DTransformer.m', - './MapDocument.h', - './MapDocument.m', - './OfflinePackNameValueTransformer.h', - './OfflinePackNameValueTransformer.m', - './TimeIntervalTransformer.h', - './TimeIntervalTransformer.m', - './NSValue+Additions.h', - './NSValue+Additions.m', - './main.m', - ], - - 'xcode_settings': { - 'CLANG_ENABLE_OBJC_ARC': 'YES', - 'INFOPLIST_FILE': '../platform/osx/app/Info.plist', - 'LD_RUNPATH_SEARCH_PATHS': [ - '\${inherited}', - '@executable_path/../Frameworks', - ], - 'PRODUCT_BUNDLE_IDENTIFIER': 'com.mapbox.MapboxGL', - 'SDKROOT': 'macosx', - 'SUPPORTED_PLATFORMS': 'macosx', - }, - - 'configurations': { - 'Debug': { - 'xcode_settings': { - 'COPY_PHASE_STRIP': 'NO', - }, - }, - 'Release': { - 'xcode_settings': { - 'COPY_PHASE_STRIP': 'YES', - }, - }, - }, - - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)/${FRAMEWORKS_FOLDER_PATH}', - 'files': [ - '<(PRODUCT_DIR)/Mapbox.framework', - ], - 'xcode_code_sign': 1, - } - ], - }, - ] -} diff --git a/platform/osx/bitrise.yml b/platform/osx/bitrise.yml index 70fe9041bf..7170fa3f66 100644 --- a/platform/osx/bitrise.yml +++ b/platform/osx/bitrise.yml @@ -1,11 +1,6 @@ format_version: 1.1.0 default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git -app: - envs: - - BITRISE_APP_TITLE: "Mapbox GL – OS X" - - BITRISE_DEV_BRANCH: "master" - trigger_map: - pattern: "*" is_pull_request_allowed: true @@ -28,12 +23,15 @@ workflows: envman add --key SKIPCI --value false fi - script: - title: Run SDK unit tests + title: Run build script run_if: '{{enveq "SKIPCI" "false"}}' inputs: - content: |- #!/bin/bash - make xctest BUILDTYPE=Debug + set -eu -o pipefail + export BUILDTYPE=Debug + make osx + make test-osx - is_debug: 'yes' - slack: title: Post to Slack diff --git a/platform/osx/platform.gyp b/platform/osx/platform.gyp new file mode 100644 index 0000000000..120e5c592d --- /dev/null +++ b/platform/osx/platform.gyp @@ -0,0 +1,328 @@ +{ + 'variables': { + 'loop_lib': 'darwin', + 'headless_lib': 'cgl', + }, + 'xcode_settings': { + # Force all build output to the build directory. Must + # be an absolute path or xcodebuild will ignore it. + 'SYMROOT': ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/osx/scripts/osxtest.xcscheme b/platform/osx/scripts/osxtest.xcscheme new file mode 100644 index 0000000000..dbc0577df8 --- /dev/null +++ b/platform/osx/scripts/osxtest.xcscheme @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/osx/scripts/package.sh b/platform/osx/scripts/package.sh deleted file mode 100755 index f4b2d0c899..0000000000 --- a/platform/osx/scripts/package.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail -set -u - -NAME=Mapbox -OUTPUT=build/osx/pkg -OSX_SDK_VERSION=`xcrun --sdk macosx --show-sdk-version` - -if [[ ${#} -eq 0 ]]; then # e.g. "make xpackage" - BUILDTYPE="Release" - GCC_GENERATE_DEBUGGING_SYMBOLS="YES" -else # e.g. "make xpackage-strip" - BUILDTYPE="Release" - GCC_GENERATE_DEBUGGING_SYMBOLS="NO" -fi - -function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } -function finish { >&2 echo -en "\033[0m"; } -trap finish EXIT - -step "Creating build files..." -export MASON_PLATFORM=osx -export BUILDTYPE=${BUILDTYPE:-Release} -export HOST=osx -make Xcode/osx - -VERSION=${TRAVIS_JOB_NUMBER:-${BITRISE_BUILD_NUMBER:-0}} - -step "Building OS X framework (build ${VERSION})..." -xcodebuild -sdk macosx${OSX_SDK_VERSION} \ - ARCHS="x86_64" \ - ONLY_ACTIVE_ARCH=NO \ - GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \ - CURRENT_PROJECT_VERSION=${VERSION} \ - -project ./build/osx-x86_64/gyp/osx.xcodeproj \ - -configuration ${BUILDTYPE} \ - -target osxsdk \ - -jobs ${JOBS} - -TARGET_BUILD_DIR=gyp/build/${BUILDTYPE} -INFOPLIST_PATH=Mapbox.framework/Versions/Current/Resources/Info.plist - -# Uncomment when we're ready to release an official version. -#VERSION=$( git tag | grep ^osx | sed 's/^osx-//' | sort -r | grep -v '\-rc.' | grep -v '\-pre.' | sed -n '1p' | sed 's/^v//' ) -#if [ "$VERSION" ]; then -# plutil \ -# -replace CFBundleShortVersionString -string ${VERSION} \ -# $TARGET_BUILD_DIR/$INFOPLIST_PATH -# plutil \ -# -replace CFBundleVersion -string ${VERSION} \ -# $TARGET_BUILD_DIR/$INFOPLIST_PATH -#fi - -echo $TARGET_BUILD_DIR/Mapbox.framework diff --git a/platform/osx/scripts/run.sh b/platform/osx/scripts/run.sh deleted file mode 100755 index 6d00d1b977..0000000000 --- a/platform/osx/scripts/run.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -source ./platform/osx/scripts/setup.sh - -BUILDTYPE=${BUILDTYPE:-Release} - -################################################################################ -# Build -################################################################################ - -mapbox_time "compile_render_binary" \ -make render -j${JOBS} BUILDTYPE=${BUILDTYPE} - -mapbox_time "compile_offline_binary" \ -make offline -j${JOBS} BUILDTYPE=${BUILDTYPE} - -mapbox_time "compile_tests" \ -make xtest -j${JOBS} BUILDTYPE=${BUILDTYPE} diff --git a/platform/osx/scripts/setup.sh b/platform/osx/scripts/setup.sh deleted file mode 100755 index 502d61d44d..0000000000 --- a/platform/osx/scripts/setup.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -# This script is sourced; do not set -e or -o pipefail here. - -# Ensure mason is on the 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 diff --git a/platform/osx/scripts/test.sh b/platform/osx/scripts/test.sh deleted file mode 100755 index f72895d850..0000000000 --- a/platform/osx/scripts/test.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail -set -u - -OSX_SDK_VERSION=`xcrun --sdk macosx --show-sdk-version` -OSX_PROJ_PATH=./build/osx-x86_64/gyp/osx.xcodeproj - -export BUILDTYPE=${BUILDTYPE:-Release} - -mkdir -p "${OSX_PROJ_PATH}/xcshareddata/xcschemes" -cp platform/osx/scripts/osxsdk.xcscheme "${OSX_PROJ_PATH}/xcshareddata/xcschemes/osxsdk.xcscheme" - -xcodebuild -verbose \ - -sdk macosx${OSX_SDK_VERSION} \ - -project "${OSX_PROJ_PATH}" \ - -scheme osxsdk \ - test diff --git a/platform/osx/sdk/framework-osx.gypi b/platform/osx/sdk/framework-osx.gypi deleted file mode 100644 index 259066f702..0000000000 --- a/platform/osx/sdk/framework-osx.gypi +++ /dev/null @@ -1,68 +0,0 @@ -{ - 'includes': [ - '../../../gyp/common.gypi', - ], - 'targets': [ - { - 'target_name': 'osxsdk', - 'product_name': 'Mapbox', - 'type': 'shared_library', - 'mac_bundle': 1, - - 'dependencies': [ - 'mbgl.gyp:core', - 'mbgl.gyp:platform-<(platform_lib)', - 'mbgl.gyp:http-<(http_lib)', - 'mbgl.gyp:asset-<(asset_lib)', - ], - - 'xcode_settings': { - 'CLANG_ENABLE_OBJC_ARC': 'YES', - 'CURRENT_PROJECT_VERSION': '0', - 'DEFINES_MODULE': 'YES', - 'DYLIB_INSTALL_NAME_BASE': '@rpath', - 'INFOPLIST_FILE': '../platform/osx/sdk/Info.plist', - 'LD_RUNPATH_SEARCH_PATHS': [ - '${inherited}', - '@executable_path/../Frameworks', - '@loader_path/Frameworks', - ], - 'PRODUCT_BUNDLE_IDENTIFIER': 'com.mapbox.MapboxGL', - 'OTHER_LDFLAGS': [ '-stdlib=libc++', '-lstdc++' ], - 'SDKROOT': 'macosx', - 'SKIP_INSTALL': 'YES', - 'SUPPORTED_PLATFORMS':'macosx', - 'VERSIONING_SYSTEM': 'apple-generic', - }, - - 'mac_framework_headers': [ - './Mapbox.h', - '/dev/null 2>&1 || { exit 1 } -cd build/${HOST}-${HOST_VERSION}/${BUILDTYPE} +cd build/${PLATFORM}-${SUBPLATFORM}/${BUILDTYPE} git ls-files '../../../src/mbgl/*.cpp' '../../../platform/*.cpp' '../../../test/*.cpp' | \ xargs -I{} -P ${JOBS} ${CLANG_TIDY:-clang-tidy} -header-filter='\/mbgl\/' {} diff --git a/scripts/collect-coverage.sh b/scripts/collect-coverage.sh index 0007eebd5b..2e8ad9550b 100755 --- a/scripts/collect-coverage.sh +++ b/scripts/collect-coverage.sh @@ -25,12 +25,12 @@ command -v genhtml >/dev/null 2>&1 || usage lcov \ --quiet \ --zerocounters \ - --directory "build/${HOST_SLUG}/${BUILDTYPE}" \ - --output-file "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info" \ + --directory "build/${PLATFORM_SLUG}/${BUILDTYPE}" \ + --output-file "build/${PLATFORM_SLUG}/${BUILDTYPE}/coverage.info" \ >/dev/null 2>&1 # Run all unit tests -./scripts/run_tests.sh "build/${HOST_SLUG}/${BUILDTYPE}/test" +make test-* # Collect coverage data and save it into coverage.info echo "Collecting coverage data..." @@ -41,9 +41,9 @@ lcov \ --directory "src/mbgl" \ --directory "platform" \ --directory "include/mbgl" \ - --directory "build/${HOST_SLUG}/${BUILDTYPE}" \ - --base-directory "build/${HOST_SLUG}/${BUILDTYPE}" \ - --output-file "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info" \ + --directory "build/${PLATFORM_SLUG}/${BUILDTYPE}" \ + --base-directory "build/${PLATFORM_SLUG}/${BUILDTYPE}" \ + --output-file "build/${PLATFORM_SLUG}/${BUILDTYPE}/coverage.info" \ >/dev/null 2>&1 # Generate HTML report based on coverage.info @@ -59,8 +59,8 @@ genhtml \ --sort \ --demangle-cpp \ --prefix $(pwd -P) \ - --output-directory "build/${HOST_SLUG}/${BUILDTYPE}/coverage" \ - "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info" \ + --output-directory "build/${PLATFORM_SLUG}/${BUILDTYPE}/coverage" \ + "build/${PLATFORM_SLUG}/${BUILDTYPE}/coverage.info" \ >/dev/null 2>&1 -echo "Coverage report is now available in build/${HOST_SLUG}/${BUILDTYPE}/coverage/index.html" +echo "Coverage report is now available in build/${PLATFORM_SLUG}/${BUILDTYPE}/coverage/index.html" diff --git a/scripts/coveralls.sh b/scripts/coveralls.sh deleted file mode 100755 index 79e398dc1f..0000000000 --- a/scripts/coveralls.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" - -mapbox_time "install_lcov" \ -mason install lcov 1.12 - -LCOV="`mason prefix lcov 1.12`/usr/bin/lcov" - -mapbox_time "check_mason_lcov" \ -command -v $LCOV > /dev/null 2>&1 || exit 1 - -mapbox_time "remove_coverage_info" \ -rm -f "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info" - -# Run all unit tests -./scripts/run_tests.sh "build/${HOST_SLUG}/${BUILDTYPE}/test" - -# Collect coverage data and save it into coverage.info -mapbox_time "lcov_capture" \ -$LCOV \ - --quiet \ - --capture \ - --no-external \ - --gcov-tool "gcov-4.9" \ - --directory "src/mbgl" \ - --directory "platform" \ - --directory "include/mbgl" \ - --directory "build/${HOST_SLUG}/${BUILDTYPE}" \ - --base-directory "build/${HOST_SLUG}/${BUILDTYPE}" \ - --output-file "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info" - -mapbox_time "coveralls_upload" \ -coveralls-lcov "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info" diff --git a/scripts/flock.py b/scripts/flock.py deleted file mode 100755 index 6ceb585cdc..0000000000 --- a/scripts/flock.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -import fcntl, os, subprocess, sys, errno - -# from http://stackoverflow.com/a/600612 -def mkdir_p(path): - try: - os.makedirs(path) - except OSError as exc: # Python >2.5 - if exc.errno == errno.EEXIST and os.path.isdir(path): - pass - else: raise - -def flock(lockfile, cmd_list, verbose = False): - mkdir_p(os.path.dirname(lockfile)) - fd = os.open(lockfile, os.O_RDONLY | os.O_NOCTTY | os.O_CREAT, 0o666) - fcntl.flock(fd, fcntl.LOCK_EX) - if verbose: - print(' '.join(cmd_list)) - return subprocess.call(cmd_list) - -if '__main__' == __name__: - try: - if sys.argv[1] == '-v': - sys.exit(flock(sys.argv[2], sys.argv[3:], True)) - else: - sys.exit(flock(sys.argv[1], sys.argv[2:])) - except KeyboardInterrupt: - sys.exit(1) diff --git a/scripts/main.mk b/scripts/main.mk index d10fa39d52..a0e6a0d67a 100644 --- a/scripts/main.mk +++ b/scripts/main.mk @@ -1,31 +1,39 @@ -ifeq (,$(V)) - QUIET = @ +ifeq ($(shell uname -s), Darwin) + export PLATFORM ?= osx +else ifeq ($(shell uname -s), Linux) + export PLATFORM ?= linux endif -# Determine host platform -export HOST ?= $(BUILD) - -# Defines host defaults -include platform/$(HOST)/scripts/defaults.mk - -export HOST_VERSION ?= $(BUILD_VERSION) - -# Optionally include version-specific host defaults --include scripts/$(HOST)/$(HOST_VERSION)/defaults.mk --include platform/$(HOST)/scripts/$(HOST_VERSION)/defaults.mk - -export MASON_PLATFORM=$(HOST) -export MASON_PLATFORM_VERSION=$(HOST_VERSION) - -export HOST_SLUG = $(HOST)-$(HOST_VERSION) -CONFIGURE_FILES = platform/$(HOST)/scripts/configure.sh -ifneq (,$(wildcard scripts/$(HOST)/$(HOST_VERSION)/configure.sh)) - CONFIGURE_FILES += scripts/$(HOST)/$(HOST_VERSION)/configure.sh +ifeq ($(PLATFORM),android) + export SUBPLATFORM ?= arm-v7 + GYP_FLAVOR_SUFFIX = -android + ENV = $(shell MASON_ANDROID_ABI=$(SUBPLATFORM) ./platform/android/scripts/toolchain.sh) +else ifeq ($(PLATFORM),ios) + export SUBPLATFORM = all +else ifeq ($(PLATFORM),osx) + export SUBPLATFORM = x86_64 +else + export SUBPLATFORM ?= $(shell uname -m) endif -ifneq (,$(wildcard platform/$(HOST)/scripts/$(HOST_VERSION)/configure.sh)) - CONFIGURE_FILES += platform/$(HOST)/scripts/$(HOST_VERSION)/configure.sh + +ifneq ($(PLATFORM),node) + export MASON_PLATFORM = $(PLATFORM) + export MASON_PLATFORM_VERSION = $(SUBPLATFORM) + export PLATFORM_SLUG = $(PLATFORM)-$(SUBPLATFORM) +else ifeq ($(shell uname -s), Darwin) + export MASON_PLATFORM = osx + export MASON_PLATFORM_VERSION = $(SUBPLATFORM) + export PLATFORM_SLUG = node-osx-$(SUBPLATFORM) +else ifeq ($(shell uname -s), Linux) + export MASON_PLATFORM = linux + export MASON_PLATFORM_VERSION = $(SUBPLATFORM) + export PLATFORM_SLUG = node-linux-$(SUBPLATFORM) endif +export PLATFORM_OUTPUT = ./build/$(PLATFORM_SLUG) +export PLATFORM_CONFIG_INPUT = platform/$(MASON_PLATFORM)/scripts/configure.sh +export PLATFORM_CONFIG_OUTPUT = $(PLATFORM_OUTPUT)/config.gypi + ifneq (,$(findstring clang,$(CXX))) CXX_HOST = "clang" else ifneq (,$(findstring g++,$(CXX))) @@ -39,155 +47,107 @@ COLOR_CYAN = \033[36m COLOR_PINK = \033[35m FORMAT_END = \033[0m -default: ; +# Never remove intermediate files +.SECONDARY: #### Dependencies ############################################################## ifneq (,$(wildcard .git/.)) -SUBMODULES += .mason/mason.sh -.mason/mason.sh: - ./scripts/flock.py .git/Submodule.lock git submodule update --init .mason - -ifeq ($(HOST),ios) -SUBMODULES += platform/ios/vendor/SMCalloutView/SMCalloutView.h -platform/ios/vendor/SMCalloutView/SMCalloutView.h: - ./scripts/flock.py .git/Submodule.lock git submodule update --init platform/ios/vendor/SMCalloutView - -SUBMODULES += platform/ios/test/KIF/KIF.xcodeproj -platform/ios/test/KIF/KIF.xcodeproj: - ./scripts/flock.py .git/Submodule.lock git submodule update --init platform/ios/test/KIF +.mason: + git submodule update --init +else +.mason: ; endif -endif - -# Wildcard targets get removed after build by default, but we want to preserve the config. -.PRECIOUS: config/%.gypi -config/%.gypi: $(SUBMODULES) configure $(CONFIGURE_FILES) - @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Recreating project...$(FORMAT_END)\n" - $(QUIET)$(ENV) ./scripts/flock.py build/Configure.lock ./configure config/$*.gypi -.PHONY: config -config: config/$(HOST_SLUG).gypi +$(PLATFORM_CONFIG_OUTPUT): .mason configure $(PLATFORM_CONFIG_INPUT) + @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Running configure...$(FORMAT_END)\n" + $(ENV) ./configure $(PLATFORM_CONFIG_INPUT) $(PLATFORM_CONFIG_OUTPUT) #### Build files ############################################################### -GYP_FLAGS += -Dhost=$(HOST) -GYP_FLAGS += -Iconfig/$(HOST_SLUG).gypi -GYP_FLAGS += -Dplatform_lib=$(PLATFORM) -GYP_FLAGS += -Dhttp_lib=$(HTTP) -GYP_FLAGS += -Dloop_lib=$(LOOP) -GYP_FLAGS += -Dasset_lib=$(ASSET) -GYP_FLAGS += -Dheadless_lib=$(HEADLESS) -GYP_FLAGS += -Dtest=$(BUILD_TEST) -GYP_FLAGS += -Drender=$(BUILD_RENDER) -GYP_FLAGS += -Doffline=$(BUILD_OFFLINE) +GYP_FLAGS += -I$(PLATFORM_CONFIG_OUTPUT) GYP_FLAGS += -Dcoverage=$(ENABLE_COVERAGE) GYP_FLAGS += -Dcxx_host=$(CXX_HOST) -GYP_FLAGS += --depth=. GYP_FLAGS += -Goutput_dir=. -GYP_FLAGS += --generator-output=./build/$(HOST_SLUG) +GYP_FLAGS += --depth=. +GYP_FLAGS += --generator-output=$(PLATFORM_OUTPUT) .PHONY: Makefile/__project__ -Makefile/__project__: print-env $(SUBMODULES) config/$(HOST_SLUG).gypi +Makefile/__project__: $(PLATFORM_CONFIG_OUTPUT) @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Recreating project...$(FORMAT_END)\n" - $(QUIET)$(ENV) deps/run_gyp gyp/$(HOST).gyp $(GYP_FLAGS) \ - -f make$(GYP_FLAVOR_SUFFIX) + $(ENV) deps/run_gyp platform/$(PLATFORM)/platform.gyp $(GYP_FLAGS) -f make$(GYP_FLAVOR_SUFFIX) .PHONY: Xcode/__project__ -Xcode/__project__: print-env $(SUBMODULES) config/$(HOST_SLUG).gypi +Xcode/__project__: $(PLATFORM_CONFIG_OUTPUT) @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Recreating project...$(FORMAT_END)\n" - $(QUIET)$(ENV) deps/run_gyp gyp/$(HOST).gyp $(GYP_FLAGS) \ - -f xcode$(GYP_FLAVOR_SUFFIX) + $(ENV) deps/run_gyp platform/$(PLATFORM)/platform.gyp $(GYP_FLAGS) -f xcode$(GYP_FLAVOR_SUFFIX) .PHONY: Ninja/__project__ -Ninja/__project__: print-env $(SUBMODULES) config/$(HOST_SLUG).gypi +Ninja/__project__: $(PLATFORM_CONFIG_OUTPUT) @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Recreating project...$(FORMAT_END)\n" - $(QUIET)$(ENV) deps/run_gyp gyp/$(HOST).gyp -Gconfig=$(BUILDTYPE) $(GYP_FLAGS) \ - -f ninja + $(ENV) deps/run_gyp platform/$(PLATFORM)/platform.gyp $(GYP_FLAGS) -f ninja -#### Build individual targets ################################################## +#### Node targets ############################################################## NODE_PRE_GYP = $(shell npm bin)/node-pre-gyp -node/configure: - $(QUIET)$(ENV) $(NODE_PRE_GYP) configure --clang -- \ - $(GYP_FLAGS) -Dlibuv_cflags= -Dlibuv_ldflags= -Dlibuv_static_libs= -node/xproj: Xcode/__project__ node/configure - $(QUIET)$(ENV) $(NODE_PRE_GYP) configure --clang -- \ - $(GYP_FLAGS) -f xcode -Dlibuv_cflags= -Dlibuv_ldflags= -Dlibuv_static_libs= - $(QUIET)$(ENV) ./platform/node/scripts/create_node_scheme.sh "node test" "`npm bin tape`/tape platform/node/test/js/**/*.test.js" - $(QUIET)$(ENV) ./platform/node/scripts/create_node_scheme.sh "npm run test-suite" "platform/node/test/render.test.js" +Makefile/node: $(PLATFORM_CONFIG_OUTPUT) + $(NODE_PRE_GYP) configure --clang -- $(GYP_FLAGS) \ + -Dlibuv_cflags= -Dlibuv_ldflags= -Dlibuv_static_libs= + $(NODE_PRE_GYP) build --clang -Makefile/node: Makefile/__project__ node/configure - @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Building target node...$(FORMAT_END)\n" - $(QUIET)$(ENV) $(NODE_PRE_GYP) build --clang -- \ - -j$(JOBS) +Xcode/node: $(PLATFORM_CONFIG_OUTPUT) + $(NODE_PRE_GYP) configure --clang -- $(GYP_FLAGS) -f xcode \ + -Dlibuv_cflags= -Dlibuv_ldflags= -Dlibuv_static_libs= + +#### Build individual targets ################################################## Makefile/%: Makefile/__project__ @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Building target $*...$(FORMAT_END)\n" - $(QUIET)$(ENV) $(MAKE) -C build/$(HOST_SLUG) BUILDTYPE=$(BUILDTYPE) $* - -Xcode/node: Xcode/__project__ node/xproj - @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Building target node...$(FORMAT_END)\n" - xcodebuild \ - $(XCODEBUILD_ARGS) \ - -project ./build/binding.xcodeproj \ - -configuration $(BUILDTYPE) \ - -target mapbox-gl-native \ - -jobs $(JOBS) + $(ENV) $(MAKE) -j$(JOBS) -C $(PLATFORM_OUTPUT) BUILDTYPE=$(BUILDTYPE) $* Xcode/%: Xcode/__project__ @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Building target $*...$(FORMAT_END)\n" xcodebuild \ - PROVISIONING_PROFILE="$(PROVISIONING_PROFILE)" \ - $(XCODEBUILD_ARGS) \ - -project ./build/$(HOST_SLUG)/gyp/$(HOST).xcodeproj \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGN_IDENTITY= \ + -project $(PLATFORM_OUTPUT)/platform/$(PLATFORM)/platform.xcodeproj \ -configuration $(BUILDTYPE) \ -target $* \ -jobs $(JOBS) Ninja/%: Ninja/__project__ @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Building target $*...$(FORMAT_END)\n" - $(QUIET)$(ENV) deps/ninja/ninja-$(BUILD) -C build/$(HOST_SLUG)/$(BUILDTYPE) $* + $(ENV) deps/ninja/ninja-$(PLATFORM) -C $(PLATFORM_OUTPUT)/$(BUILDTYPE) $* +#### Tidy ###################################################################### -Ninja/compdb: OUTPUT=build/$(HOST_SLUG)/$(BUILDTYPE)/compile_commands.json +Ninja/compdb: OUTPUT=$(PLATFORM_OUTPUT)/$(BUILDTYPE)/compile_commands.json Ninja/compdb: Ninja/__project__ @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Writing to $(OUTPUT)$(FORMAT_END)\n" - $(QUIET)$(ENV) deps/ninja/ninja-$(BUILD) -C build/$(HOST_SLUG)/$(BUILDTYPE) \ + $(ENV) deps/ninja/ninja-$(PLATFORM) -C $(PLATFORM_OUTPUT)/$(BUILDTYPE) \ -t compdb cc cc_s cxx objc objcxx > $(OUTPUT) -#### Tidy ###################################################################### - tidy: Ninja/compdb @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Generating header files...$(FORMAT_END)\n" - $(QUIET)$(ENV) deps/ninja/ninja-$(BUILD) -C build/$(HOST_SLUG)/$(BUILDTYPE) version shaders + $(ENV) deps/ninja/ninja-$(PLATFORM) -C $(PLATFORM_OUTPUT)/$(BUILDTYPE) version shaders @printf "$(TEXT_BOLD)$(COLOR_GREEN)* Running tidy...$(FORMAT_END)\n" @./scripts/clang-tidy.sh #### Run tests ################################################################# -test-%: Makefile/test - ./scripts/run_tests.sh "build/$(HOST_SLUG)/$(BUILDTYPE)/test" --gtest_filter=$* +run-glfw-app: + $(PLATFORM_OUTPUT)/$(BUILDTYPE)/mapbox-glfw -check: Makefile/test - ./scripts/collect-coverage.sh - -coveralls: Makefile/test - ./scripts/coveralls.sh +run-valgrind-glfw-app: + valgrind --leak-check=full --suppressions=../../../scripts/valgrind.sup $(PLATFORM_OUTPUT)/$(BUILDTYPE)/mapbox-glfw -#### Helper targets ############################################################ +ifneq (,$(shell command -v gdb)) + GDB = gdb -batch -return-child-result -ex 'set print thread-events off' -ex 'run' -ex 'thread apply all bt' --args +endif -.PHONY: print-env -print-env: $(SUBMODULES) - @printf "$(COLOR_PINK)build:$(FORMAT_END) $(BUILD)/$(BUILD_VERSION)\n" - @printf "$(COLOR_PINK)host:$(FORMAT_END) $(HOST)/$(HOST_VERSION)\n" - @printf "$(COLOR_PINK)libs:$(FORMAT_END) " - @printf "headless=$(COLOR_CYAN)%s$(FORMAT_END) " $(HEADLESS) - @printf "platform=$(COLOR_CYAN)%s$(FORMAT_END) " $(PLATFORM) - @printf "asset=$(COLOR_CYAN)%s$(FORMAT_END) " $(ASSET) - @printf "http=$(COLOR_CYAN)%s$(FORMAT_END) " $(HTTP) - @printf "loop=$(COLOR_CYAN)%s$(FORMAT_END) " $(LOOP) - @printf "\n" +test-%: Makefile/test + $(GDB) $(PLATFORM_OUTPUT)/$(BUILDTYPE)/test --gtest_filter=$* -# Never remove intermediate files -.SECONDARY: +check: Makefile/test + ./scripts/collect-coverage.sh diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh deleted file mode 100755 index a4af39d5a9..0000000000 --- a/scripts/run_tests.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -if [ `uname -s` = 'Darwin' ]; then HOST=${HOST:-osx} ; else HOST=${HOST:-linux} ; fi - -CMD=$@ -shift - -# allow writing core files -ulimit -c unlimited -S -echo 'ulimit -c: '`ulimit -c` -if [ -f /proc/sys/kernel/core_pattern ]; then - echo '/proc/sys/kernel/core_pattern: '`cat /proc/sys/kernel/core_pattern` -fi - -if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then - sysctl kernel.core_pattern -fi - -# install test server dependencies -if [ ! -d "test/node_modules/express" ]; then - (cd test; npm install express@4.11.1) -fi - -if command -v gdb >/dev/null 2>&1; then - gdb -batch -return-child-result -ex 'set print thread-events off' \ - -ex 'run' -ex 'thread apply all bt' --args ${CMD} ; -else - ${CMD} ; -fi diff --git a/scripts/set_compiler.sh b/scripts/set_compiler.sh deleted file mode 100755 index 161126f044..0000000000 --- a/scripts/set_compiler.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -if [ ! -z "${_CXX}" ]; then export CXX="${_CXX}" ; fi -if [ ! -z "${_CC}" ]; then export CC="${_CC}" ; fi - -if [ "${CCACHE:-0}" -ge 1 ]; then - export CXX="ccache ${CXX}" - export CC="ccache ${CC}" - - # ccache splits up the compile steps, so we end up with unused arguments in some steps. - # Clang also thinks that ccache isn't interactive, so we explicitly need to enable color. - if [ $(echo | ${CXX} -dM -E - | grep -c "#define __clang__ 1") -ge 1 ]; then - export CXX="${CXX} -Qunused-arguments -fcolor-diagnostics" - export CC="${CC} -Qunused-arguments -fcolor-diagnostics" - else - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60304 - # GCC normally throws this error which is in GTest, but *only* when compilation and - # preprocessing aren't combined in one step. However, when using ccache with GCC, we are - # running them in separate steps, so this warning/error is shown. - export CXX="${CXX} -Wno-conversion-null" - export CC="${CC} -Wno-conversion-null" - fi -fi - -echo "export CXX=\"${CXX}\"" -echo "export CC=\"${CC}\"" -${CXX} --version diff --git a/scripts/tidy.sh b/scripts/tidy.sh new file mode 100755 index 0000000000..424c82c3cd --- /dev/null +++ b/scripts/tidy.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +# Ensure mason is on the PATH +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" + +BUILDTYPE=${BUILDTYPE:-Release} + +export CLANG_TIDY=clang-tidy-3.8 + +mapbox_time "config" \ +make config + +mapbox_time "tidy" \ +make tidy diff --git a/scripts/travis_setup.sh b/scripts/travis_setup.sh new file mode 100755 index 0000000000..e9fa87811f --- /dev/null +++ b/scripts/travis_setup.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# This script is sourced; do not set -e or -o pipefail here. + +if [ ! -z "${_CXX}" ]; then export CXX="${_CXX}" ; fi +if [ ! -z "${_CC}" ]; then export CC="${_CC}" ; fi + +if [ "${CCACHE:-0}" -ge 1 ]; then + export CXX="ccache ${CXX}" + export CC="ccache ${CC}" + + # ccache splits up the compile steps, so we end up with unused arguments in some steps. + # Clang also thinks that ccache isn't interactive, so we explicitly need to enable color. + if [ $(echo | ${CXX} -dM -E - | grep -c "#define __clang__ 1") -ge 1 ]; then + export CXX="${CXX} -Qunused-arguments -fcolor-diagnostics" + export CC="${CC} -Qunused-arguments -fcolor-diagnostics" + else + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60304 + # GCC normally throws this error which is in GTest, but *only* when compilation and + # preprocessing aren't combined in one step. However, when using ccache with GCC, we are + # running them in separate steps, so this warning/error is shown. + export CXX="${CXX} -Wno-conversion-null" + export CC="${CC} -Wno-conversion-null" + fi +fi + +echo "export CXX=\"${CXX}\"" +echo "export CC=\"${CC}\"" +${CXX} --version + +# Ensure mason is on the PATH +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" + +# 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 + +mapbox_time "checkout_mason" \ +git submodule update --init .mason + +# Install and set up to load a more recent version of mesa +mapbox_time "install_mesa" \ +mason install mesa 10.4.3 +export LD_LIBRARY_PATH="`mason prefix mesa 10.4.3`/lib:${LD_LIBRARY_PATH:-}" + +# Install and set up to load awscli +pip install --user awscli +export PATH="`python -m site --user-base`/bin:${PATH}" + +# Install coveralls gem +gem install coveralls-lcov --no-rdoc --no-ri diff --git a/test/api/render_missing.cpp b/test/api/render_missing.cpp index 8c3a1f8e52..f29a0c2b9c 100644 --- a/test/api/render_missing.cpp +++ b/test/api/render_missing.cpp @@ -45,15 +45,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) { std::rethrow_exception(err); } catch (const std::exception& ex) { message = ex.what(); -#ifdef MBGL_HTTP_NSURL - EXPECT_STREQ("Could not connect to the server.", ex.what()); -#elif MBGL_HTTP_CURL - const char* prefix = "Couldn't connect to server:"; - EXPECT_EQ(0, strncmp(prefix, ex.what(), strlen(prefix))) << "Full message is: \"" - << ex.what() << "\""; -#else - FAIL(); -#endif + EXPECT_TRUE(message.find("connect") != std::string::npos); } promise.set_value(); }); diff --git a/test/storage/http_error.cpp b/test/storage/http_error.cpp index 073f48b1b1..dfe4a55973 100644 --- a/test/storage/http_error.cpp +++ b/test/storage/http_error.cpp @@ -69,17 +69,6 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPConnectionError)) { EXPECT_GT(wait + 0.2, duration) << "Backoff timer fired too late"; ASSERT_NE(nullptr, res.error); EXPECT_EQ(Response::Error::Reason::Connection, res.error->reason); -#ifdef MBGL_HTTP_NSURL - EXPECT_TRUE(res.error->message == - "The operation couldn’t be completed. (NSURLErrorDomain error -1004.)" || - res.error->message == "Could not connect to the server.") - << "Full message is: \"" << res.error->message << "\""; -#elif MBGL_HTTP_CURL - const std::string prefix { "Couldn't connect to server: " }; - EXPECT_STREQ(prefix.c_str(), res.error->message.substr(0, prefix.size()).c_str()) << "Full message is: \"" << res.error->message << "\""; -#else - FAIL(); -#endif ASSERT_FALSE(res.data.get()); EXPECT_FALSE(bool(res.expires)); EXPECT_FALSE(bool(res.modified)); diff --git a/test/storage/http_retry_network_status.cpp b/test/storage/http_retry_network_status.cpp index 249f74c264..94a2bcdc4d 100644 --- a/test/storage/http_retry_network_status.cpp +++ b/test/storage/http_retry_network_status.cpp @@ -70,17 +70,6 @@ TEST_F(Storage, TEST_REQUIRES_SERVER(HTTPNetworkStatusChangePreempt)) { } ASSERT_NE(nullptr, res.error); EXPECT_EQ(Response::Error::Reason::Connection, res.error->reason); -#ifdef MBGL_HTTP_NSURL - EXPECT_TRUE(res.error->message == - "The operation couldn’t be completed. (NSURLErrorDomain error -1004.)" || - res.error->message == "Could not connect to the server.") - << "Full message is: \"" << res.error->message << "\""; -#elif MBGL_HTTP_CURL - const std::string prefix { "Couldn't connect to server: " }; - EXPECT_STREQ(prefix.c_str(), res.error->message.substr(0, prefix.size()).c_str()) << "Full message is: \"" << res.error->message << "\""; -#else - FAIL(); -#endif ASSERT_FALSE(res.data.get()); EXPECT_FALSE(bool(res.expires)); EXPECT_FALSE(bool(res.modified)); diff --git a/test/test.gypi b/test/test.gypi index c93b5b67b8..782d98e43f 100644 --- a/test/test.gypi +++ b/test/test.gypi @@ -1,24 +1,19 @@ { - 'includes': [ - '../gyp/common.gypi', - ], - 'targets': [ - { 'target_name': 'test', + { + 'target_name': 'test', 'type': 'executable', 'include_dirs': [ + '../include', '../src', '../platform/default', 'include', ], 'dependencies': [ - 'mbgl.gyp:core', - 'mbgl.gyp:platform-<(platform_lib)', - 'mbgl.gyp:http-<(http_lib)', - 'mbgl.gyp:asset-<(asset_lib)', - 'mbgl.gyp:headless-<(headless_lib)', + 'platform-lib', + 'copy_certificate_bundle', ], 'sources': [ @@ -96,6 +91,8 @@ 'sprite/sprite_image.cpp', 'sprite/sprite_parser.cpp', 'sprite/sprite_store.cpp', + + 'src/main.cpp', ], 'variables': { @@ -121,30 +118,6 @@ }, 'conditions': [ - ['host == "ios"', { - 'product_name': 'ios-test', - # iOS tests - 'includes': [ - '../gyp/target-ios-bundle.gypi', - ], - 'sources': [ - 'src/main.mm', - '../src/mbgl/util/premultiply.cpp', - ], - 'xcode_settings': { - 'INFOPLIST_FILE': '../test/src/app-info.plist', - }, - 'copies': [ - { 'destination': '<(PRODUCT_DIR)/$(WRAPPER_NAME)/test', - 'files': [ '../test/fixtures' ], - }, - ] - }, { - # non-iOS tests - 'sources': [ - 'src/main.cpp', - ] - }], ['OS == "mac"', { 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], -- cgit v1.2.1