Bug 1839316: part 5) Guard the "fetchpriority" attribute behind a pref. r=kershaw...
[gecko.git] / build / gecko_templates.mozbuild
blob51aae5b8703d1643efc54872d4561236dd046b69
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/.
7 @template
8 def GeckoBinary(linkage='dependent', 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     `mozglue` indicates whether to link against the mozglue library, and if
21     so, what linkage to apply. Valid values are None (mozglue not linked),
22     'program' (mozglue linked to an executable program), or 'library' (mozglue
23     linked to a shared library).
24     '''
25     if linkage == 'dependent':
26         USE_LIBS += [
27             'nspr',
28             'xul-real',
29         ]
30     elif linkage == 'standalone':
31         DEFINES['XPCOM_GLUE'] = True
33         USE_LIBS += [
34             'xpcomglue',
35         ]
36     elif linkage != None:
37         error('`linkage` must be "dependent", "standalone" or None')
39     if mozglue:
40         if mozglue == 'program':
41             USE_LIBS += ['mozglue']
42             DEFINES['MOZ_HAS_MOZGLUE'] = True
43             if CONFIG['MOZ_GLUE_IN_PROGRAM'] and CONFIG['CC_TYPE'] in ('clang', 'gcc'):
44                 LDFLAGS += ['-rdynamic']
45         elif mozglue == 'library':
46             LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = True
47             if not CONFIG['MOZ_GLUE_IN_PROGRAM']:
48                 USE_LIBS += ['mozglue']
49         else:
50             error('`mozglue` must be "program" or "library"')
53 @template
54 def GeckoProgram(name, linkage='standalone', **kwargs):
55     '''Template for program executables related to Gecko.
57     `name` identifies the executable base name.
59     See the documentation for `GeckoBinary` for other possible arguments,
60     with the notable difference that the default for `linkage` is 'standalone'.
61     '''
62     Program(name)
64     kwargs.setdefault('mozglue', 'program')
66     GeckoBinary(linkage=linkage, **kwargs)
69 @template
70 def GeckoSimplePrograms(names, **kwargs):
71     '''Template for simple program executables related to Gecko.
73     `names` identifies the executable base names for each executable.
75     See the documentation for `GeckoBinary` for other possible arguments.
76     '''
77     SimplePrograms(names)
79     kwargs.setdefault('mozglue', 'program')
81     GeckoBinary(**kwargs)
84 @template
85 def GeckoCppUnitTests(names, **kwargs):
86     '''Template for C++ unit tests related to Gecko.
88     `names` identifies the executable base names for each executable.
90     See the documentation for `GeckoBinary` for other possible arguments.
91     '''
92     CppUnitTests(names)
94     kwargs.setdefault('mozglue', 'program')
96     GeckoBinary(**kwargs)
99 @template
100 def GeckoSharedLibrary(name, output_category=None, **kwargs):
101     '''Template for shared libraries related to Gecko.
103     `name` identifies the library base name.
104     See the documentation for `GeckoBinary` for other possible arguments.
105     '''
106     SharedLibrary(name, output_category)
108     kwargs.setdefault('mozglue', 'library')
110     GeckoBinary(**kwargs)
113 @template
114 def GeckoFramework(name, output_category=None, **kwargs):
115     '''Template for OSX frameworks related to Gecko.
117     `name` identifies the library base name.
118     See the documentation for `GeckoBinary` for other possible arguments.
119     '''
120     Framework(name, output_category)
122     kwargs.setdefault('mozglue', 'library')
124     GeckoBinary(**kwargs)