summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-04-19 17:51:36 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-04-20 20:55:51 +0300
commitc8c69f1d2a968dfc2556c3612e96ddba848ee885 (patch)
treea515b9e17ea8809b18c96c2e1808174b2ef57bbc
parent029f9f088331fa0d04a9b75a7dbdae773f749f47 (diff)
downloadqtlocation-mapboxgl-c8c69f1d2a968dfc2556c3612e96ddba848ee885.tar.gz
[Qt] Build the Qt port
-rw-r--r--Makefile18
-rwxr-xr-xconfigure7
-rw-r--r--platform/qt/app/qmapboxgl.gypi52
-rw-r--r--platform/qt/platform.gyp152
-rw-r--r--platform/qt/qt.gypi12
-rw-r--r--platform/qt/scripts/configure.sh37
-rw-r--r--scripts/main.mk17
7 files changed, 295 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index f1b5fe9bad..1534db8494 100644
--- a/Makefile
+++ b/Makefile
@@ -165,6 +165,24 @@ test-node: node
npm test
npm run test-suite
+#### Qt targets #####################################################
+
+.PHONY: qt-lib
+qt-lib:
+ $(RUN) PLATFORM=qt Makefile/qt-lib
+
+.PHONY: qt-app
+qt-app:
+ $(RUN) PLATFORM=qt Makefile/qt-app
+
+.PHONY: run-qt-app
+run-qt-app: qt-app
+ $(RUN) PLATFORM=qt run-qt-app
+
+.PHONY: test-qt
+test-qt: node_modules/express
+ $(RUN) PLATFORM=qt test-*
+
#### Miscellaneous targets #####################################################
.PHONY: linux
diff --git a/configure b/configure
index 1a8337d63e..3ce952af41 100755
--- a/configure
+++ b/configure
@@ -60,6 +60,12 @@ function print_opengl_flags {
CONFIG+=" 'opengl_ldflags%': [],"$LN
}
+function print_qt_flags {
+ CONFIG+=" 'qt_cflags%': [], "$LN
+ CONFIG+=" 'qt_ldflags%': [], "$LN
+ CONFIG+=" 'qt_moc%': [], "$LN
+}
+
# Load dependencies
source ${INPUT_FILE}
@@ -91,6 +97,7 @@ CONFIG+=" },"$LN
CONFIG+=" 'variables': {"$LN
print_opengl_flags
+print_qt_flags
print_flags boost cflags
print_flags boost_libprogram_options static_libs
diff --git a/platform/qt/app/qmapboxgl.gypi b/platform/qt/app/qmapboxgl.gypi
new file mode 100644
index 0000000000..c864d7d19e
--- /dev/null
+++ b/platform/qt/app/qmapboxgl.gypi
@@ -0,0 +1,52 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'qt-app',
+ 'product_name': 'qmapboxgl',
+ 'type': 'executable',
+
+ 'includes': [
+ '../qt.gypi',
+ ],
+
+ 'dependencies': [
+ 'platform-lib',
+ ],
+
+ 'sources': [
+ 'main.cpp',
+ 'mapwindow.cpp',
+ 'mapwindow.hpp',
+ ],
+
+ 'include_dirs': [
+ '../include',
+ '../../../include',
+ ],
+
+ 'variables': {
+ 'cflags': [
+ '<@(opengl_cflags)',
+ '<@(qt_cflags)',
+ '-Wno-error', # TODO: eliminate
+ ],
+ 'ldflags': [
+ '<@(opengl_ldflags)',
+ '<@(qt_ldflags)'
+ ],
+ },
+
+ 'conditions': [
+ ['OS == "mac"', {
+ 'xcode_settings': {
+ 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags)' ],
+ 'OTHER_LDFLAGS': [ '<@(ldflags)', '-framework OpenGL' ],
+ },
+ }, {
+ 'cflags_cc': [ '<@(cflags)' ],
+ 'libraries': [ '<@(ldflags)' ],
+ }],
+ ],
+ },
+ ],
+}
diff --git a/platform/qt/platform.gyp b/platform/qt/platform.gyp
new file mode 100644
index 0000000000..1135ec4a6a
--- /dev/null
+++ b/platform/qt/platform.gyp
@@ -0,0 +1,152 @@
+{
+ 'variables': {
+ 'loop_lib': 'qt',
+ 'conditions': [
+ ['OS == "mac"', {
+ 'headless_lib': 'cgl',
+ }, {
+ 'headless_lib': 'glx',
+ }]
+ ],
+ 'qtlibversion': '1.0.0',
+ },
+ 'includes': [
+ 'app/qmapboxgl.gypi',
+ '../../mbgl.gypi',
+ '../../test/test.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'platform-lib',
+ 'product_name': 'mbgl-platform-qt',
+ 'type': 'static_library',
+ 'standalone_static_library': 1,
+ 'hard_dependency': 1,
+
+ 'dependencies': [
+ 'core',
+ ],
+
+ 'includes': [
+ '../../platform/qt/qt.gypi',
+ ],
+
+ 'sources': [
+ '../default/asset_file_source.cpp',
+ '../default/default_file_source.cpp',
+ '../default/log_stderr.cpp',
+ '../default/mbgl/storage/offline.cpp',
+ '../default/mbgl/storage/offline_database.cpp',
+ '../default/mbgl/storage/offline_download.cpp',
+ '../default/online_file_source.cpp',
+ '../default/sqlite3.cpp',
+ '../default/string_stdlib.cpp',
+ '../default/thread.cpp',
+ 'include/qmapboxgl.hpp',
+ 'src/async_task.cpp',
+ 'src/async_task_impl.hpp',
+ 'src/http_file_source.cpp',
+ 'src/http_file_source.hpp',
+ 'src/http_request.cpp',
+ 'src/http_request.hpp',
+ 'src/image.cpp',
+ 'src/qmapboxgl.cpp',
+ 'src/qmapboxgl_p.hpp',
+ 'src/run_loop.cpp',
+ 'src/run_loop_impl.hpp',
+ 'src/timer.cpp',
+ 'src/timer_impl.hpp',
+ ],
+
+ 'variables': {
+ 'cflags': [
+ '<@(boost_cflags)',
+ '<@(nunicode_cflags)',
+ '<@(opengl_cflags)',
+ '<@(qt_cflags)',
+ '<@(rapidjson_cflags)',
+ '<@(sqlite_cflags)',
+ '<@(variant_cflags)',
+ '-Wno-error', # TODO: eliminate
+ '-fPIC',
+ ],
+ 'ldflags': [
+ '<@(nunicode_ldflags)',
+ '<@(opengl_ldflags)',
+ '<@(qt_ldflags)',
+ '<@(sqlite_ldflags)',
+ '<@(zlib_ldflags)',
+ ],
+ 'libraries': [
+ '<@(nunicode_static_libs)',
+ '<@(sqlite_static_libs)',
+ '<@(zlib_static_libs)',
+ ],
+ },
+
+ 'include_dirs': [
+ 'include',
+ '../default',
+ '../../include',
+ '../../src', # TODO: eliminate
+ ],
+
+ 'conditions': [
+ ['OS == "mac"', {
+ 'xcode_settings': {
+ 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags)' ],
+ }
+ }, {
+ 'cflags_cc': [ '<@(cflags)' ],
+ }]
+ ],
+
+ 'link_settings': {
+ 'conditions': [
+ ['OS == "mac"', {
+ 'libraries': [ '<@(libraries)' ],
+ 'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(ldflags)' ] }
+ }, {
+ 'libraries': [ '<@(libraries)', '<@(ldflags)' ],
+ }]
+ ],
+ },
+ },
+ {
+ 'target_name': 'qt-lib',
+ 'product_name': 'qmapboxgl',
+ 'type': 'shared_library',
+ 'product_extension': 'so.<(qtlibversion)',
+
+ 'includes': [
+ 'qt.gypi',
+ ],
+
+ 'dependencies': [
+ 'platform-lib',
+ ],
+
+ 'link_settings': {
+ 'conditions': [
+ ['OS == "mac"', {
+ 'libraries': [ '-framework OpenGL' ],
+ 'xcode_settings': { 'OTHER_LDFLAGS': [ '-all_load' ] }
+ }]
+ ],
+ },
+ },
+ {
+ 'target_name': 'test',
+ 'type': 'executable',
+
+ 'dependencies': [
+ 'test-lib',
+ 'platform-lib',
+ ],
+
+ 'sources': [
+ '../../test/src/main.cpp',
+ ],
+ },
+ ],
+}
diff --git a/platform/qt/qt.gypi b/platform/qt/qt.gypi
new file mode 100644
index 0000000000..4bec63cd89
--- /dev/null
+++ b/platform/qt/qt.gypi
@@ -0,0 +1,12 @@
+{
+ 'rules': [
+ {
+ 'rule_name': 'MOC files',
+ 'extension': 'hpp',
+ 'process_outputs_as_sources': 1,
+ 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/moc_<(RULE_INPUT_ROOT).cpp' ],
+ 'action': [ '<(qt_moc)', '<(RULE_INPUT_PATH)', '-o', '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/moc_<(RULE_INPUT_ROOT).cpp' ],
+ 'message': 'Generating MOC <(RULE_INPUT_ROOT).cpp',
+ },
+ ],
+}
diff --git a/platform/qt/scripts/configure.sh b/platform/qt/scripts/configure.sh
new file mode 100644
index 0000000000..5be71e27b8
--- /dev/null
+++ b/platform/qt/scripts/configure.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+BOOST_VERSION=1.59.0
+GEOJSONVT_VERSION=4.1.2
+GTEST_VERSION=1.7.0
+NUNICODE_VERSION=1.6
+PIXELMATCH_VERSION=0.9.0
+RAPIDJSON_VERSION=1.0.2
+SQLITE_VERSION=3.9.1
+VARIANT_VERSION=1.1.0
+ZLIB_VERSION=system
+
+if [ "$MASON_PLATFORM" == "osx" ]; then
+ function print_opengl_flags {
+ CONFIG+=" 'opengl_cflags%': [],"$LN
+ CONFIG+=" 'opengl_ldflags%': ['-framework OpenGL', '-framework CoreFoundation'],"$LN
+ }
+else
+ function print_opengl_flags {
+ CONFIG+=" 'opengl_cflags%': $(quote_flags $(pkg-config gl x11 --cflags)),"$LN
+ CONFIG+=" 'opengl_ldflags%': $(quote_flags $(pkg-config gl x11 --libs)),"$LN
+ }
+fi
+
+function print_qt_flags {
+ mason install Qt system
+
+ CONFIG+=" 'qt_cflags%': $(quote_flags $(mason cflags Qt system "QtCore QtGui QtOpenGL QtNetwork")),"$LN
+ CONFIG+=" 'qt_ldflags%': $(quote_flags $(mason ldflags Qt system "QtCore QtGui QtOpenGL QtNetwork")),"$LN
+
+ QT_VERSION_MAJOR=$(qmake -query QT_VERSION | cut -d. -f1)
+ if [ ${QT_VERSION_MAJOR} -gt 4 ] ; then
+ CONFIG+=" 'qt_moc%': '$(pkg-config Qt${QT_VERSION_MAJOR}Core --variable=host_bins)/moc',"$LN
+ else
+ CONFIG+=" 'qt_moc%': '$(pkg-config QtCore --variable=moc_location)',"$LN
+ fi
+}
diff --git a/scripts/main.mk b/scripts/main.mk
index 4c7f0d4794..af0743d2b2 100644
--- a/scripts/main.mk
+++ b/scripts/main.mk
@@ -34,6 +34,20 @@ export PLATFORM_OUTPUT = ./build/$(PLATFORM_SLUG)
export PLATFORM_CONFIG_INPUT = platform/$(MASON_PLATFORM)/scripts/configure.sh
export PLATFORM_CONFIG_OUTPUT = $(PLATFORM_OUTPUT)/config.gypi
+ifeq ($(PLATFORM),qt)
+ ifeq ($(shell uname -s), Darwin)
+ export MASON_PLATFORM = osx
+ export MASON_PLATFORM_VERSION = $(SUBPLATFORM)
+ export PLATFORM_SLUG = qt-osx-$(SUBPLATFORM)
+ export PLATFORM_CONFIG_INPUT = platform/qt/scripts/configure.sh
+ else ifeq ($(shell uname -s), Linux)
+ export MASON_PLATFORM = linux
+ export MASON_PLATFORM_VERSION = $(SUBPLATFORM)
+ export PLATFORM_SLUG = qt-linux-$(SUBPLATFORM)
+ export PLATFORM_CONFIG_INPUT = platform/qt/scripts/configure.sh
+ endif
+endif
+
ifneq (,$(findstring clang,$(CXX)))
CXX_HOST = "clang"
else ifneq (,$(findstring g++,$(CXX)))
@@ -124,6 +138,9 @@ tidy: Ninja/compdb
run-glfw-app:
cd $(PLATFORM_OUTPUT)/$(BUILDTYPE) && ./mapbox-glfw
+run-qt-app:
+ cd $(PLATFORM_OUTPUT)/$(BUILDTYPE) && ./qmapboxgl
+
run-valgrind-glfw-app:
cd $(PLATFORM_OUTPUT)/$(BUILDTYPE) && valgrind --leak-check=full --suppressions=../../../scripts/valgrind.sup ./mapbox-glfw