diff --git a/.travis.yml b/.travis.yml index 66423f4ef..f09282a9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,10 +19,9 @@ matrix: env: global: - - secure: "HPlPuLk531F7bCyADMcxQ+I1CfGhJlhX9A3q3auNCdLsjqaZbktaCIGuq4R1IPZz0UTtO8RfrTfVaoktyZdq2QyU3iD8oj6BeZ/Jypr4TCBJxI5IeyU3gyPMFHqUYIJuHL9k40Xu7Dhf4HT123zr8KoeVqCHauZP1/TumA0nezg=" - - secure: "R/+uOeccl7GqjJbknailAV7VtjAtGwHHM9xToVnhfPVUXp9fzJs+oNk3IWcs3Eg4sw4WsYxXRfbCQG9bA3MnPlTOsxETGRioO9CAuXap6mwcwNAzeWuq7ePFki2u01pJGQD5b6WFqBCdnAQ4o2SgHgGzhs0TJzYd9tONQxSmkCI=" + - secure: "bG4YYWMfl9API0MSRgmOaJrlGLv06tRg9KJNawBieZvBJbITPpxVGJZT3/l/SEJ+Rl15e2dRex4k+MGQlmT2SqPQxTEYWv1qxNigKPPcla7IWeNmWWqW8uVvFjdglojgBOK2k/xErVQtA4zDfi3mwSXH4DKwquXWsoEKmX2SV7M=" + - secure: "Cbvap9ubVKgjPe3hUhI6JGeDZzBXHpOG9RaYKh+SdoIPhKnlJiNOYm1egomi+e4uqJInlFKuVHTw7Ng9Cun6Zm0jIxpkSchv1GpsR7hmB3UGnGed19Dw8121FwuUaktN+4YnbVlsyd+u8EHD3+h58t4eELrLrZolM4rS7DL6caA=" - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" - - AWS_S3_BUCKET: 'node-mapbox-gl-native' - LD_LIBRARY_PATH: '/usr/local/lib' before_install: diff --git a/Makefile b/Makefile index 95a7d90f3..2431f7be7 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,35 @@ BUILDTYPE ?= Release PYTHON ?= python V ?= 1 +PREFIX ?= /usr/local + +ifeq ($(shell uname -s), Darwin) +PLATFORM ?= osx +endif +PLATFORM ?= linux + all: mbgl -config.gypi: +config.gypi: configure ./configure -config-ios.gypi: +config-ios.gypi: configure MASON_PLATFORM=ios ./configure config-ios.gypi # Builds the regular library mbgl: config.gypi mapboxgl.gyp - deps/run_gyp mapboxgl.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make - $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mapboxgl + deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl + +install: config.gypi mapboxgl.gyp + deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) -Dinstall_prefix=$(PREFIX) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) install ##### Test cases ############################################################### build/test/Makefile: src common config.gypi test/test.gyp - deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/test -f make + deps/run_gyp test/test.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/test -f make test: build/test/Makefile $(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) test @@ -29,7 +40,7 @@ test_%: build/test/Makefile # build Mac OS X project for Xcode xtest: config.gypi clear_xcode_cache - deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build -f xcode + deps/run_gyp test/test.gyp -Iconfig.gypi -Dplatform=osx --depth=. -Goutput_dir=.. --generator-output=./build -f xcode open ./build/test/test.xcodeproj ##### Makefile builds ########################################################## @@ -37,7 +48,7 @@ xtest: config.gypi clear_xcode_cache # Builds the linux app with make. linux: config.gypi linux/mapboxgl-app.gyp - deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make + deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=linux --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make $(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp # Executes the Linux binary @@ -48,7 +59,7 @@ run-linux: linux # Builds the OS X app with make. osx: config.gypi macosx/mapboxgl-app.gyp - deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make + deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=osx --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make $(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp # Executes the OS X binary @@ -70,21 +81,21 @@ clear_xcode_cache: # build Mac OS X project for Xcode xproj-cli: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache - deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode + deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=osx --depth=. --generator-output=./build -f xcode xproj: xproj-cli open ./build/macosx/mapboxgl-app.xcodeproj # build iOS project for Xcode iproj-cli: config-ios.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache - deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp -Iconfig-ios.gypi --depth=. --generator-output=./build -f xcode + deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp -Iconfig-ios.gypi -Dplatform=ios --depth=. --generator-output=./build -f xcode iproj: iproj-cli open ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj # build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code) lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache - deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode + deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=linux --depth=. --generator-output=./build -f xcode open ./build/linux/mapboxgl-app.xcodeproj @@ -98,5 +109,5 @@ clean: clear_xcode_cache distclean: clean -rm -rf ./mason_packages -.PHONY: mbgl test linux build/test/Makefile clean distclean +.PHONY: mbgl install test linux clear_xcode_cache build/test/Makefile clean distclean # DO NOT DELETE diff --git a/README.md b/README.md index ee9d1bacb..8d55c2ac3 100644 --- a/README.md +++ b/README.md @@ -6,114 +6,129 @@ implemented in C++11, currently targeting iOS, OS X, and Ubuntu Linux. # Depends - Modern C++ compiler that supports `-std=c++11` (On OS X clang++, on Linux g++-4.8 or g++-4.9) - - Boost headers - - `libpng` - - `libuv` - - `glfw3` - - `libcurl` (depends on OpenSSL; Linux only) + - [Boost headers](http://boost.org/) + - [`zlib`](http://www.zlib.net/) + - [`libpng`](http://www.libpng.org/pub/png/libpng.html) + - [`libuv 0.10+`](https://github.com/joyent/libuv) + - [`glfw 3.1+`](http://www.glfw.org/) + - [`libcurl`](http://curl.haxx.se/libcurl/) (depends on OpenSSL; Linux only) - `libboost_regex` (Linux only) - Apple Command Line Tools (for build on OS X; available at [Apple Developer](https://developer.apple.com/downloads)) + - `pkg-config` (for build only) - [Homebrew](http://brew.sh) (for build on OS X) - Python 2.x (for build only) - Node.js (for build only) # Build instructions -We use [mapnik-packaging](https://github.com/mapnik/mapnik-packaging) to build static libraries of -dependencies. +We try to link to as many system-provided libraries as possible. When these are unavailable or too outdated, we run a thin build-script layer called [Mason](https://github.com/mapbox/mason) to automate builds, and load precompiled binary packages when possible. -First off: if you hit problems during development try: +## OS X - make clean +On OS X, we are using `zlib`, `SQLite3`, `libcurl` and `libpng` provided by the operating system. In addition to that, you need to have the Boost headers installed. To install all prerequisites, use [Homebrew](http://brew.sh/) and type `brew install pkg-config boost`. -This will clear cached build data and update to the latest versions of dependencies. +To create projects, you can run: -### Mapbox API access tokens +- `make xproj`: Creates an Xcode project with OS X-specific handlers for HTTP downloads and settings storage. It uses [GLFW](http://www.glfw.org) for window handling. +- `make lproj`: Creates an Xcode project with platform-independent handlers for downloads and settings storage. This is what is also being built on Linux. +- `make osx run-osx`: Builds and runs the OS X application on the command line with `xcodebuild`. +- `make linux run-linux`: Builds and runs the Linux application with `make`. -The demo applications use Mapbox vector tiles, which **require a Mapbox account and API access token**. Obtain an access token on the [Mapbox account page](https://www.mapbox.com/account/apps/). +Note that you can't have more than one project in Xcode open at a time since they the static library project is shared across the OS X, Linux and iOS project. -For iOS and OS X use of the demo apps in Xcode, setup the access token by editing the scheme for the application target, then adding an environment variable with the name `MAPBOX_ACCESS_TOKEN`. +Target OS: 10.9+ + + +## iOS + +iOS makes use of a Cocoa-specific API called [`mapbox-gl-cocoa`](https://github.com/mapbox/mapbox-gl-cocoa). If you are just interested in running Mapbox GL on iOS and not developing with it, head to that project and you can use this library as a pre-built static library instead. A `UIView` interface to the map view and bundle resources are provided there. + +If you intend to develop here, `mapbox-gl-cocoa` is included as a submodule of the overall build setup. + +To pull down the submodule(s), run: + + git submodule init + git submodule update + +Then, you can run `make iproj` to create and open an Xcode project with an iOS-specific view controller housing. This will automatically install required dependencies as well. + +Note that if you are doing OS X development as well, to toggle from OS X back to iOS, you will need to `make iproj` again. + +Target devices: iPhone 4S and above (5, 5c, 5s, 6, 6 Plus) and iPad 2 and above (3, 4, Mini , Air, Mini 2, Air 2). + +Target OS: 7.0+ + +## Linux + +We are using Ubuntu for development. While the software should work on other distributions as well, we are not providing explicit build instructions here. + +Install GCC 4.8+ if you are running Ubuntu 13.10 or older. Alternatively, you can also use Clang 3.4+. + + sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test + sudo apt-get update + sudo apt-get install gcc-4.8 g++-4.8 + +Ensure you have git and other build essentials: + + sudo apt-get install git build-essential zlib1g-dev automake \ + libtool xutils-dev make cmake pkg-config python-pip \ + libcurl4-openssl-dev libpng-dev libsqlite3-dev + +Install glfw3 dependencies: + + sudo apt-get install libxi-dev libglu1-mesa-dev x11proto-randr-dev \ + x11proto-xext-dev libxrandr-dev \ + x11proto-xf86vidmode-dev libxxf86vm-dev \ + libxcursor-dev libxinerama-dev + +Finally, install Boost. If you're running Ubuntu 12.04 or older, you need to install a backport PPA since the version provided by APT doesn't contain Boost Geometry: + + sudo add-apt-repository --yes ppa:boost-latest/ppa + sudo apt-get update + sudo apt-get install libboost1.55-dev libboost-regex1.55-dev + +Otherwise, you can just install + + sudo apt-get install libboost-dev libboost-regex-dev + +Once you're done installing the build dependencies, you can get started by running + + ./configure + +which downloads all other dependencies that we need to build manually with [Mason](https://github.com/mapbox/mason). There's a good chance that there already are binary files and that you don't need to compile anything. + +Then, you can then proceed to build the library like: + + make mbgl + +Or proceed to building the debug application with: + + make linux + + +# Troubleshooting + +To trigger a complete rebuild, run `make clean` and then start over generating the Xcode projects or Makefiles as described above. + +If you are having trouble getting the dependencies right, you can blow away the `mason_packages` directory, or run `make distclean`. This means the Makefile and configure script will automatically install the dependencies again on the next try. + +On OS X, you can also try clearing the Xcode cache with `make clear_xcode_cache`. + +# Mapbox API access tokens + +The demo applications use Mapbox vector tiles, which **require a Mapbox account and API access token**. Obtain an access token on the [Mapbox account page](https://www.mapbox.com/account/apps/). + +For iOS and OS X use of the demo apps in Xcode, setup the access token by editing the scheme for the application target, then adding an environment variable with the name `MAPBOX_ACCESS_TOKEN`. ![edit scheme](https://cloud.githubusercontent.com/assets/98601/3647749/30f74f26-1102-11e4-84af-f1be853b4e38.png) ![setting access token in Xcode scheme](https://cloud.githubusercontent.com/assets/52399/3543326/9e7cfbb8-0860-11e4-8def-3684a9028b61.png) -## OS X - -Run: - - make setup - -This downloads all required dependencies, builds them and creates universal libraries that can be used on both OS X and iOS. - -To create projects, you can run: -- `make xproj`: Creates an Xcode project with OS X-specific handlers for HTTP downloads and - settings storage. It uses [GLFW](http://www.glfw.org) for window handling. -- `make lproj`: Creates an Xcode project with platform-independent handlers for downloads - and settings storage. This is what is also being built on Linux. -- `make linux`: Builds the Linux GLFW application with `make`. - -Note that if you are doing iOS development as well, to toggle from iOS back to OS X, you will need to `make xproj` again. - -Target OS: 10.9+ - -## iOS - -iOS makes use of a Cocoa-specific API called [`mapbox-gl-cocoa`](https://github.com/mapbox/mapbox-gl-cocoa). If you are just interested in running Mapbox GL on iOS and not developing with it, head to that project and you can use this library as a pre-built static library instead. A `UIView` interface to the map view and bundle resources are provided there. - -If you intend to develop here, `mapbox-gl-cocoa` is included as a submodule of the overall build setup. - -First, pull down the submodule(s): - - git submodule init - git submodule update - -Then run: - - make setup - -This downloads all required dependencies, builds them and creates universal libraries that can be used on both OS X and iOS. - -Lastly, `make iproj` to create and open an Xcode project with an iOS-specific view controller housing. - -Note that if you are doing OS X development as well, to toggle from OS X back to iOS, you will need to `make iproj` again. - -Target devices: iPhone 4 and above (4S, 5, 5c, 5s) and iPad 2 and above (3, 4, mini and/or retina). - -Target OS: 7.0+ - -## Ubuntu - -Set the environment variable `MAPBOX_ACCESS_TOKEN` to your token. - -Ensure you have git and other build essentials: - - sudo apt-get update - sudo apt-get install git build-essential zlib1g-dev automake libtool xutils-dev make cmake pkg-config nodejs-legacy curl libuv-dev - -If you are running Ubuntu 13.10 or older, install a `-std=c++11` capable compiler: - - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test - sudo apt-get update - sudo apt-get install gcc-4.8 g++-4.8 - -Install glfw3 dependencies: - - sudo apt-get install libxi-dev libglu1-mesa-dev x11proto-randr-dev x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev - -Then run: - - make setup - -This downloads all required dependencies, builds them and creates universal libraries that can be used on both OS X and iOS. - -You can then proceed to build the library like: - - make linux +For Linux, set the environment variable `MAPBOX_ACCESS_TOKEN` to your token. # Style -Some styles in JSON format are included at `./styles`. See the [style spec](https://github.com/mapbox/mapbox-gl-style-spec) for more details. +Some styles in JSON format are included at `./styles`. See the [style spec](https://github.com/mapbox/mapbox-gl-style-spec) for more details. # Usage @@ -136,4 +151,4 @@ Some styles in JSON format are included at `./styles`. See the [style spec](http # Other notes -Under early development, this project was called LLMR (Low-Level Map Renderer), in case you see any lingering references to it. +Under early development, this project was called LLMR (Low-Level Map Renderer), in case you see any lingering references to it. diff --git a/configure b/configure index 2fffd5920..ef289ac5d 100755 --- a/configure +++ b/configure @@ -2,6 +2,7 @@ set -e set -o pipefail +shopt -s expand_aliases CONFIG_FILE=${1:-config.gypi} @@ -26,6 +27,13 @@ else >&2 echo -en "\033[0m"; fi +# Install mason +if [[ ! -d ~/.mason ]]; then + >&2 echo -e "\033[1m\033[32m* Installing Mason\033[0m" + git clone https://github.com/mapbox/mason.git ~/.mason +fi +alias mason='~/.mason/mason' + case $MASON_PLATFORM in 'ios') diff --git a/gyp/certificates.gypi b/gyp/certificates.gypi new file mode 100644 index 000000000..1d0c2acf8 --- /dev/null +++ b/gyp/certificates.gypi @@ -0,0 +1,12 @@ +{ + 'targets': [ + { 'target_name': 'copy_certificate_bundle', + 'type': 'none', + 'hard_dependency': 1, + 'copies': [{ + 'files': [ '../common/ca-bundle.crt' ], + 'destination': '<(PRODUCT_DIR)' + }], + }, + ] +} diff --git a/common.gypi b/gyp/common.gypi similarity index 97% rename from common.gypi rename to gyp/common.gypi index 627c18668..6d6b0e667 100644 --- a/common.gypi +++ b/gyp/common.gypi @@ -1,4 +1,7 @@ { + 'variables': { + 'install_prefix%': '', + }, 'target_defaults': { 'default_configuration': 'Release', 'conditions': [ @@ -44,6 +47,6 @@ 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'NO' } }, - } + }, } } diff --git a/gyp/fixtures.gypi b/gyp/fixtures.gypi new file mode 100644 index 000000000..199865a6f --- /dev/null +++ b/gyp/fixtures.gypi @@ -0,0 +1,17 @@ +{ + 'targets': [ + { 'target_name': 'copy_fixtures', + 'type': 'none', + 'hard_dependency': 1, + 'dependencies': [ + 'bundle_styles' + ], + 'copies': [ + { + 'files': [ '../styles' ], + 'destination': '../test/fixtures/style_parser' + } + ] + }, + ] +} diff --git a/gyp/install.gypi b/gyp/install.gypi new file mode 100644 index 000000000..8b79a4518 --- /dev/null +++ b/gyp/install.gypi @@ -0,0 +1,23 @@ +{ + 'conditions': [ + ['install_prefix != ""', { + 'targets': [ + { 'target_name': 'install', + 'type': 'none', + 'hard_dependency': 1, + 'dependencies': [ + 'mbgl', + 'mbgl-headless', + 'mbgl-<(platform)', + ], + 'copies': [ + { 'files': [ '<(PRODUCT_DIR)/libmbgl.a' ], 'destination': '<(install_prefix)/lib' }, + { 'files': [ '<(PRODUCT_DIR)/libmbgl-headless.a' ], 'destination': '<(install_prefix)/lib' }, + { 'files': [ '<(PRODUCT_DIR)/libmbgl-<(platform).a' ], 'destination': '<(install_prefix)/lib' }, + { 'files': [ '../include/mbgl' ], 'destination': '<(install_prefix)/include' } + ], + }, + ] + }], + ], +} diff --git a/gyp/mbgl-headless.gypi b/gyp/mbgl-headless.gypi new file mode 100644 index 000000000..5ffc251d2 --- /dev/null +++ b/gyp/mbgl-headless.gypi @@ -0,0 +1,15 @@ +{ + 'targets': [ + { 'target_name': 'mbgl-headless', + 'product_name': 'mbgl-headless', + 'type': 'static_library', + 'include_dirs': [ + '../include', + ], + 'sources': [ + '../platform/default/headless_view.cpp', + '../platform/default/headless_display.cpp', + ], + }, + ] +} \ No newline at end of file diff --git a/gyp/mbgl-ios.gypi b/gyp/mbgl-ios.gypi new file mode 100644 index 000000000..dbad60086 --- /dev/null +++ b/gyp/mbgl-ios.gypi @@ -0,0 +1,58 @@ +{ + 'target_defaults': { + 'target_conditions': [ + ['_type == "static_library"', { + 'xcode_settings': { + 'SDKROOT': 'iphoneos', + 'SUPPORTED_PLATFORMS': 'iphonesimulator iphoneos', + 'CLANG_CXX_LIBRARY': 'libc++', + 'CLANG_CXX_LANGUAGE_STANDARD':'c++11', + 'IPHONEOS_DEPLOYMENT_TARGET':'7.0', + 'TARGETED_DEVICE_FAMILY': '1,2', + 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', + 'CLANG_ENABLE_OBJC_ARC': 'YES', + 'CODE_SIGN_IDENTITY': 'iPhone Developer', + 'PUBLIC_HEADERS_FOLDER_PATH': 'include', + }, + 'configurations': { + 'Release': { + 'xcode_settings': { + 'ARCHS': [ "armv7", "armv7s", "arm64", "i386", "x86_64" ], + }, + }, + }, + }], + ], + }, + 'targets': [ + { 'target_name': 'mbgl-ios', + 'product_name': 'mbgl-ios', + 'type': 'static_library', + 'hard_dependency': 1, + 'include_dirs': [ + '../include', + ], + 'sources': [ + '../platform/ios/cache_database_library.mm', + '../platform/darwin/log_nslog.mm', + '../platform/darwin/string_nsstring.mm', + '../platform/darwin/http_request_baton_cocoa.mm', + ], + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ + '<@(uv_cflags)', + ], + }, + 'direct_dependent_settings': { + 'include_dirs': [ + '../include', + ], + 'xcode_settings': { + 'OTHER_LDFLAGS': [ + '<@(uv_libraries)', + ], + }, + }, + }, + ], +} diff --git a/gyp/mbgl-linux.gypi b/gyp/mbgl-linux.gypi new file mode 100644 index 000000000..39a175556 --- /dev/null +++ b/gyp/mbgl-linux.gypi @@ -0,0 +1,54 @@ +{ + 'targets': [ + { 'target_name': 'mbgl-linux', + 'product_name': 'mbgl-linux', + 'type': 'static_library', + 'hard_dependency': 1, + 'include_dirs': [ + '../include' + ], + 'sources': [ + '../platform/default/cache_database_tmp.cpp', + '../platform/default/log_stderr.cpp', + '../platform/default/string_stdlib.cpp', + '../platform/default/http_request_baton_curl.cpp', + ], + 'conditions': [ + ['OS == "mac"', { + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ + '<@(uv_cflags)', + '<@(curl_cflags)', + ], + } + }, { + 'cflags': [ + '<@(uv_cflags)', + '<@(curl_cflags)', + ], + }] + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '../include', + ], + 'conditions': [ + ['OS == "mac"', { + 'xcode_settings': { + 'OTHER_LDFLAGS': [ + '<@(uv_libraries)', + '<@(curl_libraries)', + ] + } + }, { + 'libraries': [ + '<@(uv_libraries)', + '<@(curl_libraries)', + '-lboost_regex', + ] + }] + ] + } + }, + ] +} diff --git a/gyp/mbgl-osx.gypi b/gyp/mbgl-osx.gypi new file mode 100644 index 000000000..ba117e5a5 --- /dev/null +++ b/gyp/mbgl-osx.gypi @@ -0,0 +1,33 @@ +{ + 'targets': [ + { 'target_name': 'mbgl-osx', + 'product_name': 'mbgl-osx', + 'type': 'static_library', + 'hard_dependency': 1, + 'include_dirs': [ + '../include', + ], + 'sources': [ + '../platform/osx/cache_database_application_support.mm', + '../platform/darwin/log_nslog.mm', + '../platform/darwin/string_nsstring.mm', + '../platform/darwin/http_request_baton_cocoa.mm', + ], + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ + '<@(uv_cflags)', + ], + }, + 'direct_dependent_settings': { + 'include_dirs': [ + '../include', + ], + 'xcode_settings': { + 'OTHER_LDFLAGS': [ + '<@(uv_libraries)', + ], + }, + }, + }, + ], +} diff --git a/gyp/mbgl-platform.gypi b/gyp/mbgl-platform.gypi new file mode 100644 index 000000000..74ac9aecc --- /dev/null +++ b/gyp/mbgl-platform.gypi @@ -0,0 +1,16 @@ +{ + 'conditions': [ + ['platform == "osx"', { + 'includes': ['mbgl-osx.gypi'], + 'variables': { 'platform_library': 'mbgl-osx' }, + }], + ['platform == "ios"', { + 'includes': ['mbgl-ios.gypi'], + 'variables': { 'platform_library': 'mbgl-ios' }, + }], + ['platform == "linux"', { + 'includes': ['mbgl-linux.gypi'], + 'variables': { 'platform_library': 'mbgl-linux' }, + }], + ], +} diff --git a/gyp/mbgl.gypi b/gyp/mbgl.gypi new file mode 100644 index 000000000..f268fd625 --- /dev/null +++ b/gyp/mbgl.gypi @@ -0,0 +1,74 @@ +{ + 'targets': [ + { 'target_name': 'mbgl', + 'product_name': 'mbgl', + 'type': 'static_library', + 'hard_dependency': 1, + 'dependencies': [ + 'shaders', + ], + 'sources': [ + ' -#include #include +#include +#include +#include +#include #include #include #include #include -#include "../common/settings_json.hpp" -#include "../common/glfw_view.hpp" -#include "../common/stderr_log.hpp" + GLFWView *view = nullptr; diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index 05716dd11..ee38b4b26 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -1,7 +1,6 @@ { 'includes': [ - '../common.gypi', - '../config.gypi', + '../gyp/common.gypi', ], 'targets': [ { @@ -10,15 +9,9 @@ 'type': 'executable', 'sources': [ './main.cpp', - '../common/settings_json.cpp', - '../common/settings_json.hpp', - '../common/platform_default.cpp', - '../common/glfw_view.hpp', - '../common/glfw_view.cpp', - '../common/http_request_baton_curl.cpp', - '../common/linux.cpp', - '../common/stderr_log.hpp', - '../common/stderr_log.cpp', + '../platform/default/settings_json.cpp', + '../platform/default/glfw_view.cpp', + '../platform/default/log_stderr.cpp', ], 'conditions': [ @@ -29,11 +22,9 @@ 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS':[ '<@(glfw3_cflags)', - '<@(curl_cflags)', ], 'OTHER_LDFLAGS': [ '<@(glfw3_libraries)', - '<@(curl_libraries)', ], } }, @@ -42,19 +33,19 @@ { 'cflags': [ '<@(glfw3_cflags)', - '<@(curl_cflags)', ], 'link_settings': { 'libraries': [ '<@(glfw3_libraries)', - '<@(curl_libraries)', - '-lboost_regex' + '-L<(boost_root)/lib', + '-lboost_regex', ], }, }], ], 'dependencies': [ - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-linux', '../mapboxgl.gyp:copy_styles', '../mapboxgl.gyp:copy_certificate_bundle', ], diff --git a/macosx/main.mm b/macosx/main.mm index 8cf3cc81c..81494821c 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -1,12 +1,10 @@ -#include "../common/settings_nsuserdefaults.hpp" -#include "../common/glfw_view.hpp" -#include "../common/nslog_log.hpp" -#include "../common/Reachability.h" +#include +#include +#include +#include #import -#include - @interface URLHandler : NSObject @property (nonatomic) mbgl::Map *map; @@ -71,7 +69,6 @@ @end int main() { - fprintf(stderr, "main thread: 0x%lx\n", uv_thread_self()); mbgl::Log::Set(); GLFWView view; diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index 51f591fdd..fe8d9f7ae 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -1,7 +1,6 @@ { 'includes': [ - '../common.gypi', - '../config.gypi' + '../gyp/common.gypi', ], 'targets': [ { @@ -10,17 +9,11 @@ 'type': 'executable', 'sources': [ './main.mm', - '../common/settings_nsuserdefaults.hpp', - '../common/settings_nsuserdefaults.mm', - '../common/platform_nsstring.mm', - '../common/glfw_view.hpp', - '../common/glfw_view.cpp', - '../common/reachability.h', - '../common/reachability.m', - '../common/http_request_baton_cocoa.mm', - '../common/osx.mm', - '../common/nslog_log.hpp', - '../common/nslog_log.mm', + '../platform/darwin/settings_nsuserdefaults.hpp', + '../platform/darwin/settings_nsuserdefaults.mm', + '../platform/darwin/reachability.m', + '../platform/default/glfw_view.hpp', + '../platform/default/glfw_view.cpp', ], 'product_extension': 'app', 'mac_bundle': 1, @@ -44,7 +37,8 @@ }, 'dependencies': [ '../mapboxgl.gyp:bundle_styles', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-osx', ] } ] diff --git a/mapboxgl.gyp b/mapboxgl.gyp index bdecb94d0..9126a1a62 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -1,248 +1,14 @@ { 'includes': [ - './common.gypi', + './gyp/common.gypi', + './gyp/shaders.gypi', + './gyp/npm_install.gypi', + './gyp/styles.gypi', + './gyp/fixtures.gypi', + './gyp/certificates.gypi', + './gyp/mbgl.gypi', + './gyp/mbgl-platform.gypi', + './gyp/mbgl-headless.gypi', + './gyp/install.gypi', ], - 'targets': [ - { - 'target_name': 'shaders', - 'type': 'none', - 'hard_dependency': 1, - 'dependencies': [ - 'npm_install' - ], - 'actions': [ - { - 'action_name': 'Build Shaders', - 'inputs': [ - ' #import diff --git a/common/Reachability.m b/platform/darwin/reachability.m similarity index 99% rename from common/Reachability.m rename to platform/darwin/reachability.m index c6f6388f5..823465940 100644 --- a/common/Reachability.m +++ b/platform/darwin/reachability.m @@ -25,7 +25,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -#import "Reachability.h" +#import NSString *const kReachabilityChangedNotification = @"kReachabilityChangedNotification"; diff --git a/common/settings_nsuserdefaults.mm b/platform/darwin/settings_nsuserdefaults.mm similarity index 96% rename from common/settings_nsuserdefaults.mm rename to platform/darwin/settings_nsuserdefaults.mm index dfc601bdd..b9b0e134b 100644 --- a/common/settings_nsuserdefaults.mm +++ b/platform/darwin/settings_nsuserdefaults.mm @@ -1,6 +1,6 @@ #import -#include "settings_nsuserdefaults.hpp" +#include using namespace mbgl; diff --git a/common/platform_nsstring.mm b/platform/darwin/string_nsstring.mm similarity index 99% rename from common/platform_nsstring.mm rename to platform/darwin/string_nsstring.mm index 9119f2a8f..9b1dc745c 100644 --- a/common/platform_nsstring.mm +++ b/platform/darwin/string_nsstring.mm @@ -18,4 +18,4 @@ std::string lowercase(const std::string &string) { } } -} \ No newline at end of file +} diff --git a/common/linux.cpp b/platform/default/cache_database_tmp.cpp similarity index 100% rename from common/linux.cpp rename to platform/default/cache_database_tmp.cpp diff --git a/common/glfw_view.cpp b/platform/default/glfw_view.cpp similarity index 99% rename from common/glfw_view.cpp rename to platform/default/glfw_view.cpp index 92d1e1908..baacfbfd9 100644 --- a/common/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -1,4 +1,4 @@ -#include "glfw_view.hpp" +#include #include diff --git a/common/headless_display.cpp b/platform/default/headless_display.cpp similarity index 97% rename from common/headless_display.cpp rename to platform/default/headless_display.cpp index 3aaf2020b..409fcbf05 100644 --- a/common/headless_display.cpp +++ b/platform/default/headless_display.cpp @@ -1,4 +1,4 @@ -#include "headless_display.hpp" +#include #include #include diff --git a/common/headless_view.cpp b/platform/default/headless_view.cpp similarity index 98% rename from common/headless_view.cpp rename to platform/default/headless_view.cpp index d1d13db5f..ec5c4aabe 100644 --- a/common/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -1,5 +1,5 @@ -#include "headless_view.hpp" -#include "headless_display.hpp" +#include +#include #include #include diff --git a/common/http_request_baton_curl.cpp b/platform/default/http_request_baton_curl.cpp similarity index 100% rename from common/http_request_baton_curl.cpp rename to platform/default/http_request_baton_curl.cpp diff --git a/common/stderr_log.cpp b/platform/default/log_stderr.cpp similarity index 94% rename from common/stderr_log.cpp rename to platform/default/log_stderr.cpp index bcb84447b..62938b6d6 100644 --- a/common/stderr_log.cpp +++ b/platform/default/log_stderr.cpp @@ -1,4 +1,4 @@ -#include "stderr_log.hpp" +#include #include #include diff --git a/common/settings_json.cpp b/platform/default/settings_json.cpp similarity index 95% rename from common/settings_json.cpp rename to platform/default/settings_json.cpp index f2f1248aa..f81c75115 100644 --- a/common/settings_json.cpp +++ b/platform/default/settings_json.cpp @@ -1,4 +1,4 @@ -#include "settings_json.hpp" +#include #include #include #include diff --git a/common/platform_default.cpp b/platform/default/string_stdlib.cpp similarity index 100% rename from common/platform_default.cpp rename to platform/default/string_stdlib.cpp diff --git a/common/ios.mm b/platform/ios/cache_database_library.mm similarity index 100% rename from common/ios.mm rename to platform/ios/cache_database_library.mm diff --git a/common/osx.mm b/platform/osx/cache_database_application_support.mm similarity index 100% rename from common/osx.mm rename to platform/osx/cache_database_application_support.mm diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 6b42b7991..e10700076 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -10,7 +10,10 @@ for TEST in ./test_* ; do ulimit -c unlimited -S echo 'ulimit -c: '`ulimit -c` echo '/proc/sys/kernel/core_pattern: '`cat /proc/sys/kernel/core_pattern` - sysctl kernel.core_pattern + + if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then + sysctl kernel.core_pattern + fi RESULT=0 ${TEST} || RESULT=$? diff --git a/test/headless.cpp b/test/headless.cpp index 02dd0165e..e1bdbdc06 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -9,8 +9,8 @@ #include #include -#include "../common/headless_view.hpp" -#include "../common/headless_display.hpp" +#include +#include #include "./fixtures/fixture_log.hpp" diff --git a/test/test.gyp b/test/test.gyp index 8bf1dffdf..daf74b3e9 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -1,201 +1,154 @@ { 'includes': [ - '../common.gypi', - '../config.gypi' + '../gyp/common.gypi', + '../gyp/mbgl-platform.gypi', ], 'targets': [ - { - 'target_name': 'link_gl', - 'type': 'none', - 'direct_dependent_settings': { - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_LDFLAGS': [ - '<@(glfw3_libraries)', # This is a hack since we're not actually using GLFW - ], - }, - }, { - 'link_settings': { - 'libraries': [ - '<@(glfw3_libraries)', # This is a hack since we're not actually using GLFW - '-lboost_regex', - ], - }, - }], - ], - }, + { 'target_name': 'rotation_range', + 'product_name': 'test_rotation_range', + 'type': 'executable', + 'sources': [ + './main.cpp', + './rotation_range.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mbgl', + ] }, - { - 'target_name': 'link_curl', - 'type': 'none', - 'direct_dependent_settings': { - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS':[ - '<@(curl_cflags)', - ], - 'OTHER_LDFLAGS': [ - '<@(curl_libraries)', - ], - }, - }, { - 'cflags': [ - '<@(curl_cflags)', - ], - 'link_settings': { - 'libraries': [ - '<@(curl_libraries)', - ], - }, - }], - ], - }, + { 'target_name': 'clip_ids', + 'product_name': 'test_clip_ids', + 'type': 'executable', + 'sources': [ + './main.cpp', + './clip_ids.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mbgl', + ] }, - { - "target_name": "rotation_range", - "product_name": "test_rotation_range", - "type": "executable", - "sources": [ - "./main.cpp", - "./rotation_range.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", + { 'target_name': 'enums', + 'product_name': 'test_enums', + 'type': 'executable', + 'sources': [ + './main.cpp', + './enums.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mbgl', + ] + }, + { 'target_name': 'style_parser', + 'product_name': 'test_style_parser', + 'type': 'executable', + 'sources': [ + './main.cpp', + './style_parser.cpp', + './fixtures/fixture_log.hpp', + './fixtures/fixture_log.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:copy_fixtures', + ] + }, + { 'target_name': 'variant', + 'product_name': 'test_variant', + 'type': 'executable', + 'sources': [ + './main.cpp', + './variant.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mbgl', + ] + }, + { 'target_name': 'comparisons', + 'product_name': 'test_comparisons', + 'type': 'executable', + 'sources': [ + './main.cpp', + './comparisons.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mbgl', + ] + }, + { 'target_name': 'tile', + 'product_name': 'test_tile', + 'type': 'executable', + 'sources': [ + './main.cpp', + './tile.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mbgl', + ] + }, + { 'target_name': 'functions', + 'product_name': 'test_functions', + 'type': 'executable', + 'sources': [ + './main.cpp', + './functions.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mbgl', ] }, - { - "target_name": "clip_ids", - "product_name": "test_clip_ids", - "type": "executable", - "sources": [ - "./main.cpp", - "./clip_ids.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] + { 'target_name': 'headless', + 'product_name': 'test_headless', + 'type': 'executable', + 'sources': [ + './main.cpp', + './headless.cpp', + './fixtures/fixture_request.cpp', + './fixtures/fixture_log.cpp', + '../platform/default/headless_view.cpp', + '../platform/default/headless_display.cpp', + ], + 'conditions': [ + # add libuv include path and OpenGL libs + ['OS == "mac"', + { + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': ['<@(uv_cflags)'], + 'OTHER_LDFLAGS': ['<@(glfw3_libraries)'], + }, + }, + { + 'cflags': ['<@(uv_cflags)'], + 'libraries': ['<@(glfw3_libraries)'], + }], + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mbgl', + '<(platform_library)', + ], }, - { - "target_name": "enums", - "product_name": "test_enums", - "type": "executable", - "sources": [ - "./main.cpp", - "./enums.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "style_parser", - "product_name": "test_style_parser", - "type": "executable", - "sources": [ - "./main.cpp", - "./style_parser.cpp", - "./fixtures/fixture_log.hpp", - "./fixtures/fixture_log.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - "../mapboxgl.gyp:copy_fixtures", - ] - }, - { - "target_name": "variant", - "product_name": "test_variant", - "type": "executable", - "sources": [ - "./main.cpp", - "./variant.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "comparisons", - "product_name": "test_comparisons", - "type": "executable", - "sources": [ - "./main.cpp", - "./comparisons.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "tile", - "product_name": "test_tile", - "type": "executable", - "sources": [ - "./main.cpp", - "./tile.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "functions", - "product_name": "test_functions", - "type": "executable", - "sources": [ - "./main.cpp", - "./functions.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "headless", - "product_name": "test_headless", - "type": "executable", - "sources": [ - "./main.cpp", - "./headless.cpp", - "../common/headless_view.hpp", - "../common/headless_view.cpp", - "../common/headless_display.hpp", - "../common/headless_display.cpp", - "../common/platform_default.cpp", - "./fixtures/fixture_request.cpp", - "./fixtures/fixture_log.hpp", - "./fixtures/fixture_log.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - "link_gl", - ] - }, - { - "target_name": "test", - "type": "none", - "dependencies": [ - "rotation_range", - "clip_ids", - "enums", - "variant", - "tile", - "functions", - "headless", - "style_parser", - "comparisons", - ], + + # Build all targets + { 'target_name': 'test', + 'type': 'none', + 'dependencies': [ + 'rotation_range', + 'clip_ids', + 'enums', + 'variant', + 'tile', + 'functions', + 'headless', + 'style_parser', + 'comparisons', + ], } ] } diff --git a/travis/travis-resources.template b/travis/travis-resources.template index e1b0cff8c..2b7cea836 100644 --- a/travis/travis-resources.template +++ b/travis/travis-resources.template @@ -1,7 +1,7 @@ { "AWSTemplateFormatVersion": "2010-09-09", - "Description": "node-mapbox-gl-native travis resources", + "Description": "mapbox-gl-native travis resources", "Resources": { "BuildUser": { "Type": "AWS::IAM::User", @@ -17,7 +17,7 @@ ], "Effect": "Allow", "Resource": [ - "arn:aws:s3:::node-mapbox-gl-native" + "arn:aws:s3:::mapbox-gl-testing" ] } ] @@ -37,7 +37,7 @@ ], "Effect": "Allow", "Resource": [ - "arn:aws:s3:::node-mapbox-gl-native/*" + "arn:aws:s3:::mapbox-gl-testing/*" ] } ]