Bug 1059113 - Use templates for shared libraries and frameworks. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 04 Sep 2014 09:04:45 +0900
changeset 226689 8b5e3ba0f83d448eac343b84e95c2caae988524f
parent 226688 344599c26cd3ca2c14cb042dfc82434207d36ceb
child 226690 338372590fc44d51ac28d183ad46afc674caed39
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)
reviewersgps
bugs1059113
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 1059113 - Use templates for shared libraries and frameworks. r=gps Also force to use the existing template for XPCOM components.
accessible/interfaces/ia2/moz.build
accessible/interfaces/msaa/moz.build
build/docs/defining-binaries.rst
build/templates.mozbuild
build/win32/crashinjectdll/moz.build
build/win32/vmwarerecordinghelper/moz.build
config/external/nss/moz.build
config/external/sqlite/moz.build
dom/media/gmp-plugin/moz.build
dom/plugins/ipc/interpose/moz.build
dom/plugins/test/testplugin/javaplugin/moz.build
dom/plugins/test/testplugin/moz.build
dom/plugins/test/testplugin/secondplugin/moz.build
dom/plugins/test/testplugin/testplugin.mozbuild
gfx/angle/src/libEGL/moz.build
gfx/angle/src/libGLESv2/moz.build
js/src/moz.build
layout/media/moz.build
media/omx-plugin/froyo/moz.build
media/omx-plugin/gb/moz.build
media/omx-plugin/gb235/moz.build
media/omx-plugin/hc/moz.build
media/omx-plugin/kk/moz.build
media/omx-plugin/lib/froyo/libstagefright/moz.build
media/omx-plugin/lib/gb/libstagefright/moz.build
media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build
media/omx-plugin/lib/gb/libutils/moz.build
media/omx-plugin/lib/gb235/libstagefright/moz.build
media/omx-plugin/lib/hc/libstagefright/moz.build
media/omx-plugin/lib/ics/libstagefright/moz.build
media/omx-plugin/lib/ics/libutils/moz.build
media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build
media/omx-plugin/moz.build
memory/mozalloc/moz.build
memory/replace/dmd/moz.build
memory/replace/dummy/moz.build
memory/replace/jemalloc/moz.build
mozglue/build/moz.build
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozbuild/frontend/emitter.py
security/manager/ssl/tests/unit/pkcs11testmodule/moz.build
security/sandbox/linux/moz.build
security/sandbox/win/src/sandboxbroker/moz.build
toolkit/components/ctypes/tests/moz.build
toolkit/crashreporter/injector/moz.build
toolkit/crashreporter/test/moz.build
toolkit/library/gtest/moz.build
toolkit/library/libxul.mozbuild
toolkit/library/moz.build
tools/jprof/stub/moz.build
widget/gtk/mozgtk/gtk2/moz.build
widget/gtk/mozgtk/gtk3/moz.build
widget/gtk/mozgtk/stub/moz.build
--- a/accessible/interfaces/ia2/moz.build
+++ b/accessible/interfaces/ia2/moz.build
@@ -1,17 +1,15 @@
 # -*- 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/.
 
-Library('IA2Marshal')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('IA2Marshal')
 
 DEFINES['REGISTER_PROXY_DLL'] = True
 
 DEFFILE = SRCDIR + '/IA2Marshal.def'
 
 OS_LIBS += [
     'uuid',
     'kernel32',
--- a/accessible/interfaces/msaa/moz.build
+++ b/accessible/interfaces/msaa/moz.build
@@ -1,28 +1,26 @@
 # -*- 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/.
 
-Library('AccessibleMarshal')
+SharedLibrary('AccessibleMarshal')
 
 GENERATED_SOURCES += [
     'dlldata.c',
     'ISimpleDOMDocument_i.c',
     'ISimpleDOMDocument_p.c',
     'ISimpleDOMNode_i.c',
     'ISimpleDOMNode_p.c',
     'ISimpleDOMText_i.c',
     'ISimpleDOMText_p.c',
 ]
 
-FORCE_SHARED_LIB = True
-
 DEFINES['REGISTER_PROXY_DLL'] = True
 
 DEFFILE = SRCDIR + '/AccessibleMarshal.def'
 
 OS_LIBS += [
     'kernel32',
     'rpcns4',
     'rpcrt4',
--- a/build/docs/defining-binaries.rst
+++ b/build/docs/defining-binaries.rst
@@ -90,44 +90,44 @@ in the tree.
 As a special rule, those intermediate libraries don't need a ``Library`` name
 for themselves.
 
 
 Shared Libraries
 ================
 
 Sometimes, we want shared libraries, a.k.a. dynamic libraries. Such libraries
-are defined with the same variables as static libraries, with the addition of
-the ``FORCE_SHARED_LIB`` boolean variable:
+are defined similarly to static libraries, using the ``SharedLibrary`` template
+instead of ``Library``.
 
-   FORCE_SHARED_LIB = True
+   SharedLibrary('foo')
 
-When this variable is set, no static library is built. See further below to
+When this template is used, no static library is built. See further below to
 build both types of libraries.
 
-With a ``Library`` name of ``foo``, the library file name will be
+With a ``SharedLibrary`` name of ``foo``, the library file name will be
 ``libfoo.dylib`` on OSX, ``libfoo.so`` on ELF systems (Linux, etc.), and
 ``foo.dll`` on Windows. On Windows, there is also an import library named
 ``foo.lib``, used on the linker command line. ``libfoo.dylib`` and
 ``libfoo.so`` are considered the import library name for, resp. OSX and ELF
 systems.
 
 On OSX, one may want to create a special kind of dynamic library: frameworks.
-This is done with the ``IS_FRAMEWORK`` boolean variable.
+This is done with the ``Framework`` template.
 
-   IS_FRAMEWORK = True
+   Framework('foo')
 
-With a ``Library`` name of ``foo``, the framework file name will be ``foo``.
-This variable however affects the behavior on all platforms, so it needs to
+With a ``Framework`` name of ``foo``, the framework file name will be ``foo``.
+This template however affects the behavior on all platforms, so it needs to
 be set only on OSX.
 
 Another special kind of library, XPCOM-specific, are XPCOM components. One can
-build such a component with the ``IS_COMPONENT`` boolean variable.
+build such a component with the ``XPCOMBinaryComponent`` template.
 
-   IS_COMPONENT = True
+   XPCOMBinaryComponent('foo')
 
 
 Executables
 ===========
 
 Executables, a.k.a. programs, are, in the simplest form, defined with the
 ``Program`` template.
 
--- a/build/templates.mozbuild
+++ b/build/templates.mozbuild
@@ -32,16 +32,32 @@ def CppUnitTests(names, ext='.cpp'):
 
 @template
 def Library(name):
     '''Template for libraries.'''
     LIBRARY_NAME = name
 
 
 @template
+def SharedLibrary(name):
+    '''Template for shared libraries.'''
+    Library(name)
+
+    FORCE_SHARED_LIB = True
+
+
+@template
+def Framework(name):
+    '''Template for OSX Frameworks.'''
+    Library(name)
+
+    IS_FRAMEWORK = True
+
+
+@template
 def HostProgram(name):
     '''Template for build tools executables.'''
     HOST_PROGRAM = name
 
 
 @template
 def HostSimplePrograms(names, ext='.cpp'):
     '''Template for simple build tools executables.
--- a/build/win32/crashinjectdll/moz.build
+++ b/build/win32/crashinjectdll/moz.build
@@ -3,15 +3,13 @@
 # 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/.
 
 SOURCES += [
     'crashinjectdll.cpp',
 ]
 
-Library('crashinjectdll')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('crashinjectdll')
 
 DEFFILE = SRCDIR + '/crashinjectdll.def'
 
 USE_STATIC_LIBS = True
--- a/build/win32/vmwarerecordinghelper/moz.build
+++ b/build/win32/vmwarerecordinghelper/moz.build
@@ -3,15 +3,13 @@
 # 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/.
 
 SOURCES += [
     'vmwarerecordinghelper.cpp',
 ]
 
-Library('vmwarerecordinghelper')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('vmwarerecordinghelper')
 
 DEFFILE = '%s/%s.def' % (SRCDIR, LIBRARY_NAME)
 
 USE_STATIC_LIBS = True
--- a/config/external/nss/moz.build
+++ b/config/external/nss/moz.build
@@ -1,25 +1,24 @@
 # -*- 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/.
 
-Library('nss')
-
 DIRS += ['crmf']
 
 if CONFIG['MOZ_NATIVE_NSS']:
+    Library('nss')
     OS_LIBS += CONFIG['NSS_LIBS']
 elif CONFIG['MOZ_FOLD_LIBS']:
+    SharedLibrary('nss')
     # TODO: The library name can be changed when bug 845217 is fixed.
     SHARED_LIBRARY_NAME = 'nss3'
 
-    FORCE_SHARED_LIB = True
     SDK_LIBRARY = True
 
     # Normally, there should be /something/ to ensure nspr is built
     # before this directory, but since nspr is built during "export",
     # it actually doesn't matter.
     if CONFIG['OS_TARGET'] == 'WINNT':
         suffix = '_s'
     else:
@@ -33,15 +32,16 @@ elif CONFIG['MOZ_FOLD_LIBS']:
     OS_LIBS += CONFIG['REALTIME_LIBS']
 
     if CONFIG['OS_TARGET'] == 'WINNT':
         DEFFILE = 'nss3.def'
 
     if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['GCC_USE_GNU_LD']:
         LD_VERSION_SCRIPT = 'nss3.def'
 else:
+    Library('nss')
     USE_LIBS += [
         '/security/nss/lib/nss/nss3',
         '/security/nss/lib/smime/smime3',
         '/security/nss/lib/ssl/ssl3',
         '/security/nss/lib/util/nssutil3',
         'sqlite',
     ]
--- a/config/external/sqlite/moz.build
+++ b/config/external/sqlite/moz.build
@@ -1,23 +1,23 @@
 # -*- 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/.
 
-Library('sqlite')
-
 if CONFIG['MOZ_NATIVE_SQLITE']:
+    Library('sqlite')
     OS_LIBS += CONFIG['SQLITE_LIBS']
 else:
     DIRS += ['../../../db/sqlite3/src']
     if CONFIG['MOZ_FOLD_LIBS']:
+        Library('sqlite')
         # When folding libraries, sqlite is actually in the nss library.
         USE_LIBS += [
             'nss',
         ]
     else:
-        FORCE_SHARED_LIB = True
+        SharedLibrary('sqlite')
         SHARED_LIBRARY_NAME = 'mozsqlite3'
 
         if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['GCC_USE_GNU_LD']:
             LD_VERSION_SCRIPT = 'sqlite-processed.def'
--- a/dom/media/gmp-plugin/moz.build
+++ b/dom/media/gmp-plugin/moz.build
@@ -4,15 +4,14 @@
 # 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/.
 
 NO_DIST_INSTALL = True
 SOURCES += [
         'gmp-fake.cpp'
 ]
 
-Library("fake")
+SharedLibrary("fake")
 
 USE_STATIC_LIBS = True
-FORCE_SHARED_LIB = True
 NO_VISIBILITY_FLAGS = True
 # Don't use STL wrappers; this isn't Gecko code
 DISABLE_STL_WRAPPING = True
--- a/dom/plugins/ipc/interpose/moz.build
+++ b/dom/plugins/ipc/interpose/moz.build
@@ -1,17 +1,15 @@
 # -*- 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/.
 
-Library('plugin_child_interpose')
+SharedLibrary('plugin_child_interpose')
 
 UNIFIED_SOURCES += [ "%s.mm" % (LIBRARY_NAME) ]
 
 UNIFIED_SOURCES += [
     'plugin_child_quirks.mm',
 ]
 
-FORCE_SHARED_LIB = True
-
 OS_LIBS += ['-framework Carbon']
--- a/dom/plugins/test/testplugin/javaplugin/moz.build
+++ b/dom/plugins/test/testplugin/javaplugin/moz.build
@@ -1,10 +1,10 @@
 # -*- 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/.
 
-Library('nptestjava')
+SharedLibrary('nptestjava')
 
 relative_path = '..'
 include('../testplugin.mozbuild')
--- a/dom/plugins/test/testplugin/moz.build
+++ b/dom/plugins/test/testplugin/moz.build
@@ -1,14 +1,14 @@
 # -*- 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/.
 
 DIRS += ['secondplugin', 'javaplugin']
 
-Library('nptest')
+SharedLibrary('nptest')
 
 FAIL_ON_WARNINGS = not CONFIG['_MSC_VER']
 
 relative_path = '.'
 include('testplugin.mozbuild')
--- a/dom/plugins/test/testplugin/secondplugin/moz.build
+++ b/dom/plugins/test/testplugin/secondplugin/moz.build
@@ -1,10 +1,10 @@
 # -*- 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/.
 
-Library('npsecondtest')
+SharedLibrary('npsecondtest')
 
 relative_path = '..'
 include('../testplugin.mozbuild')
--- a/dom/plugins/test/testplugin/testplugin.mozbuild
+++ b/dom/plugins/test/testplugin/testplugin.mozbuild
@@ -35,18 +35,16 @@ elif toolkit == 'qt':
 elif toolkit == 'windows':
     UNIFIED_SOURCES += [
         relative_path + '/nptest_windows.cpp',
     ]
     OS_LIBS += [
         'msimg32',
     ]
 
-FORCE_SHARED_LIB = True
-
 # must link statically with the CRT; nptest isn't Gecko code
 USE_STATIC_LIBS = True
 
 # Don't use STL wrappers; nptest isn't Gecko code
 DISABLE_STL_WRAPPING = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     RCFILE  = 'nptest.rc'
--- a/gfx/angle/src/libEGL/moz.build
+++ b/gfx/angle/src/libEGL/moz.build
@@ -49,13 +49,12 @@ DEFINES['EGLAPI'] = ""
 
 # ANGLE uses the STL, so we can't use our derpy STL wrappers.
 DISABLE_STL_WRAPPING = True
 
 
 LOCAL_INCLUDES += [ '../../include', '../../src' ]
 USE_LIBS += [ 'libGLESv2' ]
 
-Library('libEGL')
-FORCE_SHARED_LIB = True
+SharedLibrary('libEGL')
 
 RCFILE = SRCDIR + '/libEGL.rc'
 DEFFILE = SRCDIR + '/libEGL.def'
--- a/gfx/angle/src/libGLESv2/moz.build
+++ b/gfx/angle/src/libGLESv2/moz.build
@@ -199,16 +199,15 @@ LOCAL_INCLUDES += [ '../../include', '..
 if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']:
   EXTRA_DSO_LDOPTS += [ 'd3d9.lib', 'dxguid.lib' ]
 else:
   EXTRA_DSO_LDOPTS += [
     '\'%s/lib/%s/d3d9.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']),
     '\'%s/lib/%s/dxguid.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']),
   ]
 
-Library('libGLESv2')
-FORCE_SHARED_LIB = True
+SharedLibrary('libGLESv2')
 
 RCFILE = SRCDIR + '/libGLESv2.rc'
 DEFFILE = SRCDIR + '/libGLESv2.def'
 
 DEFINES['ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES'] = '{ TEXT("d3dcompiler_47.dll"), TEXT("d3dcompiler_46.dll"), TEXT("d3dcompiler_43.dll") }'
 
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -430,22 +430,22 @@ HostSimplePrograms([
 # JavaScript must be built shared, even for static builds, as it is used by
 # other modules which are always built shared. Failure to do so results in
 # the js code getting copied into xpinstall and jsd as well as mozilla-bin,
 # and then the static data cells used for locking no longer work.
 #
 # In fact, we now build both a static and a shared library, as the
 # JS shell would like to link to the static library.
 
-Library('js')
-
 if CONFIG['JS_SHARED_LIBRARY']:
-    FORCE_SHARED_LIB = True
+    SharedLibrary('js')
     SHARED_LIBRARY_NAME = CONFIG['JS_LIBRARY_NAME']
     SDK_LIBRARY = True
+else:
+    Library('js')
 
 FORCE_STATIC_LIB = True
 STATIC_LIBRARY_NAME = 'js_static'
 
 if CONFIG['JS_HAS_CTYPES']:
     USE_LIBS += [
         'ffi',
     ]
--- a/layout/media/moz.build
+++ b/layout/media/moz.build
@@ -1,22 +1,23 @@
 # -*- 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/.
 
-Library('gkmedias')
-
 if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
-    FORCE_SHARED_LIB = True
+    SharedLibrary('gkmedias')
     USE_LIBS += [
         'mozalloc',
         'nspr',
     ]
+else:
+    Library('gkmedias')
+
 
 if CONFIG['MOZ_WEBRTC']:
     DIRS += ['webrtc']
 
 if CONFIG['OS_TARGET'] == 'WINNT':
     DEFFILE = 'symbols.def'
     OS_LIBS += [
         'usp10',
--- a/media/omx-plugin/froyo/moz.build
+++ b/media/omx-plugin/froyo/moz.build
@@ -3,19 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPluginFroyo.cpp',
 ]
 
-Library('omxpluginfroyo')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('omxpluginfroyo')
 
 LOCAL_INCLUDES += [
     '../include/froyo',
     '../include/froyo/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/froyo/libstagefright/stagefright',
--- a/media/omx-plugin/gb/moz.build
+++ b/media/omx-plugin/gb/moz.build
@@ -3,19 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPlugin236.cpp',
 ]
 
-Library('omxplugingb')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('omxplugingb')
 
 LOCAL_INCLUDES += [
     '../include/gb',
     '../include/gb/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/gb/libstagefright/stagefright',
--- a/media/omx-plugin/gb235/moz.build
+++ b/media/omx-plugin/gb235/moz.build
@@ -3,19 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPlugin235.cpp',
 ]
 
-Library('omxplugingb235')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('omxplugingb235')
 
 LOCAL_INCLUDES += [
     '../include/gb',
     '../include/gb/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/gb/libutils/utils',
--- a/media/omx-plugin/hc/moz.build
+++ b/media/omx-plugin/hc/moz.build
@@ -3,19 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPluginHoneycomb.cpp',
 ]
 
-Library('omxpluginhc')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('omxpluginhc')
 
 LOCAL_INCLUDES += [
     '../include/gb',
     '../include/gb/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/gb/libutils/utils',
--- a/media/omx-plugin/kk/moz.build
+++ b/media/omx-plugin/kk/moz.build
@@ -3,19 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPluginKitKat.cpp',
 ]
 
-Library('omxpluginkk')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('omxpluginkk')
 
 LOCAL_INCLUDES += [
     '../include/ics',
     '../include/ics/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/ics/libstagefright/stagefright',
--- a/media/omx-plugin/lib/froyo/libstagefright/moz.build
+++ b/media/omx-plugin/lib/froyo/libstagefright/moz.build
@@ -5,19 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-Library('stagefright')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('stagefright')
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/froyo',
     '/media/omx-plugin/include/froyo/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/gb/libutils/utils',
--- a/media/omx-plugin/lib/gb/libstagefright/moz.build
+++ b/media/omx-plugin/lib/gb/libstagefright/moz.build
@@ -5,19 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-Library('stagefright')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('stagefright')
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/gb/libutils/utils',
--- a/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build
+++ b/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build
@@ -5,19 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright_color_conversion.cpp',
     ]
 
-Library('stagefright_color_conversion')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('stagefright_color_conversion')
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
 # Don't use STL wrappers; this isn't Gecko code
 DISABLE_STL_WRAPPING = True
--- a/media/omx-plugin/lib/gb/libutils/moz.build
+++ b/media/omx-plugin/lib/gb/libutils/moz.build
@@ -5,19 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libutils.cpp',
     ]
 
-Library('utils')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('utils')
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
 # Don't use STL wrappers; this isn't Gecko code
 DISABLE_STL_WRAPPING = True
--- a/media/omx-plugin/lib/gb235/libstagefright/moz.build
+++ b/media/omx-plugin/lib/gb235/libstagefright/moz.build
@@ -5,19 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-Library('stagefright')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('stagefright')
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/gb/libutils/utils',
--- a/media/omx-plugin/lib/hc/libstagefright/moz.build
+++ b/media/omx-plugin/lib/hc/libstagefright/moz.build
@@ -5,19 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-Library('stagefright')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('stagefright')
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/gb/libutils/utils',
--- a/media/omx-plugin/lib/ics/libstagefright/moz.build
+++ b/media/omx-plugin/lib/ics/libstagefright/moz.build
@@ -5,19 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-Library('stagefright')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('stagefright')
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/ics',
     '/media/omx-plugin/include/ics/media/stagefright/openmax',
 ]
 
 USE_LIBS += [
     '/media/omx-plugin/lib/ics/libutils/utils',
--- a/media/omx-plugin/lib/ics/libutils/moz.build
+++ b/media/omx-plugin/lib/ics/libutils/moz.build
@@ -5,19 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libutils.cpp',
     ]
 
-Library('utils')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('utils')
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/ics',
     '/media/omx-plugin/include/ics/media/stagefright/openmax',
 ]
 
 # Don't use STL wrappers; this isn't Gecko code
 DISABLE_STL_WRAPPING = True
--- a/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build
+++ b/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build
@@ -5,15 +5,13 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libvideoeditorplayer.cpp',
     ]
 
-Library('videoeditorplayer')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('videoeditorplayer')
 
 # Don't use STL wrappers; this isn't Gecko code
 DISABLE_STL_WRAPPING = True
 NO_VISIBILITY_FLAGS = True
--- a/media/omx-plugin/moz.build
+++ b/media/omx-plugin/moz.build
@@ -13,19 +13,17 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
 SOURCES += [
     'OmxPlugin.cpp',
 ]
 
-Library('omxplugin')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('omxplugin')
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     pass
 else:
     LOCAL_INCLUDES += [
         'include/ics',
         'include/ics/media/stagefright/openmax',
     ]
--- a/memory/mozalloc/moz.build
+++ b/memory/mozalloc/moz.build
@@ -52,22 +52,20 @@ elif CONFIG['OS_TARGET'] == 'WINNT':
     UNIFIED_SOURCES += [
         'VolatileBufferWindows.cpp',
     ]
 else:
     UNIFIED_SOURCES += [
         'VolatileBufferFallback.cpp',
     ]
 
-Library('mozalloc')
-
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    FORCE_STATIC_LIB = True
+    Library('mozalloc')
 else:
-    FORCE_SHARED_LIB = True
+    SharedLibrary('mozalloc')
     SDK_LIBRARY = True
 
 # The strndup declaration in string.h is in an ifdef __USE_GNU section
 DEFINES['_GNU_SOURCE'] = True
 
 TEST_DIRS += ['tests']
 
 GENERATED_INCLUDES += ['/xpcom']
--- a/memory/replace/dmd/moz.build
+++ b/memory/replace/dmd/moz.build
@@ -13,19 +13,17 @@ SOURCES += [
     '../../../xpcom/base/nsStackWalk.cpp',
     'DMD.cpp',
 ]
 
 SOURCES += [
     '../../../nsprpub/lib/libc/src/strcpy.c',
 ]
 
-Library('dmd')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('dmd')
 
 DEFINES['MOZ_NO_MOZALLOC'] = True
 
 if CONFIG['MOZ_OPTIMIZE']:
     DEFINES['MOZ_OPTIMIZE'] = True
 
 DISABLE_STL_WRAPPING = True
 
--- a/memory/replace/dummy/moz.build
+++ b/memory/replace/dummy/moz.build
@@ -4,13 +4,11 @@
 # 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/.
 NO_DIST_INSTALL = True
 
 SOURCES += [
     'dummy_replace_malloc.c',
 ]
 
-Library('replace_malloc')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('replace_malloc')
 
 DISABLE_STL_WRAPPING = True
--- a/memory/replace/jemalloc/moz.build
+++ b/memory/replace/jemalloc/moz.build
@@ -12,24 +12,22 @@ SOURCES += [
 # Android doesn't have pthread_atfork, so just implement a dummy function.
 # It shouldn't make much problem, as the use of fork is pretty limited on
 # Android.
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     SOURCES += [
         'pthread_atfork.c',
     ]
 
-Library('replace_jemalloc')
+SharedLibrary('replace_jemalloc')
 
 USE_LIBS += [
     'jemalloc',
 ]
 
-FORCE_SHARED_LIB = True
-
 DEFINES['MOZ_JEMALLOC3'] = True
 DEFINES['MOZ_REPLACE_JEMALLOC'] = True
 
 GENERATED_INCLUDES += ['../../jemalloc/src/include']
 if CONFIG['_MSC_VER']:
     LOCAL_INCLUDES += ['/memory/jemalloc/src/include/msvc_compat']
 
 DISABLE_STL_WRAPPING = True
--- a/mozglue/build/moz.build
+++ b/mozglue/build/moz.build
@@ -2,20 +2,19 @@
 # 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/.
 
 # Build mozglue as a shared lib on Windows, OSX and Android.
 # If this is ever changed, update MOZ_SHARED_MOZGLUE in browser/installer/Makefile.in
 if CONFIG['OS_TARGET'] in ('WINNT', 'Darwin', 'Android'):
-    FORCE_SHARED_LIB = True
+    SharedLibrary('mozglue')
 else:
-    FORCE_SHARED_LIB = False
-    FORCE_STATIC_LIB = True
+    Library('mozglue')
 
 SDK_LIBRARY = True
 
 if CONFIG['MOZ_MEMORY'] and (CONFIG['MOZ_NATIVE_JEMALLOC'] or FORCE_SHARED_LIB):
     pass
     # TODO: SHARED_LIBRARY_LIBS go here
 else:
     # Temporary, until bug 662814 lands
@@ -64,18 +63,16 @@ if CONFIG['CPU_ARCH'] == 'arm':
     ]
 
 if CONFIG['MOZ_ASAN']:
     SOURCES += [
         'AsanOptions.cpp',
     ]
 
 
-Library('mozglue')
-
 USE_LIBS += [
     'mfbt',
 ]
 
 if CONFIG['MOZ_LINKER']:
     USE_LIBS += [
         'zlib',
     ]
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -949,19 +949,22 @@ VARIABLES = {
 for name, (storage_type, input_types, docs, tier) in VARIABLES.items():
     if storage_type == list:
         raise RuntimeError('%s has a "list" storage type. Use "List" instead.'
             % name)
 
 # Set of variables that are only allowed in templates:
 TEMPLATE_VARIABLES = {
     'CPP_UNIT_TESTS',
+    'FORCE_SHARED_LIB',
     'HOST_PROGRAM',
     'HOST_LIBRARY_NAME',
     'HOST_SIMPLE_PROGRAMS',
+    'IS_COMPONENT',
+    'IS_FRAMEWORK',
     'LIBRARY_NAME',
     'PROGRAM',
     'SIMPLE_PROGRAMS',
 }
 
 # Add a note to template variable documentation.
 for name in TEMPLATE_VARIABLES:
     if name not in VARIABLES:
@@ -1302,16 +1305,49 @@ DEPRECATION_HINTS = {
 
             SimplePrograms(['foo', 'bar'])
 
         instead of
 
             SIMPLE_PROGRAMS += ['foo', 'bar']"
         ''',
 
+    'FORCE_SHARED_LIB': '''
+        Please use
+
+            SharedLibrary('foo')
+
+        instead of
+
+            Library('foo') [ or LIBRARY_NAME = 'foo' ]
+            FORCE_SHARED_LIB = True
+        ''',
+
+    'IS_COMPONENT': '''
+        Please use
+
+            XPCOMBinaryComponent('foo')
+
+        instead of
+
+            Library('foo') [ or LIBRARY_NAME = 'foo' ]
+            IS_COMPONENT = True
+        ''',
+
+    'IS_FRAMEWORK': '''
+        Please use
+
+            Framework('foo')
+
+        instead of
+
+            Library('foo') [ or LIBRARY_NAME = 'foo' ]
+            IS_FRAMEWORK = True
+        ''',
+
     'TOOL_DIRS': 'Please use the DIRS variable instead.',
 
     'TEST_TOOL_DIRS': 'Please use the TEST_DIRS variable instead.',
 
     'PARALLEL_DIRS': 'Please use the DIRS variable instead.',
 }
 
 # Make sure that all template variables have a deprecation hint.
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -633,36 +633,24 @@ class TreeMetadataEmitter(LoggingMixin):
                 raise SandboxValidationError(
                     'FINAL_LIBRARY conflicts with IS_COMPONENT. '
                     'Please remove one.', context)
             static_args['link_into'] = final_lib
             static_lib = True
 
         if libname:
             if is_component:
-                if shared_lib:
-                    raise SandboxValidationError(
-                        'IS_COMPONENT implies FORCE_SHARED_LIB. '
-                        'Please remove the latter.', context)
-                if is_framework:
-                    raise SandboxValidationError(
-                        'IS_COMPONENT conflicts with IS_FRAMEWORK. '
-                        'Please remove one.', context)
                 if static_lib:
                     raise SandboxValidationError(
                         'IS_COMPONENT conflicts with FORCE_STATIC_LIB. '
                         'Please remove one.', context)
                 shared_lib = True
                 shared_args['variant'] = SharedLibrary.COMPONENT
 
             if is_framework:
-                if shared_lib:
-                    raise SandboxValidationError(
-                        'IS_FRAMEWORK implies FORCE_SHARED_LIB. '
-                        'Please remove the latter.', context)
                 if soname:
                     raise SandboxValidationError(
                         'IS_FRAMEWORK conflicts with SONAME. '
                         'Please remove one.', context)
                 shared_lib = True
                 shared_args['variant'] = SharedLibrary.FRAMEWORK
 
             if static_name:
--- a/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build
+++ b/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build
@@ -3,15 +3,14 @@
 # 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/.
 
 UNIFIED_SOURCES += [
     'pkcs11testmodule.cpp',
 ]
 
-Library('pkcs11testmodule')
+SharedLibrary('pkcs11testmodule')
 
-FORCE_SHARED_LIB = True
 # C_GetFunctionList needs to be exported. As it turns out, it's much easier to
 # just export all the symbols.
 NO_VISIBILITY_FLAGS = True
 NO_DIST_INSTALL = True
--- a/security/sandbox/linux/moz.build
+++ b/security/sandbox/linux/moz.build
@@ -1,18 +1,17 @@
 # -*- 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/.
 
 FAIL_ON_WARNINGS = True
 
-Library('mozsandbox')
-FORCE_SHARED_LIB = True
+SharedLibrary('mozsandbox')
 
 EXPORTS.mozilla += [
     'Sandbox.h',
 ]
 
 SOURCES += [
     # Bug 1059038 workaround:
     '../../../xpcom/glue/unused.cpp',
--- a/security/sandbox/win/src/sandboxbroker/moz.build
+++ b/security/sandbox/win/src/sandboxbroker/moz.build
@@ -1,31 +1,29 @@
 # -*- 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/.
 
-Library('sandboxbroker')
+SharedLibrary('sandboxbroker')
 
 USE_LIBS += [
     'nspr',
     'sandbox_s',
 ]
 
 SOURCES += [
     'sandboxBroker.cpp',
 ]
 
 EXPORTS += [
     'sandboxBroker.h',
 ]
 
-FORCE_SHARED_LIB = True
-
 for var in ('UNICODE', '_UNICODE', 'NS_NO_XPCOM', 'NOMINMAX',
             'SANDBOX_EXPORTS'):
     DEFINES[var] = True
 
 LOCAL_INCLUDES += [
     '/security',
     '/security/sandbox',
     '/security/sandbox/chromium',
--- a/toolkit/components/ctypes/tests/moz.build
+++ b/toolkit/components/ctypes/tests/moz.build
@@ -9,19 +9,17 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcsh
 MOCHITEST_CHROME_MANIFESTS += ['chrome/chrome.ini']
 
 UNIFIED_SOURCES += [
     'jsctypes-test-errno.cpp',
     'jsctypes-test-finalizer.cpp',
     'jsctypes-test.cpp',
 ]
 
-Library('jsctypes-test')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('jsctypes-test')
 
 LOCAL_INCLUDES += [
     '/js/src/ctypes',
 ]
 
 USE_LIBS += [
     'mozalloc',
 ]
--- a/toolkit/crashreporter/injector/moz.build
+++ b/toolkit/crashreporter/injector/moz.build
@@ -3,22 +3,20 @@
 # 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/.
 
 SOURCES += [
     'injector.cpp',
 ]
 
-Library('breakpadinjector')
+SharedLibrary('breakpadinjector')
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
-FORCE_SHARED_LIB = True
-
 LOCAL_INCLUDES += [
     '/toolkit/crashreporter/google-breakpad/src',
 ]
 
 USE_STATIC_LIBS = True
 
 if CONFIG['GNU_CC']:
     LDFLAGS += ['-Wl,-e,_DummyEntryPoint@12']
--- a/toolkit/crashreporter/test/moz.build
+++ b/toolkit/crashreporter/test/moz.build
@@ -12,24 +12,22 @@ UNIFIED_SOURCES += [
     '../google-breakpad/src/common/logging.cc',
     '../google-breakpad/src/common/pathname_stripper.cc',
     '../google-breakpad/src/processor/basic_code_modules.cc',
     '../google-breakpad/src/processor/minidump.cc',
     'dumputils.cpp',
     'nsTestCrasher.cpp',
 ]
 
-Library('testcrasher')
+SharedLibrary('testcrasher')
 
 EXTRA_JS_MODULES += [
     'CrashTestUtils.jsm',
 ]
 
-FORCE_SHARED_LIB = True
-
 DEFINES['SHARED_LIBRARY'] = '%s%s%s' % (
     CONFIG['DLL_PREFIX'],
     LIBRARY_NAME,
     CONFIG['DLL_SUFFIX']
 )
 
 DEFINES['NOMINMAX'] = True
 
--- a/toolkit/library/gtest/moz.build
+++ b/toolkit/library/gtest/moz.build
@@ -1,15 +1,13 @@
 # -*- 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/.
 
-Library('xul-gtest')
+Libxul('xul-gtest')
 
 FINAL_TARGET = 'dist/bin/gtest'
 
 USE_LIBS += [
     'static:xul',
 ]
-
-include('../libxul.mozbuild')
deleted file mode 100644
--- a/toolkit/library/libxul.mozbuild
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- 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/.
-
-MSVC_ENABLE_PGO = True
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
-    # This is going to be a framework named "XUL", not an ordinary library named
-    # "libxul.dylib"
-    SHARED_LIBRARY_NAME = 'XUL'
-    IS_FRAMEWORK = True
-else:
-    SHARED_LIBRARY_NAME = 'xul'
-    FORCE_SHARED_LIB = True
-
-
-DELAYLOAD_DLLS += [
-    'comdlg32.dll',
-    'dbghelp.dll',
-    'psapi.dll',
-    'rasapi32.dll',
-    'rasdlg.dll',
-    'secur32.dll',
-    'wininet.dll',
-    'winspool.drv'
-]
-
-if CONFIG['MOZ_METRO']:
-    DELAYLOAD_DLLS += [
-        'API-MS-WIN-CORE-WINRT-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL',
-        'API-MS-WIN-CORE-WINRT-STRING-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL',
-        'uiautomationcore.dll'
-    ]
-
-if CONFIG['ACCESSIBILITY']:
-    DELAYLOAD_DLLS += ['oleacc.dll']
-
-if CONFIG['MOZ_WEBRTC']:
-    DELAYLOAD_DLLS += ['msdmo.dll']
-
-if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']:
-    LOCAL_INCLUDES += [
-        '/widget/windows',
-        '/xpcom/base',
-    ]
-    # config/version.mk says $(srcdir)/$(RCINCLUDE), and this needs to
-    # be valid in both toolkit/library and toolkit/library/gtest.
-    # Eventually, the make backend would do its own path canonicalization
-    # and config/version.mk would lift the $(srcdir)
-    RCINCLUDE = '$(DEPTH)/toolkit/library/xulrunner.rc'
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -1,15 +1,63 @@
 # -*- 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/.
 
-Library('xul')
+@template
+def Libxul(name):
+    MSVC_ENABLE_PGO = True
+
+    if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
+        # This is going to be a framework named "XUL", not an ordinary library named
+        # "libxul.dylib"
+        Framework(name)
+        SHARED_LIBRARY_NAME = 'XUL'
+    else:
+        SharedLibrary(name)
+        SHARED_LIBRARY_NAME = 'xul'
+
+    DELAYLOAD_DLLS += [
+        'comdlg32.dll',
+        'dbghelp.dll',
+        'psapi.dll',
+        'rasapi32.dll',
+        'rasdlg.dll',
+        'secur32.dll',
+        'wininet.dll',
+        'winspool.drv'
+    ]
+
+    if CONFIG['MOZ_METRO']:
+        DELAYLOAD_DLLS += [
+            'API-MS-WIN-CORE-WINRT-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL',
+            'API-MS-WIN-CORE-WINRT-STRING-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL',
+            'uiautomationcore.dll'
+        ]
+
+    if CONFIG['ACCESSIBILITY']:
+        DELAYLOAD_DLLS += ['oleacc.dll']
+
+    if CONFIG['MOZ_WEBRTC']:
+        DELAYLOAD_DLLS += ['msdmo.dll']
+
+    if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']:
+        LOCAL_INCLUDES += [
+            '/widget/windows',
+            '/xpcom/base',
+        ]
+        # config/version.mk says $(srcdir)/$(RCINCLUDE), and this needs to
+        # be valid in both toolkit/library and toolkit/library/gtest.
+        # Eventually, the make backend would do its own path canonicalization
+        # and config/version.mk would lift the $(srcdir)
+        RCINCLUDE = '$(DEPTH)/toolkit/library/xulrunner.rc'
+
+Libxul('xul')
 
 SDK_LIBRARY = True
 
 FORCE_STATIC_LIB = True
 
 STATIC_LIBRARY_NAME = 'xul_s'
 
 SOURCES += [
@@ -41,18 +89,16 @@ if CONFIG['OS_ARCH'] == 'WINNT' and not 
     LOCAL_INCLUDES += [
         '/xpcom/base',
     ]
 
 FAIL_ON_WARNINGS = True
 
 DIRS += ['gtest']
 
-include('libxul.mozbuild')
-
 # js needs to come after xul for now, because it is an archive and its content
 # is discarded when it comes first.
 USE_LIBS += [
     'js',
 ]
 
 if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
     USE_LIBS += [
--- a/tools/jprof/stub/moz.build
+++ b/tools/jprof/stub/moz.build
@@ -7,13 +7,11 @@
 EXPORTS += [
     'jprof.h',
 ]
 
 SOURCES += [
     'libmalloc.cpp',
 ]
 
-Library('jprof')
-
-FORCE_SHARED_LIB = True
+SharedLibrary('jprof')
 
 DEFINES['_IMPL_JPROF_API'] = True
--- a/widget/gtk/mozgtk/gtk2/moz.build
+++ b/widget/gtk/mozgtk/gtk2/moz.build
@@ -5,22 +5,20 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
     '../mozgtk.c',
 ]
 
 DEFINES['GTK3_SYMBOLS'] = True
 
-Library('mozgtk2')
+SharedLibrary('mozgtk2')
 
 SONAME = 'mozgtk'
 
-FORCE_SHARED_LIB = True
-
 # If LDFLAGS contains -Wl,--as-needed, we need to add -Wl,--no-as-needed
 # before the gtk libraries, otherwise the linker will drop those dependencies
 # because no symbols are used from them. But those dependencies need to be
 # kept for things to work properly.
 if '-Wl,--as-needed' in CONFIG['OS_LDFLAGS']:
     no_as_needed = ['-Wl,--no-as-needed']
     as_needed = ['-Wl,--as-needed']
 else:
--- a/widget/gtk/mozgtk/gtk3/moz.build
+++ b/widget/gtk/mozgtk/gtk3/moz.build
@@ -5,22 +5,20 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
     '../mozgtk.c',
 ]
 
 DEFINES['GTK2_SYMBOLS'] = True
 
-Library('mozgtk')
+SharedLibrary('mozgtk')
 
 SONAME = 'mozgtk'
 
-FORCE_SHARED_LIB = True
-
 # If LDFLAGS contains -Wl,--as-needed, we need to add -Wl,--no-as-needed
 # before the gtk libraries, otherwise the linker will drop those dependencies
 # because no symbols are used from them. But those dependencies need to be
 # kept for things to work properly.
 if '-Wl,--as-needed' in CONFIG['OS_LDFLAGS']:
     no_as_needed = ['-Wl,--no-as-needed']
     as_needed = ['-Wl,--as-needed']
 else:
--- a/widget/gtk/mozgtk/stub/moz.build
+++ b/widget/gtk/mozgtk/stub/moz.build
@@ -6,13 +6,11 @@
 
 SOURCES += [
     '../mozgtk.c',
 ]
 
 for var in ('COMMON_SYMBOLS', 'GTK2_SYMBOLS', 'GTK3_SYMBOLS'):
     DEFINES[var] = True
 
-Library('mozgtk_stub')
+SharedLibrary('mozgtk_stub')
 
 SONAME = 'mozgtk'
-
-FORCE_SHARED_LIB = True