| 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/. |
| 6 |
|
| 7 |
|
| 8 |
@template |
| 9 |
def GeckoBinary(linkage="dependent", mozglue=None): |
| 10 |
"""Template for Gecko-related binaries. |
| 11 |
|
| 12 |
This template is meant to be used in other templates. |
| 13 |
|
| 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. |
| 20 |
|
| 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). |
| 25 |
""" |
| 26 |
if linkage == "dependent": |
| 27 |
USE_LIBS += [ |
| 28 |
"nspr", |
| 29 |
"xul-real", |
| 30 |
] |
| 31 |
elif linkage == "standalone": |
| 32 |
DEFINES["XPCOM_GLUE"] = True |
| 33 |
|
| 34 |
USE_LIBS += [ |
| 35 |
"xpcomglue", |
| 36 |
] |
| 37 |
elif linkage != None: |
| 38 |
error('`linkage` must be "dependent", "standalone" or None') |
| 39 |
|
| 40 |
if mozglue: |
| 41 |
if mozglue == "program": |
| 42 |
USE_LIBS += ["mozglue"] |
| 43 |
if CONFIG["MOZ_ASAN"] or CONFIG["MOZ_UBSAN"] or CONFIG["MOZ_TSAN"]: |
| 44 |
USE_LIBS += ["sanitizer-options"] |
| 45 |
DEFINES["MOZ_HAS_MOZGLUE"] = True |
| 46 |
if CONFIG["MOZ_GLUE_IN_PROGRAM"] and CONFIG["CC_TYPE"] in ("clang", "gcc"): |
| 47 |
LDFLAGS += ["-rdynamic"] |
| 48 |
elif mozglue == "library": |
| 49 |
LIBRARY_DEFINES["MOZ_HAS_MOZGLUE"] = True |
| 50 |
if not CONFIG["MOZ_GLUE_IN_PROGRAM"]: |
| 51 |
USE_LIBS += ["mozglue"] |
| 52 |
else: |
| 53 |
error('`mozglue` must be "program" or "library"') |
| 54 |
|
| 55 |
|
| 56 |
@template |
| 57 |
def GeckoProgram(name, linkage="standalone", **kwargs): |
| 58 |
"""Template for program executables related to Gecko. |
| 59 |
|
| 60 |
`name` identifies the executable base name. |
| 61 |
|
| 62 |
See the documentation for `GeckoBinary` for other possible arguments, |
| 63 |
with the notable difference that the default for `linkage` is 'standalone'. |
| 64 |
""" |
| 65 |
Program(name) |
| 66 |
|
| 67 |
kwargs.setdefault("mozglue", "program") |
| 68 |
|
| 69 |
GeckoBinary(linkage=linkage, **kwargs) |
| 70 |
|
| 71 |
|
| 72 |
@template |
| 73 |
def GeckoSimplePrograms(names, **kwargs): |
| 74 |
"""Template for simple program executables related to Gecko. |
| 75 |
|
| 76 |
`names` identifies the executable base names for each executable. |
| 77 |
|
| 78 |
See the documentation for `GeckoBinary` for other possible arguments. |
| 79 |
""" |
| 80 |
SimplePrograms(names) |
| 81 |
|
| 82 |
kwargs.setdefault("mozglue", "program") |
| 83 |
|
| 84 |
GeckoBinary(**kwargs) |
| 85 |
|
| 86 |
|
| 87 |
@template |
| 88 |
def GeckoCppUnitTests(names, **kwargs): |
| 89 |
"""Template for C++ unit tests related to Gecko. |
| 90 |
|
| 91 |
`names` identifies the executable base names for each executable. |
| 92 |
|
| 93 |
See the documentation for `GeckoBinary` for other possible arguments. |
| 94 |
""" |
| 95 |
CppUnitTests(names) |
| 96 |
|
| 97 |
kwargs.setdefault("mozglue", "program") |
| 98 |
|
| 99 |
GeckoBinary(**kwargs) |
| 100 |
|
| 101 |
|
| 102 |
@template |
| 103 |
def GeckoSharedLibrary(name, output_category=None, **kwargs): |
| 104 |
"""Template for shared libraries related to Gecko. |
| 105 |
|
| 106 |
`name` identifies the library base name. |
| 107 |
See the documentation for `GeckoBinary` for other possible arguments. |
| 108 |
""" |
| 109 |
SharedLibrary(name, output_category) |
| 110 |
|
| 111 |
kwargs.setdefault("mozglue", "library") |
| 112 |
kwargs.setdefault("linkage", None) |
| 113 |
|
| 114 |
GeckoBinary(**kwargs) |
| 115 |
|
| 116 |
|
| 117 |
@template |
| 118 |
def GeckoFramework(name, output_category=None, **kwargs): |
| 119 |
"""Template for OSX frameworks related to Gecko. |
| 120 |
|
| 121 |
`name` identifies the library base name. |
| 122 |
See the documentation for `GeckoBinary` for other possible arguments. |
| 123 |
""" |
| 124 |
Framework(name, output_category) |
| 125 |
|
| 126 |
kwargs.setdefault("mozglue", "library") |
| 127 |
kwargs.setdefault("linkage", None) |
| 128 |
|
| 129 |
GeckoBinary(**kwargs) |