use fake linker for merging the standalone static library

This commit is contained in:
Konstantin Käfer
2015-01-26 18:24:36 +01:00
parent 46553ff00c
commit 3d51e116a8
8 changed files with 73 additions and 73 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
*.o
*.actual.png
*.diff.png
*.pyc
/mason_packages
/config.gypi
/config-ios.gypi

View File

@@ -10,7 +10,7 @@ endif
PLATFORM ?= linux
.PHONY: all
all: mbgl-core mbgl-platform mbgl-headless
all: mbgl
config.gypi: configure
./configure
@@ -20,27 +20,23 @@ config-ios.gypi: configure
#### Library builds ############################################################
.PHONY: mbgl-core
mbgl-core: build/mbgl/Makefile
$(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-core
.PHONY: mbgl-platform
mbgl-platform: build/mbgl/Makefile
$(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-$(PLATFORM)
.PHONY: mbgl-headless
mbgl-headless: build/mbgl/Makefile
$(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-headless
.PHONY: mbgl
mbgl: build/mbgl/Makefile
$(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-core mbgl-$(PLATFORM) mbgl-headless
.PHONY: install
install: build/mbgl/Makefile
$(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) install
.PHONY: standalone
standalone: build/mbgl/Makefile
LINK=`pwd`/gyp/link.py $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) standalone
#### Build scripts #############################################################
.PHONY: build/mbgl/Makefile
build/mbgl/Makefile: mbgl.gyp config.gypi
deps/run_gyp mbgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) -Dinstall_prefix=$(PREFIX) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make
deps/run_gyp mbgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make
.PHONY: build/test/Makefile
build/test/Makefile: test/test.gyp config.gypi

2
configure vendored
View File

@@ -99,8 +99,6 @@ 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

View File

@@ -98,7 +98,7 @@
'xcode_settings': {
'GCC_OPTIMIZATION_LEVEL': '3',
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES',
'DEAD_CODE_STRIPPING': 'YES',
'DEAD_CODE_STRIPPING': 'NO',
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'NO'
}
},

34
gyp/link.py Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env python
import sys
from merge_static_libs import MergeLibs
args = sys.argv[1:]
out_lib = ''
in_libs = []
flags = []
i = 0
l = len(args)
while i < l:
arg = args[i]
if arg[0:2] == '-l':
flags.append(arg)
elif arg == '-arch':
i += 1
elif arg == '-framework':
i += 1
flags.append(arg + ' ' + args[i])
elif arg == '-o':
i += 1
out_lib = args[i]
elif arg[0] != '-':
in_libs.append(arg)
else:
print 'Ignored linker directive: ' + arg
i += 1
MergeLibs(in_libs, out_lib)

View File

@@ -6,8 +6,8 @@
'standalone_static_library': 1,
'hard_dependency': 1,
'dependencies': [
'shaders',
'version',
'shaders',
'version',
],
'sources': [
@@ -21,6 +21,11 @@
'bin/style.json'
],
'include_dirs': [
'../include',
'../src',
],
'variables': {
'cflags_cc': [
'<@(uv_cflags)',
@@ -38,11 +43,6 @@
],
},
'include_dirs': [
'../include',
'../src',
],
'conditions': [
['OS == "mac"', {
'xcode_settings': {
@@ -72,50 +72,5 @@
],
},
},
{ '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)',
'<@(sqlite3_static_libs)',
'<(core_lib)'
],
}
]
}
]
}

16
gyp/mbgl-standalone.gypi Normal file
View File

@@ -0,0 +1,16 @@
{
'targets': [
{ 'target_name': 'standalone',
'product_name': 'libmbgl.a',
'type': 'executable',
'hard_dependency': 1,
'dependencies': [
'<(core_library)',
'<(platform_library)',
'<(storage_library)',
'<(headless_library)',
],
},
],
}

View File

@@ -7,26 +7,26 @@
'./gyp/certificates.gypi',
'./gyp/mbgl-core.gypi',
'./gyp/mbgl-headless.gypi',
'./gyp/mbgl-storage-curl.gypi',
'./gyp/install.gypi',
'./gyp/mbgl-standalone.gypi',
],
'conditions': [
['platform == "osx"', {
'includes': [
'./gyp/mbgl-osx.gypi',
'./gyp/mbgl-storage-cocoa.gypi'
'./gyp/mbgl-storage-cocoa.gypi',
],
}],
['platform == "ios"', {
'includes': [
'./gyp/mbgl-ios.gypi',
'./gyp/mbgl-storage-cocoa.gypi'
'./gyp/mbgl-storage-cocoa.gypi',
],
}],
['platform == "linux"', {
'includes': [
'./gyp/mbgl-linux.gypi'
'./gyp/mbgl-linux.gypi',
'./gyp/mbgl-storage-curl.gypi',
],
}],
['platform == "android"', {