diff --git a/Makefile b/Makefile index c0d76fd10..ae0ea1395 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,12 @@ BUILDTYPE ?= Release PYTHON ?= python V ?= 1 +ifeq ($(shell uname -s), Darwin) +PLATFORM ?= osx +endif +PLATFORM ?= linux + + all: mbgl config.gypi: configure @@ -12,13 +18,13 @@ config-ios.gypi: configure # Builds the regular library mbgl: config.gypi mapboxgl.gyp - deps/run_gyp mapboxgl.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + 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) mapboxgl ##### Test cases ############################################################### build/test/Makefile: src common config.gypi test/test.gyp - deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/test -f make + deps/run_gyp test/test.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/test -f make test: build/test/Makefile $(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) test @@ -29,7 +35,7 @@ test_%: build/test/Makefile # build Mac OS X project for Xcode xtest: config.gypi clear_xcode_cache - deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build -f xcode + deps/run_gyp test/test.gyp -Iconfig.gypi -Dplatform=osx --depth=. -Goutput_dir=.. --generator-output=./build -f xcode open ./build/test/test.xcodeproj ##### Makefile builds ########################################################## @@ -37,7 +43,7 @@ xtest: config.gypi clear_xcode_cache # Builds the linux app with make. linux: config.gypi linux/mapboxgl-app.gyp - deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make + deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=linux --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make $(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp # Executes the Linux binary @@ -48,7 +54,7 @@ run-linux: linux # Builds the OS X app with make. osx: config.gypi macosx/mapboxgl-app.gyp - deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make + deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=osx --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make $(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp # Executes the OS X binary @@ -70,21 +76,21 @@ clear_xcode_cache: # build Mac OS X project for Xcode xproj-cli: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache - deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode + deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=osx --depth=. --generator-output=./build -f xcode xproj: xproj-cli open ./build/macosx/mapboxgl-app.xcodeproj # build iOS project for Xcode iproj-cli: config-ios.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache - deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp -Iconfig-ios.gypi --depth=. --generator-output=./build -f xcode + deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp -Iconfig-ios.gypi -Dplatform=ios --depth=. --generator-output=./build -f xcode iproj: iproj-cli open ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj # build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code) lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache - deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode + deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=linux --depth=. --generator-output=./build -f xcode open ./build/linux/mapboxgl-app.xcodeproj @@ -98,5 +104,5 @@ clean: clear_xcode_cache distclean: clean -rm -rf ./mason_packages -.PHONY: mbgl test linux build/test/Makefile +.PHONY: mbgl test linux clear_xcode_cache build/test/Makefile # DO NOT DELETE diff --git a/common.gypi b/common.gypi index 5d02a71c1..97481c1bb 100644 --- a/common.gypi +++ b/common.gypi @@ -34,6 +34,6 @@ 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' } }, - } + }, } } diff --git a/gyp/certificates.gypi b/gyp/certificates.gypi new file mode 100644 index 000000000..6a358f0db --- /dev/null +++ b/gyp/certificates.gypi @@ -0,0 +1,13 @@ +{ + 'targets': [ + { + 'target_name': 'copy_certificate_bundle', + 'type': 'none', + 'hard_dependency': 1, + 'copies': [{ + 'files': [ '../common/ca-bundle.crt' ], + 'destination': '<(PRODUCT_DIR)' + }], + }, + ] +} diff --git a/gyp/fixtures.gypi b/gyp/fixtures.gypi new file mode 100644 index 000000000..f290da5d5 --- /dev/null +++ b/gyp/fixtures.gypi @@ -0,0 +1,18 @@ +{ + 'targets': [ + { + 'target_name': 'copy_fixtures', + 'type': 'none', + 'hard_dependency': 1, + 'dependencies': [ + 'bundle_styles' + ], + 'copies': [ + { + 'files': [ '../styles' ], + 'destination': '../test/fixtures/style_parser' + } + ] + }, + ] +} diff --git a/gyp/library.gypi b/gyp/library.gypi new file mode 100644 index 000000000..bb86432da --- /dev/null +++ b/gyp/library.gypi @@ -0,0 +1,75 @@ +{ + 'targets': [ + { + 'target_name': 'mapboxgl', + 'product_name': 'mapboxgl', + 'type': 'static_library', + 'hard_dependency': 1, + 'dependencies': [ + 'shaders', + ], + 'sources': [ + ' -#include #include +#include +#include +#include +#include #include #include #include #include -#include "../common/settings_json.hpp" -#include "../common/glfw_view.hpp" -#include "../common/stderr_log.hpp" + GLFWView *view = nullptr; diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index 05716dd11..09734fc1c 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -1,7 +1,6 @@ { 'includes': [ '../common.gypi', - '../config.gypi', ], 'targets': [ { @@ -10,15 +9,9 @@ 'type': 'executable', 'sources': [ './main.cpp', - '../common/settings_json.cpp', - '../common/settings_json.hpp', - '../common/platform_default.cpp', - '../common/glfw_view.hpp', - '../common/glfw_view.cpp', - '../common/http_request_baton_curl.cpp', - '../common/linux.cpp', - '../common/stderr_log.hpp', - '../common/stderr_log.cpp', + '../platform/default/settings_json.cpp', + '../platform/default/glfw_view.cpp', + '../platform/default/log_stderr.cpp', ], 'conditions': [ @@ -29,11 +22,9 @@ 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS':[ '<@(glfw3_cflags)', - '<@(curl_cflags)', ], 'OTHER_LDFLAGS': [ '<@(glfw3_libraries)', - '<@(curl_libraries)', ], } }, @@ -42,19 +33,19 @@ { 'cflags': [ '<@(glfw3_cflags)', - '<@(curl_cflags)', ], 'link_settings': { 'libraries': [ '<@(glfw3_libraries)', - '<@(curl_libraries)', - '-lboost_regex' + '-L<(boost_root)/lib', + '-lboost_regex', ], }, }], ], 'dependencies': [ '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mapboxgl-linux', '../mapboxgl.gyp:copy_styles', '../mapboxgl.gyp:copy_certificate_bundle', ], diff --git a/macosx/main.mm b/macosx/main.mm index 8cf3cc81c..81494821c 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -1,12 +1,10 @@ -#include "../common/settings_nsuserdefaults.hpp" -#include "../common/glfw_view.hpp" -#include "../common/nslog_log.hpp" -#include "../common/Reachability.h" +#include +#include +#include +#include #import -#include - @interface URLHandler : NSObject @property (nonatomic) mbgl::Map *map; @@ -71,7 +69,6 @@ @end int main() { - fprintf(stderr, "main thread: 0x%lx\n", uv_thread_self()); mbgl::Log::Set(); GLFWView view; diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index 51f591fdd..4451a207b 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -1,7 +1,6 @@ { 'includes': [ '../common.gypi', - '../config.gypi' ], 'targets': [ { @@ -10,17 +9,11 @@ 'type': 'executable', 'sources': [ './main.mm', - '../common/settings_nsuserdefaults.hpp', - '../common/settings_nsuserdefaults.mm', - '../common/platform_nsstring.mm', - '../common/glfw_view.hpp', - '../common/glfw_view.cpp', - '../common/reachability.h', - '../common/reachability.m', - '../common/http_request_baton_cocoa.mm', - '../common/osx.mm', - '../common/nslog_log.hpp', - '../common/nslog_log.mm', + '../platform/darwin/settings_nsuserdefaults.hpp', + '../platform/darwin/settings_nsuserdefaults.mm', + '../platform/darwin/reachability.m', + '../platform/default/glfw_view.hpp', + '../platform/default/glfw_view.cpp', ], 'product_extension': 'app', 'mac_bundle': 1, @@ -45,6 +38,7 @@ 'dependencies': [ '../mapboxgl.gyp:bundle_styles', '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mapboxgl-osx', ] } ] diff --git a/mapboxgl.gyp b/mapboxgl.gyp index bdecb94d0..64c0ccc0c 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -1,248 +1,16 @@ { 'includes': [ './common.gypi', + './gyp/shaders.gypi', + './gyp/npm_install.gypi', + './gyp/styles.gypi', + './gyp/fixtures.gypi', + './gyp/certificates.gypi', + './gyp/library.gypi', + ], + 'conditions': [ + ['platform == "osx"', { 'includes': ['./gyp/platform-osx.gypi'] }], + ['platform == "ios"', { 'includes': ['./gyp/platform-ios.gypi'] }], + ['platform == "linux"', { 'includes': ['./gyp/platform-linux.gypi'] }], ], - 'targets': [ - { - 'target_name': 'shaders', - 'type': 'none', - 'hard_dependency': 1, - 'dependencies': [ - 'npm_install' - ], - 'actions': [ - { - 'action_name': 'Build Shaders', - 'inputs': [ - ' diff --git a/common/Reachability.m b/platform/darwin/reachability.m similarity index 99% rename from common/Reachability.m rename to platform/darwin/reachability.m index c6f6388f5..823465940 100644 --- a/common/Reachability.m +++ b/platform/darwin/reachability.m @@ -25,7 +25,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -#import "Reachability.h" +#import NSString *const kReachabilityChangedNotification = @"kReachabilityChangedNotification"; diff --git a/common/settings_nsuserdefaults.mm b/platform/darwin/settings_nsuserdefaults.mm similarity index 96% rename from common/settings_nsuserdefaults.mm rename to platform/darwin/settings_nsuserdefaults.mm index dfc601bdd..b9b0e134b 100644 --- a/common/settings_nsuserdefaults.mm +++ b/platform/darwin/settings_nsuserdefaults.mm @@ -1,6 +1,6 @@ #import -#include "settings_nsuserdefaults.hpp" +#include using namespace mbgl; diff --git a/common/platform_nsstring.mm b/platform/darwin/string_nsstring.mm similarity index 99% rename from common/platform_nsstring.mm rename to platform/darwin/string_nsstring.mm index 9119f2a8f..9b1dc745c 100644 --- a/common/platform_nsstring.mm +++ b/platform/darwin/string_nsstring.mm @@ -18,4 +18,4 @@ std::string lowercase(const std::string &string) { } } -} \ No newline at end of file +} diff --git a/common/linux.cpp b/platform/default/cache_database_tmp.cpp similarity index 100% rename from common/linux.cpp rename to platform/default/cache_database_tmp.cpp diff --git a/common/glfw_view.cpp b/platform/default/glfw_view.cpp similarity index 99% rename from common/glfw_view.cpp rename to platform/default/glfw_view.cpp index edfb3a6a6..fed21f7d9 100644 --- a/common/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -1,4 +1,4 @@ -#include "glfw_view.hpp" +#include #include diff --git a/common/headless_view.cpp b/platform/default/headless_view.cpp similarity index 100% rename from common/headless_view.cpp rename to platform/default/headless_view.cpp diff --git a/common/http_request_baton_curl.cpp b/platform/default/http_request_baton_curl.cpp similarity index 100% rename from common/http_request_baton_curl.cpp rename to platform/default/http_request_baton_curl.cpp diff --git a/common/stderr_log.cpp b/platform/default/log_stderr.cpp similarity index 94% rename from common/stderr_log.cpp rename to platform/default/log_stderr.cpp index bcb84447b..62938b6d6 100644 --- a/common/stderr_log.cpp +++ b/platform/default/log_stderr.cpp @@ -1,4 +1,4 @@ -#include "stderr_log.hpp" +#include #include #include diff --git a/common/settings_json.cpp b/platform/default/settings_json.cpp similarity index 95% rename from common/settings_json.cpp rename to platform/default/settings_json.cpp index f2f1248aa..f81c75115 100644 --- a/common/settings_json.cpp +++ b/platform/default/settings_json.cpp @@ -1,4 +1,4 @@ -#include "settings_json.hpp" +#include #include #include #include diff --git a/common/platform_default.cpp b/platform/default/string_stdlib.cpp similarity index 100% rename from common/platform_default.cpp rename to platform/default/string_stdlib.cpp diff --git a/common/ios.mm b/platform/ios/cache_database_library.mm similarity index 100% rename from common/ios.mm rename to platform/ios/cache_database_library.mm diff --git a/common/osx.mm b/platform/osx/cache_database_application_support.mm similarity index 100% rename from common/osx.mm rename to platform/osx/cache_database_application_support.mm diff --git a/test/test.gyp b/test/test.gyp index 1f63756e7..865bac867 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -1,7 +1,6 @@ { 'includes': [ '../common.gypi', - '../config.gypi' ], 'targets': [ {