summaryrefslogtreecommitdiffstats
path: root/js/moz.configure
blob: 3bbaf01a3b64990770caf8357a12e3026395a00a (plain)
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# 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/.

# /!\ Use js_option() instead of option() in this file. /!\
# =========================================================

@depends(build_project, '--help')
def building_js(build_project, help):
    return build_project == 'js'

# Exception to the rule above: JS_STANDALONE is a special option that doesn't
# want the js_option treatment. When we're done merging js/src/configure and
# top-level configure, it can go away, although the JS_STANDALONE config
# will still need to be set depending on building_js above.
option(env='JS_STANDALONE', default=building_js,
       help='Reserved for internal use')

@depends('JS_STANDALONE')
def js_standalone(value):
    if value:
        return True

set_config('JS_STANDALONE', js_standalone)
add_old_configure_assignment('JS_STANDALONE', js_standalone)

js_option('--disable-js-shell', default=building_js,
       help='Do not build the JS shell')

@depends('--disable-js-shell')
def js_disable_shell(value):
    if not value:
        return True

set_config('JS_DISABLE_SHELL', js_disable_shell)


# SpiderMonkey as a shared library, and how its symbols are exported
# ==================================================================
js_option('--disable-shared-js', default=building_js,
          help='Do not create a shared library')

js_option('--disable-export-js', default=building_js,
          help='Do not mark JS symbols as DLL exported/visible')

@depends('--disable-shared-js', '--disable-export-js')
def shared_js(shared_js, export_js):
    if shared_js:
        if not export_js:
            die('Must export JS symbols when building a shared library.')
        return True

set_config('JS_SHARED_LIBRARY', shared_js)
add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)

@depends('--disable-shared-js', '--disable-export-js')
def exportable_js_api(shared_js, export_js):
    if not shared_js and export_js:
        return True

set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)

@depends('--disable-shared-js', '--disable-export-js')
def static_js_api(shared_js, export_js):
    if not shared_js and not export_js:
        return True

set_define('STATIC_JS_API', static_js_api)

@depends('--disable-shared-js')
def static_js(value):
    if not value:
        return True

set_define('MOZ_STATIC_JS', static_js)

@deprecated_option(env='DISABLE_SHARED_JS', nargs='?')
def disable_shared_js(value):
    # DISABLE_SHARED_JS=1 gets us an empty PositiveOptionValue
    if value and not len(value):
        suggestion = '--disable-shared-js'
    else:
        suggestion = '--enable-shared-js'

    die('Setting %s is deprecated, use %s instead.',
        value.format('DISABLE_SHARED_JS'), suggestion)

@deprecated_option(env='DISABLE_EXPORT_JS', nargs='?')
def disable_export_js(value):
    # DISABLE_EXPORT_JS=1 gets us an empty PositiveOptionValue
    if value and not len(value):
        suggestion = '--disable-export-js'
    else:
        suggestion = '--enable-export-js'

    die('Setting %s is deprecated, use %s instead.',
        value.format('DISABLE_EXPORT_JS'), suggestion)


# Profiling
# =======================================================
js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
          help='Enable instruments remote profiling')

@depends('--enable-instruments', target)
def instruments(value, target):
    if value and target.os != 'OSX':
        die('--enable-instruments cannot be used when targeting %s',
            target.os)
    if value:
        return True

set_config('MOZ_INSTRUMENTS', instruments)
set_define('MOZ_INSTRUMENTS', instruments)
add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
imply_option('--enable-profiling', instruments, reason='--enable-instruments')

js_option('--enable-callgrind', env='MOZ_CALLGRIND',
          help='Enable callgrind profiling')

@depends('--enable-callgrind')
def callgrind(value):
    if value:
        return True

set_define('MOZ_CALLGRIND', callgrind)
imply_option('--enable-profiling', callgrind)

js_option('--enable-profiling', env='MOZ_PROFILING',
          help='Set compile flags necessary for using sampling profilers '
               '(e.g. shark, perf)')

@depends('--enable-profiling')
def profiling(value):
    if value:
        return True

add_old_configure_assignment('MOZ_PROFILING', profiling)

@depends(profiling, target)
def imply_vtune(value, target):
    if value and (target.kernel == 'WINNT' or (target.kernel == 'Linux' and
                                               target.os == 'GNU')):
        return True

set_config('MOZ_PROFILING', profiling)
set_define('MOZ_PROFILING', profiling)
imply_option('--enable-vtune', imply_vtune, reason='--enable-profiling')


js_option('--enable-vtune', env='MOZ_VTUNE', help='Enable vtune profiling')

@depends('--enable-vtune')
def vtune(value):
    if value:
        return True

set_config('MOZ_VTUNE', vtune)
set_define('MOZ_VTUNE', vtune)


js_option('--enable-gc-trace', env='JS_GC_TRACE',
          help='Enable tracing of allocation and finalization')

@depends('--enable-gc-trace')
def gc_trace(value):
    if value:
        return True

set_define('JS_GC_TRACE', gc_trace)


js_option('--enable-perf', env='JS_ION_PERF',
          help='Enable Linux perf integration')

@depends('--enable-perf')
def ion_perf(value):
    if value:
        return True

set_define('JS_ION_PERF', ion_perf)


js_option('--enable-more-deterministic', env='JS_MORE_DETERMINISTIC',
          help='Enable changes that make the shell more deterministic')

@depends('--enable-more-deterministic')
def more_deterministic(value):
    if value:
        return True

set_define('JS_MORE_DETERMINISTIC', more_deterministic)


# CTypes
# =======================================================
@depends(building_js, '--help')
def ctypes_default(building_js, _):
    return not building_js

js_option('--enable-ctypes', help='Enable js-ctypes',
          default=ctypes_default)

build_ctypes = depends_if('--enable-ctypes')(lambda _: True)

set_config('BUILD_CTYPES', build_ctypes)
set_define('BUILD_CTYPES', build_ctypes)
add_old_configure_assignment('BUILD_CTYPES', build_ctypes)

@depends(build_ctypes, building_js)
def js_has_ctypes(ctypes, js):
    if ctypes and js:
        return True

set_config('JS_HAS_CTYPES', js_has_ctypes)
set_define('JS_HAS_CTYPES', js_has_ctypes)
add_old_configure_assignment('JS_HAS_CTYPES', js_has_ctypes)

@depends('--enable-ctypes', '--enable-compile-environment', '--help')
def ctypes_and_compile_environment(ctypes, compile_environment, _):
    return ctypes and compile_environment

include('ffi.configure', when=ctypes_and_compile_environment)

# Support various fuzzing options
# ==============================================================
with only_when('--enable-compile-environment'):
    option('--enable-fuzzing', help='Enable fuzzing support')

    @depends('--enable-fuzzing')
    def enable_fuzzing(value):
        if value:
            return True

    @depends(enable_fuzzing,
             try_compile(body='__AFL_COMPILER;',
                         check_msg='for AFL compiler',
                         when='--enable-fuzzing'))
    def enable_libfuzzer(fuzzing, afl):
        if fuzzing and not afl:
            return True

    set_config('FUZZING', enable_fuzzing)
    set_define('FUZZING', enable_fuzzing)

    set_config('LIBFUZZER', enable_libfuzzer)
    set_define('LIBFUZZER', enable_libfuzzer)

# Initial support for new regexp engine
# ==================================================

js_option('--enable-new-regexp', default=False, help='Enable new regexp engine')

@depends('--enable-new-regexp')
def enable_new_regexp(value):
    if value:
        return True

set_config('JS_NEW_REGEXP', enable_new_regexp)
set_define('JS_NEW_REGEXP', enable_new_regexp)