summaryrefslogtreecommitdiff
path: root/platform/linux
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-04-03 15:16:49 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-04-07 18:01:02 -0700
commitf964e40e7e9220d08751d8607af61ac5a7c0794c (patch)
treed34ca5407188fe3d71396faa8a8acceb52d9bd4b /platform/linux
parentf5d66f362272db034a311d2077dbdb2937c9bbdf (diff)
downloadqtlocation-mapboxgl-f964e40e7e9220d08751d8607af61ac5a7c0794c.tar.gz
[build] Refactor and simplify build system
* Main gyp files are now standardized as platform/<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.
Diffstat (limited to 'platform/linux')
-rw-r--r--platform/linux/README.md7
-rw-r--r--platform/linux/main.cpp176
-rw-r--r--platform/linux/mapboxgl-app.gypi66
-rw-r--r--platform/linux/platform.gyp97
-rwxr-xr-xplatform/linux/scripts/after_script.sh10
-rwxr-xr-xplatform/linux/scripts/coveralls.sh23
-rw-r--r--platform/linux/scripts/defaults.mk5
-rwxr-xr-xplatform/linux/scripts/install.sh11
-rwxr-xr-xplatform/linux/scripts/run.sh31
-rwxr-xr-xplatform/linux/scripts/setup.sh28
-rwxr-xr-xplatform/linux/scripts/tidy.sh17
11 files changed, 120 insertions, 351 deletions
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 <mbgl/mbgl.hpp>
-#include <mbgl/util/default_styles.hpp>
-#include <mbgl/platform/log.hpp>
-#include <mbgl/platform/platform.hpp>
-#include <mbgl/platform/default/settings_json.hpp>
-#include <mbgl/platform/default/glfw_view.hpp>
-#include <mbgl/storage/default_file_source.hpp>
-
-#include <signal.h>
-#include <getopt.h>
-#include <fstream>
-#include <sstream>
-#include <cstdlib>
-#include <cstdio>
-
-namespace {
-
-std::unique_ptr<GLFWView> 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<GLFWView>(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