Bug 1059129 - Move the addition of stdc++compat to templates. r=mshal

This commit is contained in:
Mike Hommey 2014-09-04 09:05:12 +09:00
parent a653121671
commit 22206d6d18
2 changed files with 31 additions and 13 deletions

View File

@ -4,11 +4,21 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@template
def StdCppCompat():
'''Template for libstdc++ compatibility for target binaries.'''
if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']:
USE_LIBS += ['stdc++compat']
@template
def Program(name):
'''Template for program executables.'''
PROGRAM = name
StdCppCompat()
@template
def SimplePrograms(names, ext='.cpp'):
@ -19,6 +29,8 @@ def SimplePrograms(names, ext='.cpp'):
SIMPLE_PROGRAMS += names
SOURCES += ['%s%s' % (name, ext) for name in names]
StdCppCompat()
@template
def CppUnitTests(names, ext='.cpp'):
@ -29,6 +41,8 @@ def CppUnitTests(names, ext='.cpp'):
CPP_UNIT_TESTS += names
SOURCES += ['%s%s' % (name, ext) for name in names]
StdCppCompat()
@template
def Library(name):
@ -43,20 +57,32 @@ def SharedLibrary(name):
FORCE_SHARED_LIB = True
StdCppCompat()
@template
def Framework(name):
'''Template for OSX Frameworks.'''
Library(name)
SharedLibrary(name)
IS_FRAMEWORK = True
@template
def HostStdCppCompat():
'''Template for libstdc++ compatibility for host binaries.'''
if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']:
HOST_USE_LIBS += ['host_stdc++compat']
@template
def HostProgram(name):
'''Template for build tools executables.'''
HOST_PROGRAM = name
HostStdCppCompat()
@template
def HostSimplePrograms(names, ext='.cpp'):
@ -68,6 +94,8 @@ def HostSimplePrograms(names, ext='.cpp'):
HOST_SOURCES += ['%s%s' % (name.replace('host_', ''), ext)
for name in names]
HostStdCppCompat()
@template
def HostLibrary(name):
@ -95,7 +123,7 @@ def XPCOMBinaryComponent(name):
name is the name of the component.
'''
LIBRARY_NAME = name
SharedLibrary(name)
GeckoBinary()

View File

@ -240,17 +240,7 @@ class TreeMetadataEmitter(LoggingMixin):
"""Add linkage declarations to a given object."""
assert isinstance(obj, Linkable)
extra = []
# Add stdc++compat library when wanted and needed
compat_varname = 'MOZ_LIBSTDCXX_%s_VERSION' % obj.KIND.upper()
if context.config.substs.get(compat_varname) \
and not isinstance(obj, (StaticLibrary, HostLibrary)):
extra.append({
'target': 'stdc++compat',
'host': 'host_stdc++compat',
}[obj.KIND])
for path in context.get(variable, []) + extra:
for path in context.get(variable, []):
force_static = path.startswith('static:') and obj.KIND == 'target'
if force_static:
path = path[7:]