1 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 def GeckoBinary(linkage='dependent', msvcrt='dynamic', mozglue=None):
9 '''Template for Gecko-related binaries.
11 This template is meant to be used in other templates.
13 `linkage` indicates the wanted xpcom linkage type. Valid values are
14 'dependent', 'standalone' or None. 'dependent' is the default. It is
15 used for e.g. XPCOM components and executables with direct dependencies
16 on libxul. Most executables should use the 'standalone' linkage, which
17 uses the standalone XPCOM glue to load libxul. None means no XPCOM glue
18 or libxul linkage at all.
20 `msvcrt` indicates which Microsoft Visual Studio CRT, for Windows build,
21 ought to be linked: 'static' or 'dynamic'.
23 `mozglue` indicates whether to link against the mozglue library, and if
24 so, what linkage to apply. Valid values are None (mozglue not linked),
25 'program' (mozglue linked to an executable program), or 'library' (mozglue
26 linked to a shared library).
28 if msvcrt == 'dynamic' or CONFIG['OS_ARCH'] != 'WINNT':
29 xpcomglue = 'xpcomglue'
30 elif msvcrt == 'static':
31 USE_STATIC_LIBS = True
32 xpcomglue = 'xpcomglue_staticruntime'
33 if not CONFIG['GNU_CC']:
36 error('msvcrt must be "dynamic" or "static"')
38 if linkage == 'dependent':
45 elif linkage == 'standalone':
46 DEFINES['XPCOM_GLUE'] = True
52 error('`linkage` must be "dependent", "standalone" or None')
55 if CONFIG['JS_STANDALONE']:
57 elif CONFIG['MOZ_CRT']:
58 if msvcrt == 'dynamic':
59 USE_LIBS += ['mozcrt']
60 elif msvcrt == 'static':
61 USE_LIBS += ['mozglue']
63 error('`msvcrt` must be "dynamic" or "static"')
65 LDFLAGS += CONFIG['MOZ_GLUE_WRAP_LDFLAGS']
66 if mozglue == 'program':
67 USE_LIBS += ['mozglue']
68 if CONFIG['MOZ_GLUE_IN_PROGRAM']:
70 LDFLAGS += ['-rdynamic']
71 if CONFIG['MOZ_MEMORY']:
72 USE_LIBS += ['memory']
73 if CONFIG['MOZ_LINKER']:
74 OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
75 elif mozglue == 'library':
76 if not CONFIG['MOZ_GLUE_IN_PROGRAM']:
77 USE_LIBS += ['mozglue']
79 error('`mozglue` must be "program" or "library"')
83 def GeckoProgram(name, linkage='standalone', **kwargs):
84 '''Template for program executables related to Gecko.
86 `name` identifies the executable base name.
88 See the documentation for `GeckoBinary` for other possible arguments,
89 with the notable difference that the default for `linkage` is 'standalone'.
93 kwargs.setdefault('mozglue', 'program')
95 GeckoBinary(linkage=linkage, **kwargs)
99 def GeckoSimplePrograms(names, **kwargs):
100 '''Template for simple program executables related to Gecko.
102 `names` identifies the executable base names for each executable.
104 See the documentation for `GeckoBinary` for other possible arguments.
106 SimplePrograms(names)
108 kwargs.setdefault('mozglue', 'program')
110 GeckoBinary(**kwargs)
114 def GeckoCppUnitTests(names, **kwargs):
115 '''Template for C++ unit tests related to Gecko.
117 `names` identifies the executable base names for each executable.
119 See the documentation for `GeckoBinary` for other possible arguments.
123 kwargs.setdefault('mozglue', 'program')
125 GeckoBinary(**kwargs)
129 def GeckoSharedLibrary(name, **kwargs):
130 '''Template for shared libraries related to Gecko.
132 `name` identifies the library base name.
133 See the documentation for `GeckoBinary` for other possible arguments.
137 kwargs.setdefault('mozglue', 'library')
139 GeckoBinary(**kwargs)
143 def GeckoFramework(name, **kwargs):
144 '''Template for OSX frameworks related to Gecko.
146 `name` identifies the library base name.
147 See the documentation for `GeckoBinary` for other possible arguments.
151 kwargs.setdefault('mozglue', 'library')
153 GeckoBinary(**kwargs)
157 def XPCOMBinaryComponent(name, **kwargs):
158 '''Template defining an XPCOM binary component for Gecko.
160 `name` is the name of the component.
162 GeckoSharedLibrary(name, **kwargs)