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/.
9 def GeckoBinary(linkage="dependent", mozglue=None):
10 """Template for Gecko-related binaries.
12 This template is meant to be used in other templates.
14 `linkage` indicates the wanted xpcom linkage type. Valid values are
15 'dependent', 'standalone' or None. 'dependent' is the default. It is
16 used for e.g. XPCOM components and executables with direct dependencies
17 on libxul. Most executables should use the 'standalone' linkage, which
18 uses the standalone XPCOM glue to load libxul. None means no XPCOM glue
19 or libxul linkage at all.
21 `mozglue` indicates whether to link against the mozglue library, and if
22 so, what linkage to apply. Valid values are None (mozglue not linked),
23 'program' (mozglue linked to an executable program), or 'library' (mozglue
24 linked to a shared library).
26 if linkage == "dependent":
31 elif linkage == "standalone":
32 DEFINES["XPCOM_GLUE"] = True
38 error('`linkage` must be "dependent", "standalone" or None')
41 if mozglue == "program":
42 USE_LIBS += ["mozglue"]
43 DEFINES["MOZ_HAS_MOZGLUE"] = True
44 if CONFIG["MOZ_GLUE_IN_PROGRAM"] and CONFIG["CC_TYPE"] in ("clang", "gcc"):
45 LDFLAGS += ["-rdynamic"]
46 elif mozglue == "library":
47 LIBRARY_DEFINES["MOZ_HAS_MOZGLUE"] = True
48 if not CONFIG["MOZ_GLUE_IN_PROGRAM"]:
49 USE_LIBS += ["mozglue"]
51 error('`mozglue` must be "program" or "library"')
55 def GeckoProgram(name, linkage="standalone", **kwargs):
56 """Template for program executables related to Gecko.
58 `name` identifies the executable base name.
60 See the documentation for `GeckoBinary` for other possible arguments,
61 with the notable difference that the default for `linkage` is 'standalone'.
65 kwargs.setdefault("mozglue", "program")
67 GeckoBinary(linkage=linkage, **kwargs)
71 def GeckoSimplePrograms(names, **kwargs):
72 """Template for simple program executables related to Gecko.
74 `names` identifies the executable base names for each executable.
76 See the documentation for `GeckoBinary` for other possible arguments.
80 kwargs.setdefault("mozglue", "program")
86 def GeckoCppUnitTests(names, **kwargs):
87 """Template for C++ unit tests related to Gecko.
89 `names` identifies the executable base names for each executable.
91 See the documentation for `GeckoBinary` for other possible arguments.
95 kwargs.setdefault("mozglue", "program")
101 def GeckoSharedLibrary(name, output_category=None, **kwargs):
102 """Template for shared libraries related to Gecko.
104 `name` identifies the library base name.
105 See the documentation for `GeckoBinary` for other possible arguments.
107 SharedLibrary(name, output_category)
109 kwargs.setdefault("mozglue", "library")
111 GeckoBinary(**kwargs)
115 def GeckoFramework(name, output_category=None, **kwargs):
116 """Template for OSX frameworks related to Gecko.
118 `name` identifies the library base name.
119 See the documentation for `GeckoBinary` for other possible arguments.
121 Framework(name, output_category)
123 kwargs.setdefault("mozglue", "library")
125 GeckoBinary(**kwargs)