Bug 1188336 - Enable Mulet TaskCluster Gbu. r=garndt
[gecko.git] / build / gecko_templates.mozbuild
blob905ce038e03b4b42facf73b57552a5559af66eee
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/.
7 @template
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).
27     '''
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']:
34             mozglue = None
35             if linkage == 'dependent':
36                 USE_LIBS += [
37                     'mozalloc_staticruntime',
38                 ]
39     else:
40         error('msvcrt must be "dynamic" or "static"')
42     if linkage == 'dependent':
43         USE_LIBS += [
44             'nspr',
45             '%s_s' % xpcomglue,
46             'xul',
47         ]
48     elif linkage == 'standalone':
49         DEFINES['XPCOM_GLUE'] = True
51         USE_LIBS += [
52             xpcomglue,
53         ]
54     elif linkage != None:
55         error('`linkage` must be "dependent", "standalone" or None')
57     if mozglue:
58         if CONFIG['MOZ_CRT']:
59             if msvcrt == 'dynamic':
60                 USE_LIBS += ['mozcrt']
61             elif msvcrt == 'static':
62                 USE_LIBS += ['mozglue']
63             else:
64                 error('`msvcrt` must be "dynamic" or "static"')
65         else:
66             LDFLAGS += CONFIG['MOZ_GLUE_WRAP_LDFLAGS']
67             if mozglue == 'program':
68                 USE_LIBS += ['mozglue']
69                 if CONFIG['MOZ_GLUE_IN_PROGRAM']:
70                     if CONFIG['GNU_CC']:
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']
79             else:
80                 error('`mozglue` must be "program" or "library"')
82     if not CONFIG['JS_STANDALONE']:
83         USE_LIBS += [
84             'fallible',
85         ]
88 @template
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'.
96     '''
97     Program(name)
99     kwargs.setdefault('mozglue', 'program')
101     GeckoBinary(linkage=linkage, **kwargs)
104 @template
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.
111     '''
112     SimplePrograms(names)
114     kwargs.setdefault('mozglue', 'program')
116     GeckoBinary(**kwargs)
119 @template
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.
126     '''
127     CppUnitTests(names)
129     kwargs.setdefault('mozglue', 'program')
131     GeckoBinary(**kwargs)
134 @template
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.
140     '''
141     SharedLibrary(name)
143     kwargs.setdefault('mozglue', 'library')
145     GeckoBinary(**kwargs)
148 @template
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.
154     '''
155     Framework(name)
157     kwargs.setdefault('mozglue', 'library')
159     GeckoBinary(**kwargs)
162 @template
163 def XPCOMBinaryComponent(name, **kwargs):
164     '''Template defining an XPCOM binary component for Gecko.
166     `name` is the name of the component.
167     '''
168     GeckoSharedLibrary(name, **kwargs)
170     IS_COMPONENT = True