From d13a10f8ff0706368a13ffb1ecdf659a3c369518 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 27 Oct 2014 16:04:42 -0400 Subject: [PATCH 01/27] add mbgl-config template --- utils/mbgl-config/mbgl-config.template.sh | 128 ++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 utils/mbgl-config/mbgl-config.template.sh diff --git a/utils/mbgl-config/mbgl-config.template.sh b/utils/mbgl-config/mbgl-config.template.sh new file mode 100644 index 000000000..8ca8cde6b --- /dev/null +++ b/utils/mbgl-config/mbgl-config.template.sh @@ -0,0 +1,128 @@ + +## program below + +usage() +{ + cat <&2; } + +if test $# -eq 0; then + usage 1 +fi + +while test $# -gt 0; do + case "$1" in + esac + + case "$1" in + + --help) + usage 0 + ;; + + -h) + usage 0 + ;; + + -v) + echo ${CONFIG_MBGL_VERSION_STRING} + ;; + + --version) + echo ${CONFIG_MBGL_VERSION_STRING} + ;; + + --version-number) + echo ${CONFIG_MBGL_VERSION} + ;; + + --git-revision) + echo ${CONFIG_MBGL_GIT_REVISION} + ;; + + --git-describe) + echo ${CONFIG_MBGL_GIT_DESCRIBE} + ;; + + --defines) + echo ${CONFIG_MBGL_DEFINES} + ;; + + --prefix) + echo ${CONFIG_MBGL_PREFIX} + ;; + + --lib-name) + echo ${CONFIG_MBGL_LIBNAME} + ;; + + --libs) + echo -L${CONFIG_MBGL_LIBPATH} -l${CONFIG_MBGL_LIBNAME} + ;; + + --dep-libs) + echo ${CONFIG_MBGL_DEP_LIBS} + ;; + + --ldflags) + echo ${CONFIG_MBGL_LDFLAGS} + ;; + + --includes) + echo -I${CONFIG_MBGL_INCLUDES} + ;; + + --dep-includes) + echo ${CONFIG_MBGL_DEP_INCLUDES} + ;; + + --cxxflags) + echo ${CONFIG_MBGL_CXXFLAGS} + ;; + + --cflags) + echo -I${CONFIG_MBGL_INCLUDE} ${CONFIG_MBGL_DEP_INCLUDES} ${CONFIG_MBGL_DEFINES} ${CONFIG_MBGL_CXXFLAGS} + ;; + + --cxx) + echo ${CONFIG_MBGL_CXX} + ;; + + --all-flags) + echo -I${CONFIG_MBGL_INCLUDES} ${CONFIG_MBGL_DEP_INCLUDES} ${CONFIG_MBGL_DEFINES} ${CONFIG_MBGL_CXXFLAGS} -L${CONFIG_MBGL_LIBPATH} -l${CONFIG_MBGL_LIBNAME} ${CONFIG_MBGL_LDFLAGS} ${CONFIG_MBGL_DEP_LIBS} + ;; + + *) + # push to stderr any invalid options + echo "unknown option $1" 1>&2; + ;; + esac + shift +done + +exit 0 From 602b9da9928e10b55489d2a5c9599107b32dc90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 27 Oct 2014 16:47:47 -0400 Subject: [PATCH 02/27] add -fPIC for static libraries --- gyp/common.gypi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gyp/common.gypi b/gyp/common.gypi index 6d6b0e667..163f2ce0a 100644 --- a/gyp/common.gypi +++ b/gyp/common.gypi @@ -24,6 +24,19 @@ ], }], ], + 'target_conditions': [ + ['_type == "static_library"', { + 'conditions': [ + ['OS=="mac"', { + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ '-fPIC' ], + }, + }, { + 'cflags_cc': [ '-fPIC' ], + }] + ], + }], + ], 'cflags_cc': [ '-std=c++11', '-Werror', '-Wall', '-Wextra', '-Wshadow', '-frtti', '-fexceptions' ], 'configurations': { 'Debug': { From 124cc01bf101b242792ef94b338635b8520b6721 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 27 Oct 2014 19:26:17 -0400 Subject: [PATCH 03/27] add dummy mbgl-config generator script --- gyp/install.gypi | 24 ++++++++++++++++++++++++ utils/mbgl-config/dummy.sh | 3 +++ 2 files changed, 27 insertions(+) create mode 100755 utils/mbgl-config/dummy.sh diff --git a/gyp/install.gypi b/gyp/install.gypi index 8b79a4518..b3b20cef5 100644 --- a/gyp/install.gypi +++ b/gyp/install.gypi @@ -10,12 +10,36 @@ 'mbgl-headless', 'mbgl-<(platform)', ], + 'defines': [ + 'PLATFORM=<(platform)', + ], + 'export_dependent_settings': [ + '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' } ], + 'actions': [ + { 'action_name': 'mbgl-config', + 'inputs': [ + '../utils/mbgl-config/mbgl-config.template.sh', + '../utils/mbgl-config/dummy.sh', + ], + 'outputs': [ + '<(install_prefix)/bin/mbgl-config', + ], + 'action': [ + './utils/mbgl-config/dummy.sh', + 'PREFIX=<(install_prefix)', + 'PLATFORM=<(platform)', + ] + } + ] }, ] }], diff --git a/utils/mbgl-config/dummy.sh b/utils/mbgl-config/dummy.sh new file mode 100755 index 000000000..04685b2c1 --- /dev/null +++ b/utils/mbgl-config/dummy.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "mbgl-config DUMMY $PLATFORM $PREFIX"; From dbddd3c904d34eecdda4bb7d1d0dc30c4ea7e13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 28 Oct 2014 12:47:58 -0400 Subject: [PATCH 04/27] gyp fixes --- Makefile | 12 +++++ configure | 20 ++++++--- gyp/mbgl-headless.gypi | 4 +- gyp/mbgl-ios.gypi | 18 ++++---- gyp/mbgl-linux.gypi | 47 ++++++++++---------- gyp/mbgl-osx.gypi | 17 ++++--- gyp/mbgl.gypi | 64 ++++++++++++++------------- include/mbgl/util/stopwatch.hpp | 40 +++++++++++++++++ include/mbgl/util/timer.hpp | 40 ----------------- linux/mapboxgl-app.gyp | 21 ++++----- macosx/mapboxgl-app.gyp | 5 ++- src/renderer/painter.cpp | 4 +- src/shader/shader.cpp | 4 +- src/util/{timer.cpp => stopwatch.cpp} | 16 +++---- test/test.gyp | 7 ++- 15 files changed, 170 insertions(+), 149 deletions(-) create mode 100644 include/mbgl/util/stopwatch.hpp delete mode 100644 include/mbgl/util/timer.hpp rename src/util/{timer.cpp => stopwatch.cpp} (60%) diff --git a/Makefile b/Makefile index 2431f7be7..9a6faf985 100644 --- a/Makefile +++ b/Makefile @@ -22,10 +22,22 @@ mbgl: config.gypi mapboxgl.gyp 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 +mbgl-platform: config.gypi mapboxgl.gyp + 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-$(PLATFORM) + +mbgl-headless: config.gypi mapboxgl.gyp + 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-headless + 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 +config: config.gypi mapboxgl.gyp + 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-config + ##### Test cases ############################################################### build/test/Makefile: src common config.gypi test/test.gyp diff --git a/configure b/configure index ef289ac5d..43a665f29 100755 --- a/configure +++ b/configure @@ -69,7 +69,7 @@ PYTHON=`which python || abort 'Cannot find python'` >&2 echo -en "\033[0m"; function quote_flags { - ${PYTHON} -c "import sys, re; print re.split('(?@(_libraries)' ], }, }, { - 'cflags': [ - '<@(png_cflags)', - '<@(uv_cflags)', - '<@(sqlite3_cflags)', - '<@(zlib_cflags)', - '-I<(boost_root)/include', - ], + 'cflags_cc': [ '<@(cflags_cc)' ], + 'cflags': [ '<@(cflags)' ], }] ], 'direct_dependent_settings': { @@ -52,20 +64,10 @@ 'conditions': [ ['OS == "mac"', { 'xcode_settings': { - 'OTHER_LDFLAGS': [ - '<@(png_libraries)', - '<@(uv_libraries)', - '<@(sqlite3_libraries)', - '<@(zlib_libraries)', - ] + 'OTHER_LDFLAGS': [ '<@(ldflags)' ] } }, { - 'libraries': [ - '<@(png_libraries)', - '<@(uv_libraries)', - '<@(sqlite3_libraries)', - '<@(zlib_libraries)', - ] + 'ldflags': [ '<@(ldflags)' ] }] ] } diff --git a/include/mbgl/util/stopwatch.hpp b/include/mbgl/util/stopwatch.hpp new file mode 100644 index 000000000..663bbb6fc --- /dev/null +++ b/include/mbgl/util/stopwatch.hpp @@ -0,0 +1,40 @@ +#ifndef MBGL_UTIL_STOPWATCH +#define MBGL_UTIL_STOPWATCH + +#include + +#include + +namespace mbgl { +namespace util { + +#ifndef DISABLE_STOPWATCH +class stopwatch { +public: + stopwatch(Event event = Event::General); + stopwatch(EventSeverity severity, Event event = Event::General); + stopwatch(const std::string &name, Event event = Event::General); + stopwatch(const std::string &name, EventSeverity severity, Event event = Event::General); + void report(const std::string &name); + ~stopwatch(); + +private: + const std::string name; + EventSeverity severity = EventSeverity::Debug; + Event event = Event::General; + uint64_t start; +}; +#else +class stopwatch { + inline stopwatch(Event event = Event::General); + inline stopwatch(EventSeverity severity, Event event = Event::General); + inline stopwatch(const std::string &name, Event event = Event::General); + inline stopwatch(const std::string &name, EventSeverity severity, Event event = Event::General); + inline void report(const std::string &name) {} + inline ~stopwatch() {} +}; +#endif +} +} + +#endif diff --git a/include/mbgl/util/timer.hpp b/include/mbgl/util/timer.hpp deleted file mode 100644 index 8171c2f5d..000000000 --- a/include/mbgl/util/timer.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef MBGL_UTIL_TIMER -#define MBGL_UTIL_TIMER - -#include - -#include - -namespace mbgl { -namespace util { - -#ifndef DISABLE_TIMER -class timer { -public: - timer(Event event = Event::General); - timer(EventSeverity severity, Event event = Event::General); - timer(const std::string &name, Event event = Event::General); - timer(const std::string &name, EventSeverity severity, Event event = Event::General); - void report(const std::string &name); - ~timer(); - -private: - const std::string name; - EventSeverity severity = EventSeverity::Debug; - Event event = Event::General; - uint64_t start; -}; -#else -class timer { - inline timer(Event event = Event::General); - inline timer(EventSeverity severity, Event event = Event::General); - inline timer(const std::string &name, Event event = Event::General); - inline timer(const std::string &name, EventSeverity severity, Event event = Event::General); - inline void report(const std::string &name) {} - inline ~timer() {} -}; -#endif -} -} - -#endif diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index ee38b4b26..92175d1c0 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -13,7 +13,9 @@ '../platform/default/glfw_view.cpp', '../platform/default/log_stderr.cpp', ], - + 'libraries': [ + '<@(glfw3_static_libs)', + ], 'conditions': [ ['OS == "mac"', @@ -24,23 +26,22 @@ '<@(glfw3_cflags)', ], 'OTHER_LDFLAGS': [ - '<@(glfw3_libraries)', + '<@(glfw3_ldflags)', ], } }, # Non-Mac OS X { - 'cflags': [ + 'cflags_cc': [ '<@(glfw3_cflags)', + '-I<(boost_root)/include', + ], + 'ldflags': [ + '<@(glfw3_ldflags)', + '-L<(boost_root)/lib', + '-lboost_regex', ], - 'link_settings': { - 'libraries': [ - '<@(glfw3_libraries)', - '-L<(boost_root)/lib', - '-lboost_regex', - ], - }, }], ], 'dependencies': [ diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index fe8d9f7ae..b6881c1a5 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -27,7 +27,7 @@ '<@(glfw3_cflags)' ], 'OTHER_LDFLAGS': [ - '<@(glfw3_libraries)', + '<@(glfw3_ldflags)', '-framework SystemConfiguration', ], 'SDKROOT': 'macosx', @@ -35,6 +35,9 @@ 'MACOSX_DEPLOYMENT_TARGET':'10.9', 'CLANG_ENABLE_OBJC_ARC': 'YES' }, + 'libraries': [ + '<@(glfw3_static_libs)', + ], 'dependencies': [ '../mapboxgl.gyp:bundle_styles', '../mapboxgl.gyp:mbgl', diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 38c2176ae..228783b3c 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -11,7 +11,7 @@ #include #if defined(DEBUG) -#include +#include #endif #include @@ -35,7 +35,7 @@ bool Painter::needsAnimation() const { void Painter::setup() { #if defined(DEBUG) - util::timer timer("painter setup"); + util::stopwatch stopwatch("painter setup"); #endif setupShaders(); diff --git a/src/shader/shader.cpp b/src/shader/shader.cpp index d9f63cae1..84cb55eac 100644 --- a/src/shader/shader.cpp +++ b/src/shader/shader.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -12,7 +12,7 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo : name(name_), valid(false), program(0) { - util::timer timer("shader compilation", Event::Shader); + util::stopwatch stopwatch("shader compilation", Event::Shader); GLuint vertShader; if (!compileShader(&vertShader, GL_VERTEX_SHADER, vertSource)) { diff --git a/src/util/timer.cpp b/src/util/stopwatch.cpp similarity index 60% rename from src/util/timer.cpp rename to src/util/stopwatch.cpp index 5c4af51da..c9b8756e3 100644 --- a/src/util/timer.cpp +++ b/src/util/stopwatch.cpp @@ -1,5 +1,5 @@ -#ifndef DISABLE_TIMER -#include +#ifndef DISABLE_STOPWATCH +#include #include #include @@ -8,26 +8,26 @@ using namespace mbgl::util; -timer::timer(Event event_) +stopwatch::stopwatch(Event event_) : event(event_), start(now()) {} -timer::timer(EventSeverity severity_, Event event_) +stopwatch::stopwatch(EventSeverity severity_, Event event_) : severity(severity_), event(event_), start(now()) {} -timer::timer(const std::string &name_, Event event_) +stopwatch::stopwatch(const std::string &name_, Event event_) : name(name_), event(event_), start(now()) {} -timer::timer(const std::string &name_, EventSeverity severity_, Event event_) +stopwatch::stopwatch(const std::string &name_, EventSeverity severity_, Event event_) : name(name_), severity(severity_), event(event_), start(now()) {} -void timer::report(const std::string &name_) { +void stopwatch::report(const std::string &name_) { timestamp duration = now() - start; Log::Record(severity, event, name_ + ": " + std::to_string((double)(duration) / 1_millisecond) + "ms"); start += duration; } -timer::~timer() { +stopwatch::~stopwatch() { if (name.size()) { report(name); } diff --git a/test/test.gyp b/test/test.gyp index daf74b3e9..a01d1b32b 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -111,8 +111,6 @@ './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 @@ -120,17 +118,18 @@ { 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': ['<@(uv_cflags)'], - 'OTHER_LDFLAGS': ['<@(glfw3_libraries)'], + 'OTHER_LDFLAGS': ['<@(glfw3_ldflags)'], }, }, { 'cflags': ['<@(uv_cflags)'], - 'libraries': ['<@(glfw3_libraries)'], + 'libraries': ['<@(glfw3_ldflags)'], }], ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-headless', '<(platform_library)', ], }, From 652c616048745cf78df656536fefed18e595f6d9 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 28 Oct 2014 13:42:23 -0400 Subject: [PATCH 05/27] build simple, working mbgl-config script from gyp --- gyp/install.gypi | 17 ++--- utils/mbgl-config/build.sh | 17 +++++ utils/mbgl-config/dummy.sh | 3 - utils/mbgl-config/mbgl-config.template.sh | 87 +++-------------------- 4 files changed, 32 insertions(+), 92 deletions(-) create mode 100755 utils/mbgl-config/build.sh delete mode 100755 utils/mbgl-config/dummy.sh diff --git a/gyp/install.gypi b/gyp/install.gypi index b3b20cef5..0eadb94f5 100644 --- a/gyp/install.gypi +++ b/gyp/install.gypi @@ -10,14 +10,6 @@ 'mbgl-headless', 'mbgl-<(platform)', ], - 'defines': [ - 'PLATFORM=<(platform)', - ], - 'export_dependent_settings': [ - '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' }, @@ -28,15 +20,16 @@ { 'action_name': 'mbgl-config', 'inputs': [ '../utils/mbgl-config/mbgl-config.template.sh', - '../utils/mbgl-config/dummy.sh', + '../utils/mbgl-config/build.sh', ], 'outputs': [ '<(install_prefix)/bin/mbgl-config', ], 'action': [ - './utils/mbgl-config/dummy.sh', - 'PREFIX=<(install_prefix)', - 'PLATFORM=<(platform)', + './utils/mbgl-config/build.sh', + '<(install_prefix)', + '<(platform)', + 'mbgl', ] } ] diff --git a/utils/mbgl-config/build.sh b/utils/mbgl-config/build.sh new file mode 100755 index 000000000..4fd4a93cf --- /dev/null +++ b/utils/mbgl-config/build.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +PREFIX=$1 +PLATFORM=$2 + +VARIABLES="#!/bin/bash + +## variables + +CONFIG_MBGL_PREFIX=$PREFIX +CONFIG_MBGL_PLATFORM=$PLATFORM +" + +echo "$VARIABLES" | cat - utils/mbgl-config/mbgl-config.template.sh \ + > $PREFIX/bin/mbgl-config + +chmod 755 $PREFIX/bin/mbgl-config diff --git a/utils/mbgl-config/dummy.sh b/utils/mbgl-config/dummy.sh deleted file mode 100755 index 04685b2c1..000000000 --- a/utils/mbgl-config/dummy.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -echo "mbgl-config DUMMY $PLATFORM $PREFIX"; diff --git a/utils/mbgl-config/mbgl-config.template.sh b/utils/mbgl-config/mbgl-config.template.sh index 8ca8cde6b..87f4d50e1 100644 --- a/utils/mbgl-config/mbgl-config.template.sh +++ b/utils/mbgl-config/mbgl-config.template.sh @@ -1,29 +1,18 @@ - ## program below usage() { cat < Date: Tue, 28 Oct 2014 13:45:26 -0700 Subject: [PATCH 06/27] also add cflags --- gyp/mbgl-linux.gypi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gyp/mbgl-linux.gypi b/gyp/mbgl-linux.gypi index a09f3d963..ea0ce3ee9 100644 --- a/gyp/mbgl-linux.gypi +++ b/gyp/mbgl-linux.gypi @@ -9,6 +9,9 @@ '<@(uv_cflags)', '<@(curl_cflags)', ], + 'cflags': [ + '<@(uv_cflags)', + ], 'ldflags': [ '<@(uv_ldflags)', '<@(curl_ldflags)', @@ -31,9 +34,12 @@ ['OS == "mac"', { 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], + 'OTHER_CFLAGS': [ '<@(cflags)' ], } }, { 'ldflags': [ '<@(ldflags)' ], + 'cflags_cc': [ '<@(cflags_cc)' ], + 'cflags': [ '<@(cflags)' ], }] ], 'direct_dependent_settings': { From 1d82ae14a4d14a9ad42a4dabde63d3cba57ef02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 29 Oct 2014 11:32:54 -0400 Subject: [PATCH 07/27] pass on libraries in link_settings --- gyp/mbgl-ios.gypi | 8 +++++--- gyp/mbgl-linux.gypi | 10 ++++++---- gyp/mbgl-osx.gypi | 8 +++++--- gyp/mbgl.gypi | 16 ++++++++-------- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/gyp/mbgl-ios.gypi b/gyp/mbgl-ios.gypi index daa0052b1..3fce6c249 100644 --- a/gyp/mbgl-ios.gypi +++ b/gyp/mbgl-ios.gypi @@ -40,9 +40,11 @@ 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(uv_cflags)' ], }, - 'libraries': [ - '<@(uv_static_libs)', - ], + 'link_settings': { + 'libraries': [ + '<@(uv_static_libs)', + ], + }, 'direct_dependent_settings': { 'include_dirs': [ '../include', diff --git a/gyp/mbgl-linux.gypi b/gyp/mbgl-linux.gypi index ea0ce3ee9..b15cf0e25 100644 --- a/gyp/mbgl-linux.gypi +++ b/gyp/mbgl-linux.gypi @@ -26,10 +26,12 @@ 'include_dirs': [ '../include', ], - 'libraries': [ - '<@(uv_static_libs)', - '<@(curl_static_libs)', - ], + 'link_settings': { + 'libraries': [ + '<@(uv_static_libs)', + '<@(curl_static_libs)', + ], + }, 'conditions': [ ['OS == "mac"', { 'xcode_settings': { diff --git a/gyp/mbgl-osx.gypi b/gyp/mbgl-osx.gypi index e0a683f21..6c98265bb 100644 --- a/gyp/mbgl-osx.gypi +++ b/gyp/mbgl-osx.gypi @@ -16,9 +16,11 @@ 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(uv_cflags)' ], }, - 'libraries': [ - '<@(uv_static_libs)', - ], + 'link_settings': { + 'libraries': [ + '<@(uv_static_libs)', + ], + }, 'direct_dependent_settings': { 'include_dirs': [ '../include', diff --git a/gyp/mbgl.gypi b/gyp/mbgl.gypi index d69fcc95b..fd5c586c2 100644 --- a/gyp/mbgl.gypi +++ b/gyp/mbgl.gypi @@ -38,19 +38,19 @@ 'include_dirs': [ '../include', ], - 'libraries': [ - '<@(png_static_libs)', - '<@(uv_static_libs)', - '<@(sqlite3_static_libs)', - '<@(zlib_static_libs)', - ], + 'link_settings': { + 'libraries': [ + '<@(png_static_libs)', + '<@(uv_static_libs)', + '<@(sqlite3_static_libs)', + '<@(zlib_static_libs)', + ], + }, 'conditions': [ ['OS == "mac"', { 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], 'OTHER_CFLAGS': [ '<@(cflags)' ], - # Makefile builds don't respect 'libraries' on OS X. - 'OTHER_LDFLAGS': [ '>@(_libraries)' ], }, }, { 'cflags_cc': [ '<@(cflags_cc)' ], From 293b291b80f6fc42b6551bbb50e702815ac7a4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 29 Oct 2014 11:59:24 -0400 Subject: [PATCH 08/27] rename mbgl to mbgl-core --- Makefile | 12 ++++-------- gyp/install.gypi | 4 ++-- gyp/{mbgl.gypi => mbgl-core.gypi} | 5 +++-- linux/mapboxgl-app.gyp | 2 +- macosx/mapboxgl-app.gyp | 2 +- mapboxgl.gyp | 2 +- test/test.gyp | 18 +++++++++--------- 7 files changed, 21 insertions(+), 24 deletions(-) rename gyp/{mbgl.gypi => mbgl-core.gypi} (94%) diff --git a/Makefile b/Makefile index 9a6faf985..02fc34dd5 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ endif PLATFORM ?= linux -all: mbgl +all: mbgl-core mblg-platform mbgl-headless config.gypi: configure ./configure @@ -18,9 +18,9 @@ config-ios.gypi: configure MASON_PLATFORM=ios ./configure config-ios.gypi # Builds the regular library -mbgl: config.gypi mapboxgl.gyp +mbgl-core: config.gypi mapboxgl.gyp 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 + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-core mbgl-platform: config.gypi mapboxgl.gyp deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make @@ -34,10 +34,6 @@ 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 -config: config.gypi mapboxgl.gyp - 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-config - ##### Test cases ############################################################### build/test/Makefile: src common config.gypi test/test.gyp @@ -121,5 +117,5 @@ clean: clear_xcode_cache distclean: clean -rm -rf ./mason_packages -.PHONY: mbgl install test linux clear_xcode_cache build/test/Makefile clean distclean +.PHONY: mbgl-core install test linux clear_xcode_cache build/test/Makefile clean distclean # DO NOT DELETE diff --git a/gyp/install.gypi b/gyp/install.gypi index 8b79a4518..58b8bd072 100644 --- a/gyp/install.gypi +++ b/gyp/install.gypi @@ -6,12 +6,12 @@ 'type': 'none', 'hard_dependency': 1, 'dependencies': [ - 'mbgl', + 'mbgl-core', 'mbgl-headless', 'mbgl-<(platform)', ], 'copies': [ - { 'files': [ '<(PRODUCT_DIR)/libmbgl.a' ], 'destination': '<(install_prefix)/lib' }, + { 'files': [ '<(PRODUCT_DIR)/libmbgl-core.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.gypi b/gyp/mbgl-core.gypi similarity index 94% rename from gyp/mbgl.gypi rename to gyp/mbgl-core.gypi index fd5c586c2..a9c10f111 100644 --- a/gyp/mbgl.gypi +++ b/gyp/mbgl-core.gypi @@ -1,8 +1,9 @@ { 'targets': [ - { 'target_name': 'mbgl', - 'product_name': 'mbgl', + { 'target_name': 'mbgl-core', + 'product_name': 'mbgl-core', 'type': 'static_library', + 'standalone_static_library': 1, 'hard_dependency': 1, 'dependencies': [ 'shaders', diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index 92175d1c0..77e4a5ab0 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -45,7 +45,7 @@ }], ], 'dependencies': [ - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', '../mapboxgl.gyp:mbgl-linux', '../mapboxgl.gyp:copy_styles', '../mapboxgl.gyp:copy_certificate_bundle', diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index b6881c1a5..95b7e1d31 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -40,7 +40,7 @@ ], 'dependencies': [ '../mapboxgl.gyp:bundle_styles', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', '../mapboxgl.gyp:mbgl-osx', ] } diff --git a/mapboxgl.gyp b/mapboxgl.gyp index 9126a1a62..cca803b33 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -6,7 +6,7 @@ './gyp/styles.gypi', './gyp/fixtures.gypi', './gyp/certificates.gypi', - './gyp/mbgl.gypi', + './gyp/mbgl-core.gypi', './gyp/mbgl-platform.gypi', './gyp/mbgl-headless.gypi', './gyp/install.gypi', diff --git a/test/test.gyp b/test/test.gyp index a01d1b32b..43e166938 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -13,7 +13,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', ] }, { 'target_name': 'clip_ids', @@ -25,7 +25,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', ] }, { 'target_name': 'enums', @@ -37,7 +37,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', ] }, { 'target_name': 'style_parser', @@ -51,7 +51,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', '../mapboxgl.gyp:copy_fixtures', ] }, @@ -64,7 +64,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', ] }, { 'target_name': 'comparisons', @@ -76,7 +76,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', ] }, { 'target_name': 'tile', @@ -88,7 +88,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', ] }, { 'target_name': 'functions', @@ -100,7 +100,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', ] }, { 'target_name': 'headless', @@ -128,7 +128,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-core', '../mapboxgl.gyp:mbgl-headless', '<(platform_library)', ], From 4cf24fe9592cfd5c6d44ffc03f0dc836401f9d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 29 Oct 2014 12:00:01 -0400 Subject: [PATCH 09/27] mark static libs as standalone --- gyp/mbgl-headless.gypi | 1 + gyp/mbgl-ios.gypi | 1 + gyp/mbgl-linux.gypi | 1 + gyp/mbgl-osx.gypi | 1 + 4 files changed, 4 insertions(+) diff --git a/gyp/mbgl-headless.gypi b/gyp/mbgl-headless.gypi index 644f16486..08ac21181 100644 --- a/gyp/mbgl-headless.gypi +++ b/gyp/mbgl-headless.gypi @@ -3,6 +3,7 @@ { 'target_name': 'mbgl-headless', 'product_name': 'mbgl-headless', 'type': 'static_library', + 'standalone_static_library': 1, 'include_dirs': [ '../include', ], diff --git a/gyp/mbgl-ios.gypi b/gyp/mbgl-ios.gypi index 3fce6c249..1baf06c1f 100644 --- a/gyp/mbgl-ios.gypi +++ b/gyp/mbgl-ios.gypi @@ -27,6 +27,7 @@ { 'target_name': 'mbgl-ios', 'product_name': 'mbgl-ios', 'type': 'static_library', + 'standalone_static_library': 1, 'hard_dependency': 1, 'sources': [ '../platform/ios/cache_database_library.mm', diff --git a/gyp/mbgl-linux.gypi b/gyp/mbgl-linux.gypi index b15cf0e25..f1ff1e3c9 100644 --- a/gyp/mbgl-linux.gypi +++ b/gyp/mbgl-linux.gypi @@ -3,6 +3,7 @@ { 'target_name': 'mbgl-linux', 'product_name': 'mbgl-linux', 'type': 'static_library', + 'standalone_static_library': 1, 'hard_dependency': 1, 'variables': { 'cflags_cc': [ diff --git a/gyp/mbgl-osx.gypi b/gyp/mbgl-osx.gypi index 6c98265bb..38aea690f 100644 --- a/gyp/mbgl-osx.gypi +++ b/gyp/mbgl-osx.gypi @@ -3,6 +3,7 @@ { 'target_name': 'mbgl-osx', 'product_name': 'mbgl-osx', 'type': 'static_library', + 'standalone_static_library': 1, 'hard_dependency': 1, 'sources': [ '../platform/osx/cache_database_application_support.mm', From 7dc7387073d630b99ee3522de2bee09f0ace8d71 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 12:19:11 -0400 Subject: [PATCH 10/27] fix typo in target name --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 02fc34dd5..ed75627f4 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ endif PLATFORM ?= linux -all: mbgl-core mblg-platform mbgl-headless +all: mbgl-core mbgl-platform mbgl-headless config.gypi: configure ./configure From 92474b5f516227ad1b5b0256674b4a99c23568df Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 14:54:13 -0400 Subject: [PATCH 11/27] create and install libmbgl.a with bundled libuv --- gyp/mbgl-core.gypi | 25 +++++++++++++++ gyp/merge_static_libs.py | 66 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100755 gyp/merge_static_libs.py diff --git a/gyp/mbgl-core.gypi b/gyp/mbgl-core.gypi index a9c10f111..d6a9dd8fb 100644 --- a/gyp/mbgl-core.gypi +++ b/gyp/mbgl-core.gypi @@ -72,6 +72,31 @@ }] ] } + }, + { + 'target_name': 'mbgl-standalone', + 'type': 'none', + 'variables': { + 'core_lib':'<(PRODUCT_DIR)/libmbgl-core.a', + 'standalone_lib':'<(PRODUCT_DIR)/libmbgl.a' + }, + 'actions': [ + { + 'action_name': 'build standalone core lib', + 'inputs': [ + '<(core_lib)' + ], + 'outputs': [ + '<(standalone_lib)' + ], + 'action': [ + './gyp/merge_static_libs.py', + '<(standalone_lib)', + '<@(uv_static_libs)', + '<(core_lib)' + ], + } + ] } ] } diff --git a/gyp/merge_static_libs.py b/gyp/merge_static_libs.py new file mode 100755 index 000000000..842be18c8 --- /dev/null +++ b/gyp/merge_static_libs.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import shutil +import subprocess +import sys +import tempfile + +def _Usage(): + print 'Usage: merge_static_libs OUTPUT_LIB INPUT_LIB [INPUT_LIB]*' + sys.exit(1) + +def MergeLibs(in_libs, out_lib): + """ Merges multiple static libraries into one. + + in_libs: list of paths to static libraries to be merged + out_lib: path to the static library which will be created from in_libs + """ + if os.name == 'posix': + tempdir = tempfile.mkdtemp() + abs_in_libs = [] + for in_lib in in_libs: + abs_in_libs.append(os.path.abspath(in_lib)) + curdir = os.getcwd() + os.chdir(tempdir) + objects = [] + ar = os.environ.get('AR', 'ar') + for in_lib in abs_in_libs: + proc = subprocess.Popen([ar, '-t', in_lib], stdout=subprocess.PIPE) + proc.wait() + obj_str = proc.communicate()[0] + current_objects = obj_str.rstrip().split('\n') + proc = subprocess.Popen([ar, '-x', in_lib], stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + proc.wait() + if proc.poll() == 0: + # The static library is non-thin, and we extracted objects + for object in current_objects: + objects.append(os.path.abspath(object)) + elif 'thin archive' in proc.communicate()[0]: + # The static library is thin, so it contains the paths to its objects + for object in current_objects: + objects.append(object) + else: + raise Exception('Failed to extract objects from %s.' % in_lib) + os.chdir(curdir) + if not subprocess.call([ar, '-crs', out_lib] + objects) == 0: + raise Exception('Failed to add object files to %s' % out_lib) + shutil.rmtree(tempdir) + elif os.name == 'nt': + subprocess.call(['lib', '/OUT:%s' % out_lib] + in_libs) + else: + raise Exception('Error: Your platform is not supported') + +def Main(): + if len(sys.argv) < 3: + _Usage() + out_lib = sys.argv[1] + in_libs = sys.argv[2:] + MergeLibs(in_libs, out_lib) + +if '__main__' == __name__: + sys.exit(Main()) From 139606019671c88dc86eea6b6ad4766b0006922a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 15:01:51 -0400 Subject: [PATCH 12/27] install libmbgl.a --- gyp/install.gypi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gyp/install.gypi b/gyp/install.gypi index 58b8bd072..6805c135c 100644 --- a/gyp/install.gypi +++ b/gyp/install.gypi @@ -7,10 +7,12 @@ 'hard_dependency': 1, 'dependencies': [ 'mbgl-core', + 'mbgl-standalone', 'mbgl-headless', 'mbgl-<(platform)', ], 'copies': [ + { 'files': [ '<(PRODUCT_DIR)/libmbgl.a' ], 'destination': '<(install_prefix)/lib' }, { 'files': [ '<(PRODUCT_DIR)/libmbgl-core.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' }, From 078f7afa6e2f262b31c7bf529aaf55249be65b8f Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 29 Oct 2014 15:15:36 -0400 Subject: [PATCH 13/27] --includedir --- gyp/install.gypi | 1 - utils/mbgl-config/mbgl-config.template.sh | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gyp/install.gypi b/gyp/install.gypi index 0eadb94f5..f3ff2002b 100644 --- a/gyp/install.gypi +++ b/gyp/install.gypi @@ -29,7 +29,6 @@ './utils/mbgl-config/build.sh', '<(install_prefix)', '<(platform)', - 'mbgl', ] } ] diff --git a/utils/mbgl-config/mbgl-config.template.sh b/utils/mbgl-config/mbgl-config.template.sh index 87f4d50e1..2b1b1a122 100644 --- a/utils/mbgl-config/mbgl-config.template.sh +++ b/utils/mbgl-config/mbgl-config.template.sh @@ -12,7 +12,7 @@ Help Options: Application Options: --prefix output prefix where mbgl is installed --libs output -L flags - --includes output -I flags + --includedir output include directory path EOF exit $1 @@ -46,8 +46,8 @@ while test $# -gt 0; do echo -L${CONFIG_MBGL_PREFIX}/lib -lmbgl -lmbgl-${CONFIG_MBGL_PLATFORM} -lmbgl-headless ;; - --includes) - echo -I${CONFIG_MBGL_PREFIX}/include/mbgl + --includedir) + echo ${CONFIG_MBGL_PREFIX}/include ;; *) From c11dc0fa333bb20b2c3706c4d2ff739f6c25cd36 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 15:27:41 -0400 Subject: [PATCH 14/27] attempt to build against standalone libmgl.a --- gyp/mbgl-core.gypi | 36 +++++++----------------------------- gyp/mbgl-linux.gypi | 6 ------ linux/mapboxgl-app.gyp | 31 +++++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/gyp/mbgl-core.gypi b/gyp/mbgl-core.gypi index d6a9dd8fb..c4b671283 100644 --- a/gyp/mbgl-core.gypi +++ b/gyp/mbgl-core.gypi @@ -19,12 +19,6 @@ 'cflags': [ '<@(uv_cflags)', ], - 'ldflags': [ - '<@(png_ldflags)', - '<@(uv_ldflags)', - '<@(sqlite3_ldflags)', - '<@(zlib_ldflags)', - ], }, 'sources': [ ' Date: Wed, 29 Oct 2014 15:31:57 -0400 Subject: [PATCH 15/27] linux app depends on mbgl-linux --- linux/mapboxgl-app.gyp | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index 098b2bee9..de7aa5b96 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -62,6 +62,7 @@ ], 'dependencies': [ '../mapboxgl.gyp:mbgl-standalone', + '../mapboxgl.gyp:mbgl-linux', '../mapboxgl.gyp:copy_styles', '../mapboxgl.gyp:copy_certificate_bundle', ], From 36cd65e1ab232c3a876d7c10a366143a9546e2e7 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 16:17:52 -0400 Subject: [PATCH 16/27] patch gyp to allow common 'libraries' config for both osx and linux --- deps/gyp/pylib/gyp/generator/make.py | 2 +- linux/mapboxgl-app.gyp | 64 +++++++++------------------- 2 files changed, 20 insertions(+), 46 deletions(-) diff --git a/deps/gyp/pylib/gyp/generator/make.py b/deps/gyp/pylib/gyp/generator/make.py index b6f766d55..0b515bccd 100644 --- a/deps/gyp/pylib/gyp/generator/make.py +++ b/deps/gyp/pylib/gyp/generator/make.py @@ -141,7 +141,7 @@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) # special "figure out circular dependencies" flags around the entire # input list during linking. quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) +cmd_link = $(LINK.$(TOOLSET)) -Wl,--start-group $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) -Wl,--end-group # We support two kinds of shared objects (.so): # 1) shared_library, which is just bundling together many dependent libraries diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index de7aa5b96..c2953ce53 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -13,52 +13,26 @@ '../platform/default/glfw_view.cpp', '../platform/default/log_stderr.cpp', ], - 'libraries': [ - '<@(glfw3_static_libs)', + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS':[ + '<@(glfw3_cflags)', + ], + }, + 'cflags_cc': [ + '<@(glfw3_cflags)', + '-I<(boost_root)/include', ], - 'conditions': [ - ['OS == "mac"', - - # Mac OS X - { - 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS':[ - '<@(glfw3_cflags)', - ], - }, - 'libraries': [ - '-L<(PRODUCT_DIR)/', - '-lmbgl', - '-lmbgl-linux', - '<@(png_ldflags)', - '<@(sqlite3_ldflags)', - '<@(glfw3_ldflags)', - '<@(curl_ldflags)', - '<@(zlib_ldflags)', - ] - }, - # Non-Mac OS X - { - 'cflags_cc': [ - '<@(glfw3_cflags)', - '-I<(boost_root)/include', - ], - 'libraries': [ - '-Wl,--start-group', - '-L<(PRODUCT_DIR)/', - '-lmbgl', - '-lmbgl-linux', - '<@(curl_static_libs)', - '<@(png_ldflags)', - '<@(sqlite3_ldflags)', - '<@(glfw3_ldflags)', - '-L<(boost_root)/lib', - '-lboost_regex', - '<@(curl_ldflags)', - '<@(zlib_ldflags)', - '-Wl,--end-group' - ], - }], + 'libraries': [ + '-L<(PRODUCT_DIR)/', + '-lmbgl', + '-lmbgl-linux', + '<@(curl_static_libs)', + '<@(png_ldflags)', + '<@(sqlite3_ldflags)', + '<@(glfw3_static_libs)', + '<@(glfw3_ldflags)', + '<@(curl_ldflags)', + '<@(zlib_ldflags)', ], 'dependencies': [ '../mapboxgl.gyp:mbgl-standalone', From 0f56f860f7ff3e0d0642cc1c0a18915ce74bbbaa Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 16:21:25 -0400 Subject: [PATCH 17/27] still link boost on linux --- linux/mapboxgl-app.gyp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index c2953ce53..724463ab5 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -34,6 +34,11 @@ '<@(curl_ldflags)', '<@(zlib_ldflags)', ], + 'conditions': [ + ['OS == "linux"', { + 'libraries':[ '-L<(boost_root)/lib','-lboost_regex' ] + }] + ], 'dependencies': [ '../mapboxgl.gyp:mbgl-standalone', '../mapboxgl.gyp:mbgl-linux', From 1069e3b4e9e40916c68d666b75c26bb9400546e6 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 16:29:48 -0400 Subject: [PATCH 18/27] fix tests --- test/test.gyp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/test/test.gyp b/test/test.gyp index 43e166938..19fa19070 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -3,6 +3,16 @@ '../gyp/common.gypi', '../gyp/mbgl-platform.gypi', ], + 'target_defaults': { + "libraries": [ + '-L<(PRODUCT_DIR)/', + '-lmbgl' + '<@(curl_static_libs)', + '<@(png_ldflags)', + '<@(sqlite3_ldflags)', + '<@(zlib_ldflags)' + ] + }, 'targets': [ { 'target_name': 'rotation_range', 'product_name': 'test_rotation_range', @@ -13,7 +23,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'clip_ids', @@ -25,7 +35,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'enums', @@ -37,7 +47,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'style_parser', @@ -51,7 +61,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', '../mapboxgl.gyp:copy_fixtures', ] }, @@ -64,7 +74,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'comparisons', @@ -76,7 +86,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'tile', @@ -88,7 +98,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'functions', @@ -100,7 +110,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'headless', @@ -128,7 +138,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', '../mapboxgl.gyp:mbgl-headless', '<(platform_library)', ], From cefa3462f85c627ea5c99e8c3caae06d380537c1 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 16:34:53 -0400 Subject: [PATCH 19/27] linux test build fixes --- test/test.gyp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test.gyp b/test/test.gyp index 19fa19070..9b1e36909 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -6,12 +6,18 @@ 'target_defaults': { "libraries": [ '-L<(PRODUCT_DIR)/', - '-lmbgl' + '-lmbgl', + '<@(uv_ldflags)', '<@(curl_static_libs)', '<@(png_ldflags)', '<@(sqlite3_ldflags)', '<@(zlib_ldflags)' - ] + ], + 'conditions': [ + ['OS == "linux"', { + 'libraries':[ '-L<(boost_root)/lib','-lboost_regex' ] + }] + ], }, 'targets': [ { 'target_name': 'rotation_range', From a8b5f56049ab949f88bbc47c23405093a8753f7a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 16:45:31 -0400 Subject: [PATCH 20/27] fix macosx app linking --- macosx/mapboxgl-app.gyp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index 95b7e1d31..4e19e86a2 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -38,9 +38,19 @@ 'libraries': [ '<@(glfw3_static_libs)', ], + 'libraries': [ + '-L<(PRODUCT_DIR)/', + '-lmbgl', + '<@(png_ldflags)', + '<@(sqlite3_ldflags)', + '<@(glfw3_static_libs)', + '<@(glfw3_ldflags)', + '<@(curl_ldflags)', + '<@(zlib_ldflags)', + ], 'dependencies': [ '../mapboxgl.gyp:bundle_styles', - '../mapboxgl.gyp:mbgl-core', + '../mapboxgl.gyp:mbgl-standalone', '../mapboxgl.gyp:mbgl-osx', ] } From 4cfb4b130fce9912d636ba832544bf73b38b7484 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 17:22:36 -0400 Subject: [PATCH 21/27] fix xproj target --- gyp/mbgl-core.gypi | 4 ++++ macosx/mapboxgl-app.gyp | 31 +++++++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/gyp/mbgl-core.gypi b/gyp/mbgl-core.gypi index c4b671283..e6b90a6b2 100644 --- a/gyp/mbgl-core.gypi +++ b/gyp/mbgl-core.gypi @@ -48,6 +48,10 @@ { 'target_name': 'mbgl-standalone', 'type': 'none', + 'hard_dependency': 1, + 'dependencies': [ + 'mbgl-core' + ], 'variables': { 'core_lib':'<(PRODUCT_DIR)/libmbgl-core.a', 'standalone_lib':'<(PRODUCT_DIR)/libmbgl.a' diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index 4e19e86a2..e5789fffd 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -35,18 +35,25 @@ 'MACOSX_DEPLOYMENT_TARGET':'10.9', 'CLANG_ENABLE_OBJC_ARC': 'YES' }, - 'libraries': [ - '<@(glfw3_static_libs)', - ], - 'libraries': [ - '-L<(PRODUCT_DIR)/', - '-lmbgl', - '<@(png_ldflags)', - '<@(sqlite3_ldflags)', - '<@(glfw3_static_libs)', - '<@(glfw3_ldflags)', - '<@(curl_ldflags)', - '<@(zlib_ldflags)', + 'variables' : { + 'ldflags': [ + '-L<(PRODUCT_DIR)/', + '-lmbgl', + '<@(sqlite3_ldflags)', + '<@(glfw3_static_libs)', + '<@(glfw3_ldflags)', + '<@(curl_ldflags)', + '<@(png_ldflags)' + ] + }, + 'conditions': [ + ['OS == "mac"', { + 'xcode_settings': { + 'OTHER_LDFLAGS': [ '<@(ldflags)' ], + } + }, { + 'ldflags': [ '<@(ldflags)' ], + }] ], 'dependencies': [ '../mapboxgl.gyp:bundle_styles', From d8a93dbb9542ca6f05372221ee69c086b7750a4c Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 18:13:25 -0400 Subject: [PATCH 22/27] use stable cross-generator direction for referencing standalone lib + other minor fixups --- Makefile | 1 + gyp/common.gypi | 1 + gyp/install.gypi | 2 +- gyp/mbgl-core.gypi | 11 ++++++++++- gyp/mbgl-ios.gypi | 10 +--------- gyp/mbgl-osx.gypi | 10 +--------- linux/mapboxgl-app.gyp | 3 --- macosx/mapboxgl-app.gyp | 2 -- test/test.gyp | 2 -- 9 files changed, 15 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index ed75627f4..c4d42bfd4 100644 --- a/Makefile +++ b/Makefile @@ -112,6 +112,7 @@ lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache clean: clear_xcode_cache -find ./deps/gyp -name "*.pyc" -exec rm {} \; -rm -rf ./build/ + -rm -rf ./macosx/build/ -rm -rf ./config.gypi ./config-ios.gypi distclean: clean diff --git a/gyp/common.gypi b/gyp/common.gypi index 163f2ce0a..c25bb7777 100644 --- a/gyp/common.gypi +++ b/gyp/common.gypi @@ -1,6 +1,7 @@ { 'variables': { 'install_prefix%': '', + 'standalone_product_dir':' Date: Wed, 29 Oct 2014 19:09:13 -0400 Subject: [PATCH 23/27] fix linux app linking to curl symbols --- linux/mapboxgl-app.gyp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index 027612cbd..b8062829a 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -23,6 +23,8 @@ '-I<(boost_root)/include', ], 'libraries': [ + '-L<(PRODUCT_DIR)/', + '-lmbgl-linux' # hack: double-linking to workaround lack of start/end group support for /path/to/libmbgl-linux with g++-4.8 '<@(curl_static_libs)', '<@(png_ldflags)', '<@(sqlite3_ldflags)', From b32748b42f6c9ec8d336f4571f6278a2eeeebae0 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 19:37:42 -0400 Subject: [PATCH 24/27] better fix for handling mbgl-linux symbols --- deps/gyp/pylib/gyp/generator/make.py | 2 +- linux/mapboxgl-app.gyp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/deps/gyp/pylib/gyp/generator/make.py b/deps/gyp/pylib/gyp/generator/make.py index 0b515bccd..7a8adb585 100644 --- a/deps/gyp/pylib/gyp/generator/make.py +++ b/deps/gyp/pylib/gyp/generator/make.py @@ -141,7 +141,7 @@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) # special "figure out circular dependencies" flags around the entire # input list during linking. quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) -Wl,--start-group $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) -Wl,--end-group +cmd_link = $(LINK.$(TOOLSET)) -Wl,--start-group $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) -Wl,--end-group $(LIBS) # We support two kinds of shared objects (.so): # 1) shared_library, which is just bundling together many dependent libraries diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index b8062829a..027612cbd 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -23,8 +23,6 @@ '-I<(boost_root)/include', ], 'libraries': [ - '-L<(PRODUCT_DIR)/', - '-lmbgl-linux' # hack: double-linking to workaround lack of start/end group support for /path/to/libmbgl-linux with g++-4.8 '<@(curl_static_libs)', '<@(png_ldflags)', '<@(sqlite3_ldflags)', From 77b21569ec806d154592863bf169eb7d1fa8027d Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 19:40:40 -0400 Subject: [PATCH 25/27] curl static libs fixes for osx --- configure | 2 ++ linux/mapboxgl-app.gyp | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 43a665f29..afb94d479 100755 --- a/configure +++ b/configure @@ -99,6 +99,8 @@ if [ ! -z ${LIBCURL_VERSION} ]; then CONFIG+=" 'curl_static_libs': $(quote_flags $(mason static_libs libcurl ${LIBCURL_VERSION})),"$LN CONFIG+=" 'curl_cflags': $(quote_flags $(mason cflags libcurl ${LIBCURL_VERSION})),"$LN CONFIG+=" 'curl_ldflags': $(quote_flags $(mason ldflags libcurl ${LIBCURL_VERSION})),"$LN +else + CONFIG+=" 'curl_static_libs': [],"$LN fi if [ ! -z ${GLFW_VERSION} ]; then diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index 027612cbd..75ad23552 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -23,7 +23,6 @@ '-I<(boost_root)/include', ], 'libraries': [ - '<@(curl_static_libs)', '<@(png_ldflags)', '<@(sqlite3_ldflags)', '<@(glfw3_static_libs)', From 9dbcf18d14c0054b9d090d8921c6caa01979382c Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 21:38:25 -0400 Subject: [PATCH 26/27] update to standalone mapbox-gl-cocoa branch --- ios/mapbox-gl-cocoa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index bba56f27f..80fd792b9 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit bba56f27fa747409ac9ea20cf77f470f59a415a7 +Subproject commit 80fd792b9922868ad27510657f8eb0aad7d4d2ea From 22f67bb8ab6960e1263f0c85ba540ff96123540b Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 29 Oct 2014 22:16:44 -0400 Subject: [PATCH 27/27] start passing ldflags --- gyp/install.gypi | 1 + gyp/mbgl.gypi | 75 ----------------------- utils/mbgl-config/build.sh | 3 + utils/mbgl-config/mbgl-config.template.sh | 2 +- 4 files changed, 5 insertions(+), 76 deletions(-) delete mode 100644 gyp/mbgl.gypi diff --git a/gyp/install.gypi b/gyp/install.gypi index e7217219c..c25490c45 100644 --- a/gyp/install.gypi +++ b/gyp/install.gypi @@ -31,6 +31,7 @@ './utils/mbgl-config/build.sh', '<(install_prefix)', '<(platform)', + '<@(png_ldflags)' ] } ] diff --git a/gyp/mbgl.gypi b/gyp/mbgl.gypi deleted file mode 100644 index 0d914f46f..000000000 --- a/gyp/mbgl.gypi +++ /dev/null @@ -1,75 +0,0 @@ -{ - 'targets': [ - { 'target_name': 'mbgl', - 'product_name': 'mbgl', - 'type': 'static_library', - 'standalone_static_library': 1, - 'hard_dependency': 1, - 'dependencies': [ - 'shaders', - ], - 'sources': [ - '