diff --git a/Makefile b/Makefile index 2431f7be7..c4d42bfd4 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ endif PLATFORM ?= linux -all: mbgl +all: mbgl-core mbgl-platform mbgl-headless config.gypi: configure ./configure @@ -18,9 +18,17 @@ 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 + $(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 @@ -104,10 +112,11 @@ 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 -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/configure b/configure index ef289ac5d..afb94d479 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('(? + +#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/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 diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index ee38b4b26..75ad23552 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -13,38 +13,30 @@ '../platform/default/glfw_view.cpp', '../platform/default/log_stderr.cpp', ], - + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS':[ + '<@(glfw3_cflags)', + ], + }, + 'cflags_cc': [ + '<@(glfw3_cflags)', + '-I<(boost_root)/include', + ], + 'libraries': [ + '<@(png_ldflags)', + '<@(sqlite3_ldflags)', + '<@(glfw3_static_libs)', + '<@(glfw3_ldflags)', + '<@(curl_ldflags)', + '<@(zlib_ldflags)', + ], 'conditions': [ - ['OS == "mac"', - - # Mac OS X - { - 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS':[ - '<@(glfw3_cflags)', - ], - 'OTHER_LDFLAGS': [ - '<@(glfw3_libraries)', - ], - } - }, - - # Non-Mac OS X - { - 'cflags': [ - '<@(glfw3_cflags)', - ], - 'link_settings': { - 'libraries': [ - '<@(glfw3_libraries)', - '-L<(boost_root)/lib', - '-lboost_regex', - ], - }, - }], + ['OS == "linux"', { + 'libraries':[ '-L<(boost_root)/lib','-lboost_regex' ] + }] ], 'dependencies': [ - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', '../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 fe8d9f7ae..0e6fe3804 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,9 +35,27 @@ 'MACOSX_DEPLOYMENT_TARGET':'10.9', 'CLANG_ENABLE_OBJC_ARC': 'YES' }, + 'variables' : { + 'ldflags': [ + '<@(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', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', '../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/src/renderer/painter.cpp b/src/renderer/painter.cpp index 07428a698..960168bd4 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -13,7 +13,7 @@ #include #if defined(DEBUG) -#include +#include #endif #include @@ -40,7 +40,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..66bc97d8e 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -3,6 +3,20 @@ '../gyp/common.gypi', '../gyp/mbgl-platform.gypi', ], + 'target_defaults': { + "libraries": [ + '<@(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', 'product_name': 'test_rotation_range', @@ -13,7 +27,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'clip_ids', @@ -25,7 +39,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'enums', @@ -37,7 +51,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'style_parser', @@ -51,7 +65,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', '../mapboxgl.gyp:copy_fixtures', ] }, @@ -64,7 +78,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'comparisons', @@ -76,7 +90,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'tile', @@ -88,7 +102,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'functions', @@ -100,7 +114,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-standalone', ] }, { 'target_name': 'headless', @@ -111,8 +125,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 +132,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-standalone', + '../mapboxgl.gyp:mbgl-headless', '<(platform_library)', ], }, diff --git a/utils/mbgl-config/build.sh b/utils/mbgl-config/build.sh new file mode 100755 index 000000000..fe7cbdf60 --- /dev/null +++ b/utils/mbgl-config/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +PREFIX=$1 +PLATFORM=$2 +shift +shift + +VARIABLES="#!/bin/bash + +## variables + +CONFIG_MBGL_PREFIX=$PREFIX +CONFIG_MBGL_PLATFORM=$PLATFORM +CONFIG_MBGL_LDFLAGS=\"$@\" +" + +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/mbgl-config.template.sh b/utils/mbgl-config/mbgl-config.template.sh new file mode 100644 index 000000000..16b67b1f0 --- /dev/null +++ b/utils/mbgl-config/mbgl-config.template.sh @@ -0,0 +1,61 @@ +## 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 + ;; + + --prefix) + echo ${CONFIG_MBGL_PREFIX} + ;; + + --libs) + echo -L${CONFIG_MBGL_PREFIX}/lib -lmbgl -lmbgl-${CONFIG_MBGL_PLATFORM} -lmbgl-headless ${CONFIG_MBGL_LDFLAGS} + ;; + + --includedir) + echo ${CONFIG_MBGL_PREFIX}/include + ;; + + *) + # push to stderr any invalid options + echo "unknown option $1" 1>&2; + ;; + esac + shift +done + +exit 0