summaryrefslogtreecommitdiff
path: root/bin
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 /bin
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 'bin')
-rw-r--r--bin/glfw.cpp176
-rw-r--r--bin/glfw.gypi62
-rw-r--r--bin/offline.gypi42
-rw-r--r--bin/render.gypi48
4 files changed, 270 insertions, 58 deletions
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 <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/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)',
+ ],
+ }
},
],
}