diff options
Diffstat (limited to 'gyp')
-rw-r--r-- | gyp/common.gypi | 14 | ||||
-rw-r--r-- | gyp/install.gypi | 6 | ||||
-rw-r--r-- | gyp/mbgl-core.gypi | 93 | ||||
-rw-r--r-- | gyp/mbgl-headless.gypi | 4 | ||||
-rw-r--r-- | gyp/mbgl-ios.gypi | 18 | ||||
-rw-r--r-- | gyp/mbgl-linux.gypi | 49 | ||||
-rw-r--r-- | gyp/mbgl-osx.gypi | 17 | ||||
-rwxr-xr-x | gyp/merge_static_libs.py | 66 |
8 files changed, 215 insertions, 52 deletions
diff --git a/gyp/common.gypi b/gyp/common.gypi index 6d6b0e6671..c25bb77779 100644 --- a/gyp/common.gypi +++ b/gyp/common.gypi @@ -1,6 +1,7 @@ { 'variables': { 'install_prefix%': '', + 'standalone_product_dir':'<!@(pwd)/../build' }, 'target_defaults': { 'default_configuration': 'Release', @@ -24,6 +25,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': { diff --git a/gyp/install.gypi b/gyp/install.gypi index f3ff2002bc..e7217219c8 100644 --- a/gyp/install.gypi +++ b/gyp/install.gypi @@ -6,12 +6,14 @@ 'type': 'none', 'hard_dependency': 1, 'dependencies': [ - 'mbgl', + 'mbgl-core', + 'mbgl-standalone', 'mbgl-headless', 'mbgl-<(platform)', ], 'copies': [ - { 'files': [ '<(PRODUCT_DIR)/libmbgl.a' ], 'destination': '<(install_prefix)/lib' }, + { 'files': [ '<(standalone_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-core.gypi b/gyp/mbgl-core.gypi new file mode 100644 index 0000000000..ed4a029fb6 --- /dev/null +++ b/gyp/mbgl-core.gypi @@ -0,0 +1,93 @@ +{ + 'targets': [ + { 'target_name': 'mbgl-core', + 'product_name': 'mbgl-core', + 'type': 'static_library', + 'standalone_static_library': 1, + 'hard_dependency': 1, + 'dependencies': [ + 'shaders', + ], + 'variables': { + 'cflags_cc': [ + '<@(png_cflags)', + '<@(uv_cflags)', + '<@(sqlite3_cflags)', + '<@(zlib_cflags)', + '-I<(boost_root)/include', + ], + 'cflags': [ + '<@(uv_cflags)', + ], + }, + 'sources': [ + '<!@(find src -name "*.cpp")', + '<!@(test -f "config/constants_local.cpp" && echo "config/constants_local.cpp" || echo "config/constants.cpp")', + '<!@(find src -name "*.c")', + '<!@(find src -name "*.h")', + '<!@(find include -name "*.hpp")', + '<!@(find include -name "*.h")', + '<!@(find src -name "*.glsl")', + 'bin/style.json' + ], + 'include_dirs': [ + '../include', + ], + 'conditions': [ + ['OS == "mac"', { + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], + 'OTHER_CFLAGS': [ '<@(cflags)' ], + }, + }, { + 'cflags_cc': [ '<@(cflags_cc)' ], + 'cflags': [ '<@(cflags)' ], + }] + ] + }, + { + 'target_name': 'mbgl-standalone', + 'type': 'none', + 'hard_dependency': 1, + 'dependencies': [ + 'mbgl-core' + ], + 'variables': { + 'core_lib':'<(PRODUCT_DIR)/libmbgl-core.a', + 'standalone_lib':'<(standalone_product_dir)/libmbgl.a' + }, + 'direct_dependent_settings': { + 'include_dirs': [ + '../include', + ], + 'conditions': [ + ['OS == "mac"', { + 'xcode_settings': { + 'OTHER_LDFLAGS': [ '<(standalone_lib)' ], + } + }, { + 'ldflags': [ '<(standalone_lib)' ], + }] + ], + }, + 'actions': [ + { + 'action_name': 'build standalone core lib', + 'inputs': [ + '<(core_lib)' + ], + 'outputs': [ + '<(standalone_lib)' + ], + 'action': [ + './gyp/merge_static_libs.py', + '<(standalone_lib)', + '<@(uv_static_libs)', + '<@(curl_static_libs)', + '<(core_lib)' + ], + } + ] + } + ] +} diff --git a/gyp/mbgl-headless.gypi b/gyp/mbgl-headless.gypi index e71fb7efb9..08ac211814 100644 --- a/gyp/mbgl-headless.gypi +++ b/gyp/mbgl-headless.gypi @@ -12,5 +12,5 @@ '../platform/default/headless_display.cpp', ], }, - ] -}
\ No newline at end of file + ], +} diff --git a/gyp/mbgl-ios.gypi b/gyp/mbgl-ios.gypi index 4398f04ebc..755b3cc483 100644 --- a/gyp/mbgl-ios.gypi +++ b/gyp/mbgl-ios.gypi @@ -12,7 +12,6 @@ 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', 'CLANG_ENABLE_OBJC_ARC': 'YES', 'CODE_SIGN_IDENTITY': 'iPhone Developer', - 'PUBLIC_HEADERS_FOLDER_PATH': 'include', }, 'configurations': { 'Release': { @@ -30,29 +29,22 @@ 'type': 'static_library', 'standalone_static_library': 1, 'hard_dependency': 1, - 'include_dirs': [ - '../include', - ], 'sources': [ '../platform/ios/cache_database_library.mm', '../platform/darwin/log_nslog.mm', '../platform/darwin/string_nsstring.mm', '../platform/darwin/http_request_baton_cocoa.mm', ], + 'include_dirs': [ + '../include', + ], 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS': [ - '<@(uv_cflags)', - ], + 'OTHER_CPLUSPLUSFLAGS': [ '<@(uv_cflags)' ], }, 'direct_dependent_settings': { 'include_dirs': [ '../include', - ], - 'xcode_settings': { - 'OTHER_LDFLAGS': [ - '<@(uv_libraries)', - ], - }, + ] }, }, ], diff --git a/gyp/mbgl-linux.gypi b/gyp/mbgl-linux.gypi index 6d8631e8dc..337e98039e 100644 --- a/gyp/mbgl-linux.gypi +++ b/gyp/mbgl-linux.gypi @@ -5,28 +5,38 @@ 'type': 'static_library', 'standalone_static_library': 1, 'hard_dependency': 1, - 'include_dirs': [ - '../include' - ], + 'variables': { + 'cflags_cc': [ + '<@(uv_cflags)', + '<@(curl_cflags)', + ], + 'cflags': [ + '<@(uv_cflags)', + ], + 'ldflags': [ + '<@(uv_ldflags)', + '<@(curl_ldflags)', + ], + }, 'sources': [ '../platform/default/cache_database_tmp.cpp', '../platform/default/log_stderr.cpp', '../platform/default/string_stdlib.cpp', '../platform/default/http_request_baton_curl.cpp', ], + 'include_dirs': [ + '../include', + ], 'conditions': [ ['OS == "mac"', { 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS': [ - '<@(uv_cflags)', - '<@(curl_cflags)', - ], + 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], + 'OTHER_CFLAGS': [ '<@(cflags)' ], } }, { - 'cflags': [ - '<@(uv_cflags)', - '<@(curl_cflags)', - ], + 'ldflags': [ '<@(ldflags)' ], + 'cflags_cc': [ '<@(cflags_cc)' ], + 'cflags': [ '<@(cflags)' ], }] ], 'direct_dependent_settings': { @@ -36,20 +46,13 @@ 'conditions': [ ['OS == "mac"', { 'xcode_settings': { - 'OTHER_LDFLAGS': [ - '<@(uv_libraries)', - '<@(curl_libraries)', - ] + 'OTHER_LDFLAGS': [ '<@(ldflags)' ], } }, { - 'libraries': [ - '<@(uv_libraries)', - '<@(curl_libraries)', - '-lboost_regex', - ] + 'ldflags': [ '<@(ldflags)' ], }] - ] - } + ], + }, }, - ] + ], } diff --git a/gyp/mbgl-osx.gypi b/gyp/mbgl-osx.gypi index 80af5b97a3..bee0325498 100644 --- a/gyp/mbgl-osx.gypi +++ b/gyp/mbgl-osx.gypi @@ -5,29 +5,22 @@ 'type': 'static_library', 'standalone_static_library': 1, 'hard_dependency': 1, - 'include_dirs': [ - '../include', - ], 'sources': [ '../platform/osx/cache_database_application_support.mm', '../platform/darwin/log_nslog.mm', '../platform/darwin/string_nsstring.mm', '../platform/darwin/http_request_baton_cocoa.mm', ], + 'include_dirs': [ + '../include', + ], 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS': [ - '<@(uv_cflags)', - ], + 'OTHER_CPLUSPLUSFLAGS': [ '<@(uv_cflags)' ], }, 'direct_dependent_settings': { 'include_dirs': [ '../include', - ], - 'xcode_settings': { - 'OTHER_LDFLAGS': [ - '<@(uv_libraries)', - ], - }, + ] }, }, ], diff --git a/gyp/merge_static_libs.py b/gyp/merge_static_libs.py new file mode 100755 index 0000000000..842be18c84 --- /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()) |