Bumping manifests a=b2g-bump
[gecko.git] / build / gecko_templates.mozbuild
blob9d07947ce412d5e167d6cfeaff5e78ee717085f6
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     else:
36         error('msvcrt must be "dynamic" or "static"')
38     if linkage == 'dependent':
39         USE_LIBS += [
40             'mozalloc',
41             'nspr',
42             '%s_s' % xpcomglue,
43             'xul',
44         ]
45     elif linkage == 'standalone':
46         DEFINES['XPCOM_GLUE'] = True
48         USE_LIBS += [
49             xpcomglue,
50         ]
51     elif linkage != None:
52         error('`linkage` must be "dependent", "standalone" or None')
54     if mozglue:
55         if CONFIG['JS_STANDALONE']:
56             pass
57         elif CONFIG['MOZ_CRT']:
58             if msvcrt == 'dynamic':
59                 USE_LIBS += ['mozcrt']
60             elif msvcrt == 'static':
61                 USE_LIBS += ['mozglue']
62             else:
63                 error('`msvcrt` must be "dynamic" or "static"')
64         else:
65             LDFLAGS += CONFIG['MOZ_GLUE_WRAP_LDFLAGS']
66             if mozglue == 'program':
67                 USE_LIBS += ['mozglue']
68                 if CONFIG['MOZ_GLUE_IN_PROGRAM']:
69                     if CONFIG['GNU_CC']:
70                         LDFLAGS += ['-rdynamic']
71                     if CONFIG['MOZ_MEMORY']:
72                         USE_LIBS += ['memory']
73                     if CONFIG['MOZ_LINKER']:
74                         OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
75             elif mozglue == 'library':
76                 if not CONFIG['MOZ_GLUE_IN_PROGRAM']:
77                     USE_LIBS += ['mozglue']
78             else:
79                 error('`mozglue` must be "program" or "library"')
82 @template
83 def GeckoProgram(name, linkage='standalone', **kwargs):
84     '''Template for program executables related to Gecko.
86     `name` identifies the executable base name.
88     See the documentation for `GeckoBinary` for other possible arguments,
89     with the notable difference that the default for `linkage` is 'standalone'.
90     '''
91     Program(name)
93     kwargs.setdefault('mozglue', 'program')
95     GeckoBinary(linkage=linkage, **kwargs)
98 @template
99 def GeckoSimplePrograms(names, **kwargs):
100     '''Template for simple program executables related to Gecko.
102     `names` identifies the executable base names for each executable.
104     See the documentation for `GeckoBinary` for other possible arguments.
105     '''
106     SimplePrograms(names)
108     kwargs.setdefault('mozglue', 'program')
110     GeckoBinary(**kwargs)
113 @template
114 def GeckoCppUnitTests(names, **kwargs):
115     '''Template for C++ unit tests related to Gecko.
117     `names` identifies the executable base names for each executable.
119     See the documentation for `GeckoBinary` for other possible arguments.
120     '''
121     CppUnitTests(names)
123     kwargs.setdefault('mozglue', 'program')
125     GeckoBinary(**kwargs)
128 @template
129 def GeckoSharedLibrary(name, **kwargs):
130     '''Template for shared libraries related to Gecko.
132     `name` identifies the library base name.
133     See the documentation for `GeckoBinary` for other possible arguments.
134     '''
135     SharedLibrary(name)
137     kwargs.setdefault('mozglue', 'library')
139     GeckoBinary(**kwargs)
142 @template
143 def GeckoFramework(name, **kwargs):
144     '''Template for OSX frameworks related to Gecko.
146     `name` identifies the library base name.
147     See the documentation for `GeckoBinary` for other possible arguments.
148     '''
149     Framework(name)
151     kwargs.setdefault('mozglue', 'library')
153     GeckoBinary(**kwargs)
156 @template
157 def XPCOMBinaryComponent(name, **kwargs):
158     '''Template defining an XPCOM binary component for Gecko.
160     `name` is the name of the component.
161     '''
162     GeckoSharedLibrary(name, **kwargs)
164     IS_COMPONENT = True