summaryrefslogtreecommitdiff
path: root/src/third_party/mozjs/SConscript
blob: aa958ce14c045a11b28d4cdebcf4f2b8700c6bc6 (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
# -*- mode: python -*-

Import([
    "get_option",
    "env",
    ])

env = env.Clone()
env.InjectThirdParty(libraries=['zlib'])

env['CCFLAGS_WERROR'] = []

def removeIfPresent(lst, item):
    try:
        lst.remove(item)
    except ValueError:
        pass

for to_remove in ['-Wall', '-W', '/W3', '-Wsign-compare']:
    removeIfPresent(env['CCFLAGS'], to_remove)

# See what -D's show up in make.  The AB_CD one might change, but we're little
# endian only for now so I think it's sane
env.Prepend(CPPDEFINES=[
        'IMPL_MFBT',
        'JS_USE_CUSTOM_ALLOCATOR',
        'STATIC_JS_API=1',
        'U_NO_DEFAULT_INCLUDE_UTF_HEADERS=1',
        ])

if get_option('spider-monkey-dbg') == "on":
    env.Prepend(CPPDEFINES=[
            'DEBUG',
            'JS_DEBUG',
            'JS_GC_ZEAL',
            ])


env.Append(
    FORCEINCLUDES=[
        'js-confdefs.h'
    ],
)

if env.TargetOSIs('windows'):
    env.Append(
        CCFLAGS=[
            # 'declaration' : no matching operator delete found; memory will not be freed if
            # initialization throws an exception
            '/wd4291',

            # name" : the inline specifier cannot be used when a friend declaration refers to a
            # specialization of a function template
            '/wd4396',

            # nonstandard extension used : zero-sized array in struct/union
            '/wd4200',

            # 'identifier' : no suitable definition provided for explicit template instantiation
            # request
            '/wd4661',

            # 'operation' : unsafe mix of type 'type' and type 'type' in operation
            '/wd4805',

            # 'reinterpret_cast': conversion from 'type' to 'type' of greater size
            '/wd4312',

            # 'operator': unsafe use of type 'type' in operation
            '/wd4804',
        ],
        CXXFLAGS=[
            # TODO(SERVER-59417): Override any potentially applied
            # C++20 switch to unconditionally build in C++17 mode, at
            # least until MozJS is upgraded to an ESR that can be
            # compiled in C++20 mode.
            '/std:c++17',
        ],
    )
else:
    env.Append(
        CXXFLAGS=[
            '-Wno-non-virtual-dtor',
            '-Wno-invalid-offsetof',
            '-Wno-sign-compare',
            # TODO(SERVER-59417): Override any potentially applied
            # C++20 switch to unconditionally build in C++17 mode, at
            # least until MozJS is upgraded to an ESR that can be
            # compiled in C++20 mode.
            '-std=c++17',
        ],
    )

# js/src, js/public and mfbt are the only required sources right now, that
# could change in the future
#
# Also:
# We pre-generate configs for platforms and just check them in.  Running
# mozilla's config requires a relatively huge portion of their tree.
env.Prepend(CPPPATH=[
    'extract/js/src',
    'extract/mfbt',
    'extract/intl/icu/source/common',
    'include',
    'mongo_sources',
    'platform/' + env["TARGET_ARCH"] + "/" + env["TARGET_OS"] + "/build",
    'platform/' + env["TARGET_ARCH"] + "/" + env["TARGET_OS"] + "/include",
])

sources = [
    "mongo_sources/mongoErrorReportToString.cpp",
    "mongo_sources/freeOpToJSContext.cpp",
    "extract/js/src/builtin/RegExp.cpp",
    "extract/js/src/frontend/Parser.cpp",
    "extract/js/src/gc/StoreBuffer.cpp",
    "extract/js/src/jsarray.cpp",
    "extract/js/src/jsmath.cpp",
    "extract/js/src/mfbt/Unified_cpp_mfbt0.cpp",
    "extract/js/src/perf/pm_stub.cpp",
    "extract/js/src/util/DoubleToString.cpp",
    "extract/js/src/vm/Interpreter.cpp",
    "extract/js/src/vm/JSAtom.cpp",
    "extract/mfbt/Compression.cpp",
    "extract/mfbt/double-conversion/double-conversion/strtod.cc",
    "extract/mfbt/lz4.c",
    "extract/mozglue/misc/Printf.cpp",
    "extract/mozglue/misc/TimeStamp.cpp",
    "extract/mozglue/misc/StackWalk.cpp",
]

if env.TargetOSIs('windows'):
    sources.extend([
    "extract/mozglue/misc/ConditionVariable_windows.cpp",
    "extract/mozglue/misc/Mutex_windows.cpp",
    "extract/mozglue/misc/TimeStamp_windows.cpp",
    ])
else:
    sources.extend([
    "extract/mozglue/misc/ConditionVariable_posix.cpp",
    "extract/mozglue/misc/Mutex_posix.cpp",
    "extract/mozglue/misc/TimeStamp_posix.cpp",
    ])



sources.append( [ "extract/modules/fdlibm/{}".format(f) for f in [
        'e_acos.cpp',
        'e_acosh.cpp',
        'e_asin.cpp',
        'e_atan2.cpp',
        'e_atanh.cpp',
        'e_cosh.cpp',
        'e_exp.cpp',
        'e_hypot.cpp',
        'e_log.cpp',
        'e_log10.cpp',
        'e_log2.cpp',
        'e_pow.cpp',
        'e_sinh.cpp',
        'e_sqrt.cpp',
        'k_exp.cpp',
        's_asinh.cpp',
        's_atan.cpp',
        's_cbrt.cpp',
        's_ceil.cpp',
        's_ceilf.cpp',
        's_copysign.cpp',
        's_expm1.cpp',
        's_fabs.cpp',
        's_floor.cpp',
        's_floorf.cpp',
        's_log1p.cpp',
        's_nearbyint.cpp',
        's_rint.cpp',
        's_rintf.cpp',
        's_scalbn.cpp',
        's_tanh.cpp',
        's_trunc.cpp',
        's_truncf.cpp',
]])


if env['TARGET_ARCH'] == 'x86_64':
    sources.extend([
        "extract/js/src/jit/x86-shared/Disassembler-x86-shared.cpp",
    ])

if env.TargetOSIs('windows'):
    env.Prepend(CPPDEFINES=[
        ("_CRT_RAND_S", "1")
    ])

if env['TARGET_ARCH'] == 'x86_64':
    env.Prepend(CPPDEFINES=[
        ("WASM_HUGE_MEMORY", "1")
    ])

sources.extend(Glob('platform/' + env["TARGET_ARCH"] + "/" + env["TARGET_OS"] + "/build/*.cpp")),

# All of those unified sources come in from configure.  The files don't
# actually build individually anymore.
env.Library(
    target="mozjs",
    source=sources,
    LIBDEPS_TAGS=[
        # Depends on allocation symbols defined elsewhere
        'illegal_cyclic_or_unresolved_dependencies_allowlisted',
    ],
)