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']:
35 if linkage == 'dependent':
37 'mozalloc_staticruntime',
40 error('msvcrt must be "dynamic" or "static"')
42 if linkage == 'dependent':
48 elif linkage == 'standalone':
49 DEFINES['XPCOM_GLUE'] = True
55 error('`linkage` must be "dependent", "standalone" or None')
59 if msvcrt == 'dynamic':
60 USE_LIBS += ['mozcrt']
61 elif msvcrt == 'static':
62 USE_LIBS += ['mozglue']
64 error('`msvcrt` must be "dynamic" or "static"')
66 LDFLAGS += CONFIG['MOZ_GLUE_WRAP_LDFLAGS']
67 if mozglue == 'program':
68 USE_LIBS += ['mozglue']
69 if CONFIG['MOZ_GLUE_IN_PROGRAM']:
71 LDFLAGS += ['-rdynamic']
72 if CONFIG['MOZ_MEMORY']:
73 USE_LIBS += ['memory']
74 if CONFIG['MOZ_LINKER']:
75 OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
76 elif mozglue == 'library':
77 if not CONFIG['MOZ_GLUE_IN_PROGRAM']:
78 USE_LIBS += ['mozglue']
80 error('`mozglue` must be "program" or "library"')
82 if not CONFIG['JS_STANDALONE']:
89 def GeckoProgram(name, linkage='standalone', **kwargs):
90 '''Template for program executables related to Gecko.
92 `name` identifies the executable base name.
94 See the documentation for `GeckoBinary` for other possible arguments,
95 with the notable difference that the default for `linkage` is 'standalone'.
99 kwargs.setdefault('mozglue', 'program')
101 GeckoBinary(linkage=linkage, **kwargs)
105 def GeckoSimplePrograms(names, **kwargs):
106 '''Template for simple program executables related to Gecko.
108 `names` identifies the executable base names for each executable.
110 See the documentation for `GeckoBinary` for other possible arguments.
112 SimplePrograms(names)
114 kwargs.setdefault('mozglue', 'program')
116 GeckoBinary(**kwargs)
120 def GeckoCppUnitTests(names, **kwargs):
121 '''Template for C++ unit tests related to Gecko.
123 `names` identifies the executable base names for each executable.
125 See the documentation for `GeckoBinary` for other possible arguments.
129 kwargs.setdefault('mozglue', 'program')
131 GeckoBinary(**kwargs)
135 def GeckoSharedLibrary(name, **kwargs):
136 '''Template for shared libraries related to Gecko.
138 `name` identifies the library base name.
139 See the documentation for `GeckoBinary` for other possible arguments.
143 kwargs.setdefault('mozglue', 'library')
145 GeckoBinary(**kwargs)
149 def GeckoFramework(name, **kwargs):
150 '''Template for OSX frameworks related to Gecko.
152 `name` identifies the library base name.
153 See the documentation for `GeckoBinary` for other possible arguments.
157 kwargs.setdefault('mozglue', 'library')
159 GeckoBinary(**kwargs)
163 def XPCOMBinaryComponent(name, **kwargs):
164 '''Template defining an XPCOM binary component for Gecko.
166 `name` is the name of the component.
168 GeckoSharedLibrary(name, **kwargs)