forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
/
templates.mozbuild
170 lines (123 loc) · 4.29 KB
/
templates.mozbuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@template
def Binary():
'''Generic template for target binaries. Meant to be used by other
templates.'''
# Add -llog by default, since we use it all over the place.
if CONFIG['OS_TARGET'] == 'Android':
OS_LIBS += ['log']
@template
def Program(name):
'''Template for program executables.'''
PROGRAM = name
Binary()
@template
def SimplePrograms(names, ext='.cpp'):
'''Template for simple program executables.
Those have a single source with the same base name as the executable.
'''
SIMPLE_PROGRAMS += names
SOURCES += ['%s%s' % (name, ext) for name in names]
Binary()
@template
def CppUnitTests(names, ext='.cpp'):
'''Template for C++ unit tests.
Those have a single source with the same base name as the executable.
'''
COMPILE_FLAGS['EXTRA_INCLUDES'] = ['-I%s/dist/include' % TOPOBJDIR,
'-I%s/dist/include/testing' % TOPOBJDIR]
CPP_UNIT_TESTS += names
SOURCES += ['%s%s' % (name, ext) for name in names]
Binary()
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def AllowCompilerWarnings():
COMPILE_FLAGS['WARNINGS_AS_ERRORS'] = []
@template
def DisableCompilerWarnings():
COMPILE_FLAGS['WARNINGS_CFLAGS'] = []
@template
def RustLibrary(name, features=None, output_category=None):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
# Some Rust build scripts compile C/C++ sources, don't error on warnings for them.
AllowCompilerWarnings()
# And furthermore, don't even show warnings for them, so they don't regress
# the Compiler Warnings build metric
# <https://developer.mozilla.org/en-US/docs/Mozilla/Performance/Automated_Performance_Testing_and_Sheriffing/Build_Metrics#compiler_warnings>.
DisableCompilerWarnings()
if features:
RUST_LIBRARY_FEATURES = features
if output_category:
RUST_LIBRARY_OUTPUT_CATEGORY = output_category
@template
def SharedLibrary(name, output_category=None):
'''Template for shared libraries.'''
Library(name)
FORCE_SHARED_LIB = True
if output_category:
SHARED_LIBRARY_OUTPUT_CATEGORY = output_category
Binary()
@template
def Framework(name, output_category=None):
'''Template for OSX Frameworks.'''
SharedLibrary(name, output_category)
IS_FRAMEWORK = True
@template
def HostProgram(name):
'''Template for build tools executables.'''
HOST_PROGRAM = name
@template
def HostSimplePrograms(names, ext='.cpp'):
'''Template for simple build tools executables.
Those have a single source with the same base name as the executable.
'''
HOST_SIMPLE_PROGRAMS += names
HOST_SOURCES += ['%s%s' % (name.replace('host_', ''), ext)
for name in names]
@template
def HostSharedLibrary(name):
'''Template for build tools libraries.'''
if name != 'clang-plugin':
error('Please make sure host shared library support is complete '
'before using for something else than the clang plugin')
HOST_LIBRARY_NAME = name
FORCE_SHARED_LIB = True
@template
def HostLibrary(name):
'''Template for build tools libraries.'''
HOST_LIBRARY_NAME = name
@template
def HostRustLibrary(name, features=None):
'''Template for host Rust libraries.'''
HostLibrary(name)
IS_RUST_LIBRARY = True
# Some Rust build scripts compile C/C++ sources, don't error on warnings for them.
AllowCompilerWarnings()
if features:
HOST_RUST_LIBRARY_FEATURES = features
@template
def DisableStlWrapping():
COMPILE_FLAGS['STL'] = []
@template
def NoVisibilityFlags():
COMPILE_FLAGS['VISIBILITY'] = []
@template
def ForceInclude(*headers):
"""Force includes a set of header files in C++ compilations"""
if CONFIG['CC_TYPE'] == 'clang-cl':
include_flag = '-FI'
else:
include_flag = '-include'
for header in headers:
CXXFLAGS += [include_flag, header]
include('gecko_templates.mozbuild')
include('test_templates.mozbuild')