Skip to content

Commit

Permalink
Bug 1077148 part 4 - Add and use new moz.build templates for Gecko pr…
Browse files Browse the repository at this point in the history
…ograms and libraries. r=gps

There are, sadly, many combinations of linkage in use throughout the tree.
The main differentiator, though, is between program/libraries related to
Gecko or not. Kind of. Some need mozglue, some don't. Some need dependent
linkage, some standalone.

Anyways, these new templates remove the need to manually define the
right dependencies against xpcomglue, nspr, mozalloc and mozglue
in most cases.

Places that build programs and were resetting MOZ_GLUE_PROGRAM_LDFLAGS
or that build libraries and were resetting MOZ_GLUE_LDFLAGS can now
just not use those Gecko-specific templates.
  • Loading branch information
glandium committed Oct 30, 2014
1 parent 451afe2 commit 54aee67
Show file tree
Hide file tree
Showing 109 changed files with 318 additions and 658 deletions.
2 changes: 1 addition & 1 deletion accessible/interfaces/ia2/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 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/.

SharedLibrary('IA2Marshal')
GeckoSharedLibrary('IA2Marshal', linkage=None)

DEFINES['REGISTER_PROXY_DLL'] = True

Expand Down
2 changes: 1 addition & 1 deletion accessible/interfaces/msaa/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 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/.

SharedLibrary('AccessibleMarshal')
GeckoSharedLibrary('AccessibleMarshal', linkage=None)

GENERATED_SOURCES += [
'dlldata.c',
Expand Down
10 changes: 2 additions & 8 deletions b2g/app/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

if not CONFIG['LIBXUL_SDK']:
if CONFIG['GAIADIR']:
Program(CONFIG['MOZ_APP_NAME'] + "-bin")
GeckoProgram(CONFIG['MOZ_APP_NAME'] + "-bin")
else:
Program(CONFIG['MOZ_APP_NAME'])
GeckoProgram(CONFIG['MOZ_APP_NAME'])
if CONFIG['MOZ_B2G_LOADER']:
SOURCES += [
'B2GLoader.cpp',
Expand All @@ -26,8 +26,6 @@ if not CONFIG['LIBXUL_SDK']:
'zlib',
]

DEFINES['XPCOM_GLUE'] = True

for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION', 'MOZ_UPDATER'):
DEFINES[var] = CONFIG[var]

Expand Down Expand Up @@ -70,10 +68,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
'utils',
]

USE_LIBS += [
'xpcomglue',
]

DISABLE_STL_WRAPPING = True

if CONFIG['OS_ARCH'] == 'WINNT':
Expand Down
3 changes: 0 additions & 3 deletions b2g/gaia/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

GAIA_PATH := gaia/profile

# This is needed to avoid making run-b2g depend on mozglue
WRAP_LDFLAGS :=

GENERATED_DIRS += $(DIST)/bin/$(GAIA_PATH)

include $(topsrcdir)/config/rules.mk
Expand Down
22 changes: 8 additions & 14 deletions browser/app/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

DIRS += ['profile/extensions']

Program(CONFIG['MOZ_APP_NAME'])
if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_METRO']:
GeckoProgram(CONFIG['MOZ_APP_NAME'])
else:
GeckoProgram(CONFIG['MOZ_APP_NAME'], msvcrt='static')

SOURCES += [
'nsBrowserApp.cpp',
Expand All @@ -18,8 +21,6 @@ for var in ('MOZILLA_OFFICIAL', 'LIBXUL_SDK'):
if CONFIG[var]:
DEFINES[var] = True

DEFINES['XPCOM_GLUE'] = True

GENERATED_INCLUDES += [
'/build',
]
Expand All @@ -34,7 +35,10 @@ if not CONFIG['MOZ_METRO']:
DELAYLOAD_DLLS += [
'mozglue.dll',
]
USE_STATIC_LIBS = True

USE_LIBS += [
'mozglue',
]

if CONFIG['_MSC_VER']:
# Always enter a Windows program through wmain, whether or not we're
Expand All @@ -56,16 +60,6 @@ if CONFIG['OS_ARCH'] == 'WINNT':
if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']:
LDFLAGS += ['/HEAP:0x40000']

if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['MOZ_METRO']:
USE_LIBS += [
'mozglue',
'xpcomglue_staticruntime',
]
else:
USE_LIBS += [
'xpcomglue',
]

DISABLE_STL_WRAPPING = True

if CONFIG['MOZ_LINKER']:
Expand Down
5 changes: 0 additions & 5 deletions browser/metro/shell/commandexecutehandler/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ ifndef MOZ_WINCONSOLE
MOZ_WINCONSOLE = 0
endif

include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

DIST_PROGRAM = CommandExecuteHandler$(BIN_SUFFIX)

# Don't link against mozglue.dll
MOZ_GLUE_LDFLAGS =
MOZ_GLUE_PROGRAM_LDFLAGS =
7 changes: 0 additions & 7 deletions browser/metro/shell/testing/Makefile.in

This file was deleted.

2 changes: 0 additions & 2 deletions build/clang-plugin/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# LLVM_CXXFLAGS comes with its own optimization flags.
MOZ_OPTIMIZE =

MOZ_GLUE_LDFLAGS =

include $(topsrcdir)/config/config.mk

# In the current moz.build world, we need to override essentially every
Expand Down
30 changes: 25 additions & 5 deletions build/docs/defining-binaries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ 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 ``XPCOMBinaryComponent`` template.

XPCOMBinaryComponent('foo')


Executables
===========
Expand Down Expand Up @@ -293,3 +288,28 @@ On e.g. Linux, the above ``myprog`` will have DT_NEEDED markers for
``libmylib.so`` and ``libfoo.so`` instead of ``libmylib.so`` and
``libotherlib.so`` if there weren't a ``SONAME``. This means the runtime
requirement for ``myprog`` is ``libfoo.so`` instead of ``libotherlib.so``.


Gecko-related binaries
======================

Some programs or libraries are totally independent of Gecko, and can use the
above mentioned templates. Others are Gecko-related in some way, and may
need XPCOM linkage, mozglue. These things are tedious. A set of additional
templates exists to ease defining such programs and libraries. They are
essentially the same as the above mentioned templates, prefixed with "Gecko":

- ``GeckoProgram``
- ``GeckoSimplePrograms``
- ``GeckoCppUnitTests``
- ``GeckoSharedLibrary``
- ``GeckoFramework``

There is also ``XPCOMBinaryComponent`` for XPCOM components, which is a
special kind of library.

All the Gecko-prefixed templates take the same arguments as their
non-Gecko-prefixed counterparts, and can take a few more arguments
for non-standard cases. See the definition of ``GeckoBinary`` in
build/gecko_templates.mozbuild for more details, but most usecases
should not require these additional arguments.
155 changes: 155 additions & 0 deletions build/gecko_templates.mozbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# -*- 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(linkage='dependent', msvcrt='dynamic', mozglue=None):
'''Template for Gecko-related binaries.
This template is meant to be used in other templates.
`linkage` indicates the wanted xpcom linkage type. Valid values are
'dependent', 'standalone' or None. 'dependent' is the default. It is
used for e.g. XPCOM components and executables with direct dependencies
on libxul. Most executables should use the 'standalone' linkage, which
uses the standalone XPCOM glue to load libxul. None means no XPCOM glue
or libxul linkage at all.
`msvcrt` indicates which Microsoft Visual Studio CRT, for Windows build,
ought to be linked: 'static' or 'dynamic'.
`mozglue` indicates whether to link against the mozglue library, and if
so, what linkage to apply. Valid values are None (mozglue not linked),
'program' (mozglue linked to an executable program), or 'library' (mozglue
linked to a shared library).
'''
if msvcrt == 'dynamic' or CONFIG['OS_ARCH'] != 'WINNT':
xpcomglue = 'xpcomglue'
elif msvcrt == 'static':
USE_STATIC_LIBS = True
xpcomglue = 'xpcomglue_staticruntime'
if not CONFIG['GNU_CC']:
mozglue = None
else:
error('msvcrt must be "dynamic" or "static"')

if linkage == 'dependent':
USE_LIBS += [
'mozalloc',
'nspr',
'%s_s' % xpcomglue,
'xul',
]
elif linkage == 'standalone':
DEFINES['XPCOM_GLUE'] = True

USE_LIBS += [
xpcomglue,
]
elif linkage != None:
error('`linkage` must be "dependent", "standalone" or None')

if mozglue:
if CONFIG['JS_STANDALONE']:
pass
elif CONFIG['MOZ_CRT']:
if msvcrt == 'dynamic':
USE_LIBS += ['mozcrt']
elif msvcrt == 'static':
USE_LIBS += ['mozglue']
else:
error('`msvcrt` must be "dynamic" or "static"')
else:
LDFLAGS += CONFIG['MOZ_GLUE_WRAP_LDFLAGS']
if mozglue == 'program':
USE_LIBS += ['mozglue']
if CONFIG['MOZ_GLUE_IN_PROGRAM']:
if CONFIG['GNU_CC']:
LDFLAGS += ['-rdynamic']
if CONFIG['MOZ_MEMORY']:
USE_LIBS += ['memory']
if CONFIG['MOZ_LINKER']:
OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
elif mozglue == 'library':
if not CONFIG['MOZ_GLUE_IN_PROGRAM']:
USE_LIBS += ['mozglue']
else:
error('`mozglue` must be "program" or "library"')


@template
def GeckoProgram(name, linkage='standalone', **kwargs):
'''Template for program executables related to Gecko.
`name` identifies the executable base name.
See the documentation for `GeckoBinary` for other possible arguments,
with the notable difference that the default for `linkage` is 'standalone'.
'''
Program(name)

GeckoBinary(linkage=linkage, mozglue='program', **kwargs)


@template
def GeckoSimplePrograms(names, **kwargs):
'''Template for simple program executables related to Gecko.
`names` identifies the executable base names for each executable.
See the documentation for `GeckoBinary` for other possible arguments.
'''
SimplePrograms(names)

GeckoBinary(mozglue='program', **kwargs)


@template
def GeckoCppUnitTests(names, **kwargs):
'''Template for C++ unit tests related to Gecko.
`names` identifies the executable base names for each executable.
See the documentation for `GeckoBinary` for other possible arguments.
'''
CppUnitTests(names)

GeckoBinary(mozglue='program', **kwargs)


@template
def GeckoSharedLibrary(name, **kwargs):
'''Template for shared libraries related to Gecko.
`name` identifies the library base name.
See the documentation for `GeckoBinary` for other possible arguments.
'''
SharedLibrary(name)

GeckoBinary(mozglue='library', **kwargs)


@template
def GeckoFramework(name, **kwargs):
'''Template for OSX frameworks related to Gecko.
`name` identifies the library base name.
See the documentation for `GeckoBinary` for other possible arguments.
'''
Framework(name)

GeckoBinary(mozglue='library', **kwargs)


@template
def XPCOMBinaryComponent(name):
'''Template defining an XPCOM binary component for Gecko.
`name` is the name of the component.
'''
GeckoSharedLibrary(name)

IS_COMPONENT = True

26 changes: 1 addition & 25 deletions build/templates.mozbuild
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,4 @@ def HostLibrary(name):
HOST_LIBRARY_NAME = name


@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.
'''
SharedLibrary(name)

GeckoBinary()

IS_COMPONENT = True
include('gecko_templates.mozbuild')
2 changes: 0 additions & 2 deletions build/unix/elfhack/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ INTERNAL_TOOLS = 1

OS_CXXFLAGS := $(filter-out -fno-exceptions,$(OS_CXXFLAGS)) -fexceptions

WRAP_LDFLAGS=

include $(topsrcdir)/config/rules.mk

test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): %$(DLL_SUFFIX): %.$(OBJ_SUFFIX) elfhack
Expand Down
2 changes: 0 additions & 2 deletions build/win32/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# 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/.

MOZ_GLUE_LDFLAGS =

include $(topsrcdir)/config/rules.mk

ifdef WIN32_REDIST_DIR
Expand Down
5 changes: 0 additions & 5 deletions build/win32/crashinjectdll/Makefile.in

This file was deleted.

5 changes: 0 additions & 5 deletions build/win32/vmwarerecordinghelper/Makefile.in

This file was deleted.

Loading

0 comments on commit 54aee67

Please sign in to comment.