Bug 1041941 - Use templates for Gecko XPCOM components. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Sun, 24 Aug 2014 09:11:05 +0900
changeset 201231 62b9f6d4328bb3609e731c694aabf9ad2ba9406d
parent 201230 313a81600191c795d8e6108dd1f5c53e04b15c00
child 201232 fbd0bffddd86ceda2987d83927311443f0101d12
push id48120
push usermh@glandium.org
push dateSun, 24 Aug 2014 00:11:28 +0000
treeherdermozilla-inbound@62b9f6d4328b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1041941
milestone34.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 1041941 - Use templates for Gecko XPCOM components. r=gps
browser/components/build/moz.build
build/templates.mozbuild
extensions/gnomevfs/moz.build
js/xpconnect/tests/components/native/moz.build
moz.build
toolkit/system/dbus/moz.build
toolkit/system/gnome/moz.build
xpcom/sample/moz.build
xpcom/tests/bug656331_component/moz.build
xpcom/tests/component/moz.build
xpcom/tests/component_no_aslr/moz.build
xulrunner/examples/simple/components/src/moz.build
--- a/browser/components/build/moz.build
+++ b/browser/components/build/moz.build
@@ -7,35 +7,26 @@
 EXPORTS += [
     'nsBrowserCompsCID.h',
 ]
 
 SOURCES += [
     'nsModule.cpp',
 ]
 
-LIBRARY_NAME = 'browsercomps'
-
-IS_COMPONENT = True
+XPCOMBinaryComponent('browsercomps')
 
 LOCAL_INCLUDES += [
     '../about',
     '../dirprovider',
     '../feeds',
     '../migration',
     '../shell',
 ]
 
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]
-
 if CONFIG['OS_ARCH'] == 'WINNT':
     OS_LIBS += [
         'ole32',
         'shell32',
         'shlwapi',
         'version',
     ]
 
new file mode 100644
--- /dev/null
+++ b/build/templates.mozbuild
@@ -0,0 +1,31 @@
+# -*- 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 GeckoBinary():
+    '''Template for binaries using Gecko.
+
+    This template is meant to be used in other templates.
+    '''
+    USE_LIBS += [
+        'mozalloc',
+        'nspr',
+        'xpcomglue_s',
+        'xul',
+    ]
+
+
+@template
+def XPCOMBinaryComponent(name):
+    '''Template defining an XPCOM binary component for Gecko.
+
+    name is the name of the component.
+    '''
+    LIBRARY_NAME = name
+
+    GeckoBinary()
+
+    IS_COMPONENT = True
--- a/extensions/gnomevfs/moz.build
+++ b/extensions/gnomevfs/moz.build
@@ -3,26 +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 += [
     'nsGnomeVFSProtocolHandler.cpp',
 ]
 
-LIBRARY_NAME = 'nkgnomevfs'
-
-IS_COMPONENT = True
+XPCOMBinaryComponent('nkgnomevfs')
 
 # make sure this component is never statically linked into the main
 # application.  this is necessary since we don't want to force users
 # to install gnome-vfs2 in order to use the rest of mozilla ;-)
 
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]
-
 CXXFLAGS += CONFIG['MOZ_GNOMEVFS_CFLAGS']
 
 OS_LIBS += CONFIG['MOZ_GNOMEVFS_LIBS']
--- a/js/xpconnect/tests/components/native/moz.build
+++ b/js/xpconnect/tests/components/native/moz.build
@@ -7,26 +7,17 @@
 NO_DIST_INSTALL = True
 
 UNIFIED_SOURCES += [
     'xpctest_attributes.cpp',
     'xpctest_module.cpp',
     'xpctest_params.cpp',
 ]
 
-LIBRARY_NAME = 'xpctest'
-
-IS_COMPONENT = True
+XPCOMBinaryComponent('xpctest')
 
 DEFINES['LIBRARY_FILENAME'] = '%s%s%s' % (
     CONFIG['DLL_PREFIX'],
     LIBRARY_NAME,
     CONFIG['DLL_SUFFIX']
 )
 
 FAIL_ON_WARNINGS = True
-
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]
--- a/moz.build
+++ b/moz.build
@@ -50,8 +50,10 @@ if CONFIG['COMPILE_ENVIRONMENT'] and not
         add_tier_dir('js', ['config/external/ffi'])
     if CONFIG['ENABLE_INTL_API']:
         add_tier_dir('js', ['config/external/icu'])
     add_tier_dir('js', ['js/src'])
 
 if not CONFIG['JS_STANDALONE']:
     # Bring in the configuration for the configured application.
     include('/' + CONFIG['MOZ_BUILD_APP'] + '/app.mozbuild')
+
+include('build/templates.mozbuild')
--- a/toolkit/system/dbus/moz.build
+++ b/toolkit/system/dbus/moz.build
@@ -5,23 +5,14 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
     'nsDBusModule.cpp',
     'nsDBusService.cpp',
     'nsNetworkManagerListener.cpp',
 ]
 
-LIBRARY_NAME = 'dbusservice'
-
-IS_COMPONENT = True
-
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]
+XPCOMBinaryComponent('dbusservice')
 
 CXXFLAGS += CONFIG['TK_CFLAGS']
 CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
 
 OS_LIBS += CONFIG['MOZ_DBUS_GLIB_LIBS']
--- a/toolkit/system/gnome/moz.build
+++ b/toolkit/system/gnome/moz.build
@@ -19,32 +19,24 @@ if CONFIG['MOZ_ENABLE_GNOMEVFS']:
     ]
 
 if CONFIG['MOZ_ENABLE_GIO']:
     SOURCES += [
         'nsGIOService.cpp',
         'nsGSettingsService.cpp',
     ]
 
-LIBRARY_NAME = 'mozgnome'
+XPCOMBinaryComponent('mozgnome')
 
 FAIL_ON_WARNINGS = True
-IS_COMPONENT = True
 
 LOCAL_INCLUDES += [
     '/toolkit/components/build/',
 ]
 
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]
-
 CXXFLAGS += CONFIG['MOZ_GCONF_CFLAGS']
 CXXFLAGS += CONFIG['MOZ_GNOMEVFS_CFLAGS']
 CXXFLAGS += CONFIG['MOZ_GIO_CFLAGS']
 CXXFLAGS += CONFIG['GLIB_CFLAGS']
 CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
 
 if CONFIG['MOZ_ENABLE_GTK']:
     CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/xpcom/sample/moz.build
+++ b/xpcom/sample/moz.build
@@ -24,29 +24,19 @@ UNIFIED_SOURCES += [
 
 # EXTRA_COMPONENTS installs components written JavaScript to
 # dist/bin/components
 EXTRA_COMPONENTS += [
     'nsSample.js',
     'nsSample.manifest',
 ]
 
-# LIBRARY_NAME names the library generated by this makefile,
+# XPCOMBinaryComponent names the library generated by this makefile,
 # i.e. dist/bin/components/libxpcomsample.so
-LIBRARY_NAME = 'xpcomsample'
-
-# IS_COMPONENT indicates that this makefile builds a component shared library.
-IS_COMPONENT = True
+XPCOMBinaryComponent('xpcomsample')
 
 RESOURCE_FILES.samples += [
     'xpconnect-sample.html',
 ]
 
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]
-
 # Need to link with CoreFoundation on Mac
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     OS_LIBS += CONFIG['TK_LIBS']
--- a/xpcom/tests/bug656331_component/moz.build
+++ b/xpcom/tests/bug656331_component/moz.build
@@ -5,28 +5,19 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 NO_DIST_INSTALL = True
 
 SOURCES += [
     'TestComponent.cpp',
 ]
 
-LIBRARY_NAME = 'test656331'
-
-IS_COMPONENT = True
+XPCOMBinaryComponent('test656331')
 
 DEFINES['LIBRARY_FILENAME'] = '%s%s%s' % (
     CONFIG['DLL_PREFIX'],
     LIBRARY_NAME,
     CONFIG['DLL_SUFFIX']
 )
 
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]
-
 # Need to link with CoreFoundation on Mac
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     OS_LIBS += CONFIG['TK_LIBS']
--- a/xpcom/tests/component/moz.build
+++ b/xpcom/tests/component/moz.build
@@ -5,28 +5,19 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 NO_DIST_INSTALL = True
 
 SOURCES += [
     'TestComponent.cpp',
 ]
 
-LIBRARY_NAME = 'testcomponent'
-
-IS_COMPONENT = True
+XPCOMBinaryComponent('testcomponent')
 
 DEFINES['LIBRARY_FILENAME'] = '%s%s%s' % (
     CONFIG['DLL_PREFIX'],
     LIBRARY_NAME,
     CONFIG['DLL_SUFFIX']
 )
 
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]
-
 # Need to link with CoreFoundation on Mac
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     OS_LIBS += CONFIG['TK_LIBS']
--- a/xpcom/tests/component_no_aslr/moz.build
+++ b/xpcom/tests/component_no_aslr/moz.build
@@ -5,28 +5,19 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 NO_DIST_INSTALL = True
 
 SOURCES += [
     'TestComponent.cpp',
 ]
 
-LIBRARY_NAME = 'testcompnoaslr'
-
-IS_COMPONENT = True
+XPCOMBinaryComponent('testcompnoaslr')
 
 DEFINES['LIBRARY_FILENAME'] = '%s%s%s' % (
     CONFIG['DLL_PREFIX'],
     LIBRARY_NAME,
     CONFIG['DLL_SUFFIX']
 )
 
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]
-
 # Need to link with CoreFoundation on Mac
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     OS_LIBS += CONFIG['TK_LIBS']
--- a/xulrunner/examples/simple/components/src/moz.build
+++ b/xulrunner/examples/simple/components/src/moz.build
@@ -3,25 +3,16 @@
 # 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 += [
     'SimpleTest.cpp',
 ]
 
-LIBRARY_NAME = 'simpletest'
+XPCOMBinaryComponent('simpletest')
 
 EXTRA_COMPONENTS += [
     'SimpleTest.js',
     'SimpleTest.manifest',
 ]
 
-IS_COMPONENT = True
-
 XPI_NAME = 'simple'
-
-USE_LIBS += [
-    'mozalloc',
-    'nspr',
-    'xpcomglue_s',
-    'xul',
-]