Bug 1059129 - Move the addition of stdc++compat to templates. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 04 Sep 2014 09:05:12 +0900
changeset 226690 338372590fc44d51ac28d183ad46afc674caed39
parent 226689 8b5e3ba0f83d448eac343b84e95c2caae988524f
child 226691 9fe5fe620802dc4eed07c30a24de21300c112f91
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1059129
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1059129 - Move the addition of stdc++compat to templates. r=mshal
build/templates.mozbuild
python/mozbuild/mozbuild/frontend/emitter.py
--- a/build/templates.mozbuild
+++ b/build/templates.mozbuild
@@ -1,78 +1,106 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # 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'):
     '''Template for simple program executables.
 
     Those have a single source with the same base name as the executable.
     '''
     SIMPLE_PROGRAMS += names
     SOURCES += ['%s%s' % (name, ext) for name in names]
 
+    StdCppCompat()
+
 
 @template
 def CppUnitTests(names, ext='.cpp'):
     '''Template for C++ unit tests.
 
     Those have a single source with the same base name as the executable.
     '''
     CPP_UNIT_TESTS += names
     SOURCES += ['%s%s' % (name, ext) for name in names]
 
+    StdCppCompat()
+
 
 @template
 def Library(name):
     '''Template for libraries.'''
     LIBRARY_NAME = name
 
 
 @template
 def SharedLibrary(name):
     '''Template for shared libraries.'''
     Library(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'):
     '''Template for simple build tools executables.
 
     Those have a single source with the same base name as the executable.
     '''
     HOST_SIMPLE_PROGRAMS += names
     HOST_SOURCES += ['%s%s' % (name.replace('host_', ''), ext)
         for name in names]
 
+    HostStdCppCompat()
+
 
 @template
 def HostLibrary(name):
     '''Template for build tools libraries.'''
     HOST_LIBRARY_NAME = name
 
 
 @template
@@ -90,13 +118,13 @@ def GeckoBinary():
 
 
 @template
 def XPCOMBinaryComponent(name):
     '''Template defining an XPCOM binary component for Gecko.
 
     name is the name of the component.
     '''
-    LIBRARY_NAME = name
+    SharedLibrary(name)
 
     GeckoBinary()
 
     IS_COMPONENT = True
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -235,27 +235,17 @@ class TreeMetadataEmitter(LoggingMixin):
         'host': 'HOST_LIBRARY_NAME',
         'target': 'LIBRARY_NAME',
     }
 
     def _link_libraries(self, context, obj, variable):
         """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:]
             name = mozpath.basename(path)
             dir = mozpath.dirname(path)
             candidates = [l for l in self._libs[name] if l.KIND == obj.KIND]
             if dir:
                 if dir.startswith('/'):