1 # -*- Mode: python; 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' or CONFIG['MOZ_ASAN']:
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':
47 elif linkage == 'standalone':
48 DEFINES['XPCOM_GLUE'] = True
54 error('`linkage` must be "dependent", "standalone" or None')
57 LDFLAGS += CONFIG['MOZ_GLUE_WRAP_LDFLAGS']
58 if mozglue == 'program':
59 USE_LIBS += ['mozglue']
60 DEFINES['MOZ_HAS_MOZGLUE'] = True
61 if CONFIG['MOZ_GLUE_IN_PROGRAM']:
63 LDFLAGS += ['-rdynamic']
64 if CONFIG['MOZ_MEMORY']:
65 USE_LIBS += ['memory']
66 elif mozglue == 'library':
67 LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = True
68 if not CONFIG['MOZ_GLUE_IN_PROGRAM']:
69 USE_LIBS += ['mozglue']
71 error('`mozglue` must be "program" or "library"')
73 if not CONFIG['JS_STANDALONE']:
80 def GeckoProgram(name, linkage='standalone', **kwargs):
81 '''Template for program executables related to Gecko.
83 `name` identifies the executable base name.
85 See the documentation for `GeckoBinary` for other possible arguments,
86 with the notable difference that the default for `linkage` is 'standalone'.
90 kwargs.setdefault('mozglue', 'program')
92 GeckoBinary(linkage=linkage, **kwargs)
96 def GeckoSimplePrograms(names, **kwargs):
97 '''Template for simple program executables related to Gecko.
99 `names` identifies the executable base names for each executable.
101 See the documentation for `GeckoBinary` for other possible arguments.
103 SimplePrograms(names)
105 kwargs.setdefault('mozglue', 'program')
107 GeckoBinary(**kwargs)
111 def GeckoCppUnitTests(names, **kwargs):
112 '''Template for C++ unit tests related to Gecko.
114 `names` identifies the executable base names for each executable.
116 See the documentation for `GeckoBinary` for other possible arguments.
120 kwargs.setdefault('mozglue', 'program')
122 GeckoBinary(**kwargs)
126 def GeckoSharedLibrary(name, **kwargs):
127 '''Template for shared libraries related to Gecko.
129 `name` identifies the library base name.
130 See the documentation for `GeckoBinary` for other possible arguments.
134 kwargs.setdefault('mozglue', 'library')
136 GeckoBinary(**kwargs)
140 def GeckoFramework(name, **kwargs):
141 '''Template for OSX frameworks related to Gecko.
143 `name` identifies the library base name.
144 See the documentation for `GeckoBinary` for other possible arguments.
148 kwargs.setdefault('mozglue', 'library')
150 GeckoBinary(**kwargs)
154 def XPCOMBinaryComponent(name):
155 '''Template defining an XPCOM binary component for Gecko.
157 `name` is the name of the component.
159 GeckoSharedLibrary(name)