summaryrefslogtreecommitdiffstats
path: root/js/src/moz.build
blob: 422bb9d40f695479a4c34ba008cf9d9dce728329 (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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
# -*- 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/.

include("js-config.mozbuild")
include("js-cxxflags.mozbuild")

# Directory metadata
component_engine = ("Core", "JavaScript Engine")
component_gc = ("Core", "JavaScript: GC")
component_intl = ("Core", "JavaScript: Internationalization API")
component_jit = ("Core", "JavaScript Engine: JIT")
component_stl = ("Core", "JavaScript: Standard Library")
component_wasm = ("Core", "Javascript: Web Assembly")

FILES_PER_UNIFIED_FILE = 6

# Prevent redefining FILES_PER_UNIFIED_FILE in each sub-directory of js. This
# will not escape this directory.
export("FILES_PER_UNIFIED_FILE")

with Files("*"):
    BUG_COMPONENT = component_engine

with Files("wasm/**"):
    BUG_COMPONENT = component_wasm
with Files("builtin/**"):
    BUG_COMPONENT = component_stl
with Files("ctypes/**"):
    BUG_COMPONENT = ("Core", "js-ctypes")
with Files("gc/**"):
    BUG_COMPONENT = component_gc
with Files("jit/**"):
    BUG_COMPONENT = component_jit

# File-specific metadata
for gcfile in ["devtools/rootAnalysis", "devtools/gc-ubench", "devtools/gctrace"]:
    with Files(gcfile):
        BUG_COMPONENT = component_gc

for stlfile in ["jsdate.*", "jsnum.*"]:
    with Files(stlfile):
        BUG_COMPONENT = component_stl

with Files("builtin/intl/*"):
    BUG_COMPONENT = component_intl

if not CONFIG["JS_DISABLE_SHELL"]:
    DIRS += [
        "rust",
        "shell",
    ]

    TEST_DIRS += [
        "gdb",
        "jsapi-tests",
        "tests",
    ]

    if CONFIG["FUZZING_INTERFACES"]:
        TEST_DIRS += [
            "fuzz-tests",
        ]

if CONFIG["FUZZING_INTERFACES"] and CONFIG["LIBFUZZER"]:
    # In addition to regular coverage provided by trace-pc-guard,
    # LibFuzzer can use trace-cmp to instrument various compare instructions.
    # Only use this feature on source files that do a lot of constant
    # comparisons that would otherwise be hard to guess by LibFuzzer,
    # as it comes with a larger overhead (requires -use_value_profile=1).
    include("/tools/fuzzing/libfuzzer-flags.mozbuild")

    # Any files that are targeted by LibFuzzer should be added here so they can
    # be built with the necessary instrumentation flags, rather than just building
    # the whole JS engine with instrumentation, to reduce the amount of noise.
    SOURCES += [
        "vm/StructuredClone.cpp",
    ]
    SOURCES["vm/StructuredClone.cpp"].flags += libfuzzer_flags
else:
    UNIFIED_SOURCES += [
        "vm/StructuredClone.cpp",
    ]

if CONFIG["FUZZING_JS_FUZZILLI"]:
    # When building for Fuzzilli, we instrument everything with standard
    # trace-pc instrumentation.
    include("/tools/fuzzing/libfuzzer-config.mozbuild")

CONFIGURE_DEFINE_FILES += [
    "js-confdefs.h",
]

if not CONFIG["JS_STANDALONE"]:
    CONFIGURE_SUBST_FILES += [
        "../../config/autoconf-js.mk",
        "../../config/emptyvars-js.mk",
    ]

CONFIGURE_DEFINE_FILES += [
    "js-config.h",
]

if CONFIG["HAVE_DTRACE"]:
    GeneratedFile("javascript-trace.h")
    EXPORTS += ["!javascript-trace.h"]

# Changes to internal header files, used externally, massively slow down
# browser builds.  Don't add new files here unless you know what you're
# doing!
EXPORTS += [
    "!js-config.h",
    "jsapi.h",
    "jsfriendapi.h",
    "jspubtd.h",
    "jstypes.h",
]

EXPORTS.js += [
    "!../public/PrefsGenerated.h",
    "../public/AllocationLogging.h",
    "../public/AllocationRecording.h",
    "../public/AllocPolicy.h",
    "../public/Array.h",
    "../public/ArrayBuffer.h",
    "../public/ArrayBufferMaybeShared.h",
    "../public/BigInt.h",
    "../public/BuildId.h",
    "../public/CallAndConstruct.h",
    "../public/CallArgs.h",
    "../public/CallNonGenericMethod.h",
    "../public/CharacterEncoding.h",
    "../public/Class.h",
    "../public/ColumnNumber.h",
    "../public/ComparisonOperators.h",
    "../public/CompilationAndEvaluation.h",
    "../public/CompileOptions.h",
    "../public/Context.h",
    "../public/ContextOptions.h",
    "../public/Conversions.h",
    "../public/Date.h",
    "../public/Debug.h",
    "../public/Equality.h",
    "../public/ErrorInterceptor.h",
    "../public/ErrorReport.h",
    "../public/Exception.h",
    "../public/ForOfIterator.h",
    "../public/GCAnnotations.h",
    "../public/GCAPI.h",
    "../public/GCHashTable.h",
    "../public/GCPolicyAPI.h",
    "../public/GCTypeMacros.h",
    "../public/GCVariant.h",
    "../public/GCVector.h",
    "../public/GlobalObject.h",
    "../public/HashTable.h",
    "../public/HeapAPI.h",
    "../public/HelperThreadAPI.h",
    "../public/Id.h",
    "../public/Initialization.h",
    "../public/Interrupt.h",
    "../public/Iterator.h",
    "../public/JitCodeAPI.h",
    "../public/JSON.h",
    "../public/LocaleSensitive.h",
    "../public/MapAndSet.h",
    "../public/MemoryCallbacks.h",
    "../public/MemoryFunctions.h",
    "../public/MemoryMetrics.h",
    "../public/Modules.h",
    "../public/Object.h",
    "../public/Prefs.h",
    "../public/Principals.h",
    "../public/Printer.h",
    "../public/Printf.h",
    "../public/ProfilingCategory.h",
    "../public/ProfilingFrameIterator.h",
    "../public/ProfilingStack.h",
    "../public/Promise.h",
    "../public/PropertyAndElement.h",
    "../public/PropertyDescriptor.h",
    "../public/PropertySpec.h",
    "../public/ProtoKey.h",
    "../public/Proxy.h",
    "../public/Realm.h",
    "../public/RealmIterators.h",
    "../public/RealmOptions.h",
    "../public/RefCounted.h",
    "../public/RegExp.h",
    "../public/RegExpFlags.h",
    "../public/Result.h",
    "../public/RootingAPI.h",
    "../public/SavedFrameAPI.h",
    "../public/ScalarType.h",
    "../public/ScriptPrivate.h",
    "../public/ShadowRealmCallbacks.h",
    "../public/SharedArrayBuffer.h",
    "../public/SliceBudget.h",
    "../public/SourceText.h",
    "../public/StableStringChars.h",
    "../public/Stack.h",
    "../public/StreamConsumer.h",
    "../public/String.h",
    "../public/StructuredClone.h",
    "../public/Symbol.h",
    "../public/TelemetryTimers.h",
    "../public/TraceKind.h",
    "../public/TracingAPI.h",
    "../public/Transcoding.h",
    "../public/TypeDecls.h",
    "../public/UbiNode.h",
    "../public/UbiNodeBreadthFirst.h",
    "../public/UbiNodeCensus.h",
    "../public/UbiNodeDominatorTree.h",
    "../public/UbiNodePostOrder.h",
    "../public/UbiNodeShortestPaths.h",
    "../public/UbiNodeUtils.h",
    "../public/UniquePtr.h",
    "../public/Utility.h",
    "../public/Value.h",
    "../public/ValueArray.h",
    "../public/Vector.h",
    "../public/WaitCallbacks.h",
    "../public/Warnings.h",
    "../public/WasmFeatures.h",
    "../public/WasmModule.h",
    "../public/WeakMap.h",
    "../public/WeakMapPtr.h",
    "../public/Wrapper.h",
    "../public/WrapperCallbacks.h",
    "../public/Zone.h",
]

# This lives in mozglue/baseprofiler but we re-publish ourselves to support
# standalone SpiderMonkey configurations.
EXPORTS.js += [
    "!/mozglue/baseprofiler/public/ProfilingCategoryList.h",
]

# Public APIs that are experimental: the precise contour of the APIs may still
# change, but they're at least plausible first passes at designing something.
# We expose them as-is, buyer beware.
EXPORTS.js.experimental += [
    "../public/experimental/CodeCoverage.h",
    "../public/experimental/CompileScript.h",
    "../public/experimental/CTypes.h",
    "../public/experimental/Intl.h",
    "../public/experimental/JitInfo.h",
    "../public/experimental/JSStencil.h",
    "../public/experimental/PCCountProfiling.h",
    "../public/experimental/SourceHook.h",
    "../public/experimental/TypedData.h",
]

# Friend APIs are APIs that either basically SpiderMonkey-internal, or their
# contours are gross and terrible -- but the functionality is too important to
# some embedder (often, Gecko) to just not expose anything or to agonize through
# a clean design.  Use this only if you absolutely must, and feel free to
# propose clean APIs to replace what's here!
EXPORTS.js.friend += [
    "../public/friend/DOMProxy.h",
    "../public/friend/DumpFunctions.h",
    "../public/friend/ErrorMessages.h",
    "../public/friend/ErrorNumbers.msg",
    "../public/friend/JSMEnvironment.h",
    "../public/friend/PerformanceHint.h",
    "../public/friend/StackLimits.h",
    "../public/friend/UsageStatistics.h",
    "../public/friend/WindowProxy.h",
    "../public/friend/XrayJitInfo.h",
]

# "Shadow" API defines the internal layout of public JSAPI types like |JSObject|
# and |JSString|, so that other *inline* public functions can efficiently access
# their internal fields.
#
# Embedders must never include these headers themselves or use their contents.
# These internal layout details are publicly exposed for access *only* so that
# other public API definitions may use them.
#
# When adding new shadow structure definitions (or new fields/static constants
# to existing structures) for access by inline methods, make sure to add static
# asserts to the original header file to ensure that offsets and duplicated
# constants are consistent.  (Long term, it might be worth figuring out some way
# to back actual implementations *with* these shadow definitions to eliminate
# this requirement.)
EXPORTS.js.shadow += [
    "../public/shadow/Function.h",
    "../public/shadow/Object.h",
    "../public/shadow/Realm.h",
    "../public/shadow/Shape.h",
    "../public/shadow/String.h",
    "../public/shadow/Symbol.h",
    "../public/shadow/Zone.h",
]

UNIFIED_SOURCES += [
    "builtin/Array.cpp",
    "builtin/AtomicsObject.cpp",
    "builtin/BigInt.cpp",
    "builtin/Boolean.cpp",
    "builtin/DataViewObject.cpp",
    "builtin/Eval.cpp",
    "builtin/FinalizationRegistryObject.cpp",
    "builtin/JSON.cpp",
    "builtin/MapObject.cpp",
    "builtin/ModuleObject.cpp",
    "builtin/Object.cpp",
    "builtin/ParseRecordObject.cpp",
    "builtin/Profilers.cpp",
    "builtin/Promise.cpp",
    "builtin/Reflect.cpp",
    "builtin/ReflectParse.cpp",
    "builtin/ShadowRealm.cpp",
    "builtin/String.cpp",
    "builtin/Symbol.cpp",
    "builtin/TestingFunctions.cpp",
    "builtin/TestingUtility.cpp",
    "builtin/WeakMapObject.cpp",
    "builtin/WeakRefObject.cpp",
    "builtin/WeakSetObject.cpp",
    "builtin/WrappedFunctionObject.cpp",
    "ds/Bitmap.cpp",
    "ds/LifoAlloc.cpp",
    "jsapi.cpp",
    "jsdate.cpp",
    "jsexn.cpp",
    "jsfriendapi.cpp",
    "jsnum.cpp",
    "proxy/BaseProxyHandler.cpp",
    "proxy/CrossCompartmentWrapper.cpp",
    "proxy/DeadObjectProxy.cpp",
    "proxy/DOMProxy.cpp",
    "proxy/OpaqueCrossCompartmentWrapper.cpp",
    "proxy/Proxy.cpp",
    "proxy/ScriptedProxyHandler.cpp",
    "proxy/SecurityWrapper.cpp",
    "proxy/Wrapper.cpp",
    "threading/Mutex.cpp",
    "threading/ProtectedData.cpp",
    "threading/Thread.cpp",
    "vm/Activation.cpp",
    "vm/ArgumentsObject.cpp",
    "vm/ArrayBufferObject.cpp",
    "vm/ArrayBufferObjectMaybeShared.cpp",
    "vm/ArrayBufferViewObject.cpp",
    "vm/AsyncFunction.cpp",
    "vm/AsyncIteration.cpp",
    "vm/BigIntType.cpp",
    "vm/BoundFunctionObject.cpp",
    "vm/BuildId.cpp",
    "vm/BuiltinObjectKind.cpp",
    "vm/BytecodeLocation.cpp",
    "vm/BytecodeUtil.cpp",
    "vm/CallAndConstruct.cpp",
    "vm/CallNonGenericMethod.cpp",
    "vm/CharacterEncoding.cpp",
    "vm/CodeCoverage.cpp",
    "vm/Compartment.cpp",
    "vm/CompilationAndEvaluation.cpp",
    "vm/Compression.cpp",
    "vm/ConcurrentDelazification.cpp",
    "vm/DateTime.cpp",
    "vm/EnvironmentObject.cpp",
    "vm/EqualityOperations.cpp",
    "vm/ErrorMessages.cpp",
    "vm/ErrorObject.cpp",
    "vm/ErrorReporting.cpp",
    "vm/Exception.cpp",
    "vm/ForOfIterator.cpp",
    "vm/FrameIter.cpp",
    "vm/FunctionFlags.cpp",
    "vm/GeckoProfiler.cpp",
    "vm/GeneratorObject.cpp",
    "vm/GetterSetter.cpp",
    "vm/GlobalObject.cpp",
    "vm/HelperThreads.cpp",
    "vm/Id.cpp",
    "vm/Initialization.cpp",
    "vm/InternalThreadPool.cpp",
    "vm/InvalidatingFuse.cpp",
    "vm/Iteration.cpp",
    "vm/Iterator.cpp",
    "vm/JitActivation.cpp",
    "vm/JSAtomUtils.cpp",
    "vm/JSContext.cpp",
    "vm/JSFunction.cpp",
    "vm/JSObject.cpp",
    "vm/JSONParser.cpp",
    "vm/JSONPrinter.cpp",
    "vm/JSScript.cpp",
    "vm/List.cpp",
    "vm/MemoryMetrics.cpp",
    "vm/Modules.cpp",
    "vm/NativeObject.cpp",
    "vm/OffThreadPromiseRuntimeState.cpp",
    "vm/PIC.cpp",
    "vm/PlainObject.cpp",
    "vm/Prefs.cpp",
    "vm/Printer.cpp",
    "vm/Probes.cpp",
    "vm/PromiseLookup.cpp",
    "vm/PropertyAndElement.cpp",
    "vm/PropertyDescriptor.cpp",
    "vm/PropMap.cpp",
    "vm/ProxyObject.cpp",
    "vm/Realm.cpp",
    "vm/RealmFuses.cpp",
    "vm/RegExpObject.cpp",
    "vm/RegExpStatics.cpp",
    "vm/Runtime.cpp",
    "vm/SavedStacks.cpp",
    "vm/Scope.cpp",
    "vm/SelfHosting.cpp",
    "vm/Shape.cpp",
    "vm/ShapeZone.cpp",
    "vm/SharedArrayObject.cpp",
    "vm/SharedImmutableStringsCache.cpp",
    "vm/SharedScriptDataTableHolder.cpp",
    "vm/SourceHook.cpp",
    "vm/Stack.cpp",
    "vm/StaticStrings.cpp",
    "vm/StencilCache.cpp",
    "vm/StencilObject.cpp",
    "vm/StringType.cpp",
    "vm/SymbolType.cpp",
    "vm/TaggedProto.cpp",
    "vm/ThrowMsgKind.cpp",
    "vm/Time.cpp",
    "vm/ToSource.cpp",
    "vm/TypedArrayObject.cpp",
    "vm/UbiNode.cpp",
    "vm/UbiNodeCensus.cpp",
    "vm/UbiNodeShortestPaths.cpp",
    "vm/UsageStatistics.cpp",
    "vm/Value.cpp",
    "vm/Warnings.cpp",
    "vm/Watchtower.cpp",
    "vm/WellKnownAtom.cpp",
    "vm/WindowProxy.cpp",
    "vm/Xdr.cpp",
]

# builtin/RegExp.cpp cannot be built in unified mode because it causes huge
#   win32 test slowdowns
# jsmath.cpp cannot be built in unified mode because it needs to re-#define the
#   RtlGenRandom declaration's calling convention in <ntsecapi.h> on Windows.
# vm/Interpreter.cpp is gigantic and destroys incremental build times for any
#   files unlucky enough to be unified with it.
SOURCES += [
    "builtin/RegExp.cpp",
    "jsmath.cpp",
    "vm/Interpreter.cpp",
    "vm/ProfilingStack.cpp",
]

if CONFIG["ENABLE_PORTABLE_BASELINE_INTERP"]:
    SOURCES += [
        "vm/PortableBaselineInterpret.cpp",
    ]

if CONFIG["ENABLE_RECORD_TUPLE"]:
    UNIFIED_SOURCES += [
        "builtin/RecordObject.cpp",
        "builtin/TupleObject.cpp",
        "vm/RecordTupleShared.cpp",
        "vm/RecordType.cpp",
        "vm/TupleType.cpp",
    ]

if CONFIG["JS_HAS_INTL_API"]:
    UNIFIED_SOURCES += [
        "builtin/intl/Collator.cpp",
        "builtin/intl/CommonFunctions.cpp",
        "builtin/intl/DateTimeFormat.cpp",
        "builtin/intl/DisplayNames.cpp",
        "builtin/intl/IntlObject.cpp",
        "builtin/intl/LanguageTag.cpp",
        "builtin/intl/ListFormat.cpp",
        "builtin/intl/Locale.cpp",
        "builtin/intl/NumberFormat.cpp",
        "builtin/intl/PluralRules.cpp",
        "builtin/intl/RelativeTimeFormat.cpp",
        "builtin/intl/Segmenter.cpp",
        "builtin/intl/SharedIntlData.cpp",
    ]

if CONFIG["MOZ_INSTRUMENTS"]:
    SOURCES += [
        "devtools/Instruments.cpp",
    ]

if CONFIG["OS_ARCH"] == "WINNT":
    OS_LIBS += [
        "advapi32",
    ]
    UNIFIED_SOURCES += [
        "threading/windows/CpuCount.cpp",
        "threading/windows/WindowsThread.cpp",
    ]
# WASI hasn't supported thread yet so noop implementation is used.
elif CONFIG["OS_ARCH"] == "WASI":
    UNIFIED_SOURCES += [
        "threading/noop/CpuCount.cpp",
        "threading/noop/NoopThread.cpp",
    ]
else:
    UNIFIED_SOURCES += [
        "threading/posix/CpuCount.cpp",
        "threading/posix/PosixThread.cpp",
    ]

if CONFIG["JS_HAS_INTL_API"] and CONFIG["MOZ_ICU4X"]:
    LOCAL_INCLUDES += [
        "/intl/icu_capi/c/include",
    ]

if CONFIG["JS_HAS_CTYPES"]:
    SOURCES += [
        "ctypes/CTypes.cpp",
        "ctypes/Library.cpp",
    ]
    if not CONFIG["MOZ_SYSTEM_FFI"]:
        LOCAL_INCLUDES += [
            "!ctypes/libffi/include",
            "ctypes/libffi/src/%s" % CONFIG["FFI_TARGET_DIR"],
        ]

if CONFIG["MOZ_VTUNE"]:
    SOURCES += [
        "vtune/ittnotify_static.c",
        "vtune/jitprofiling.c",
        "vtune/VTuneWrapper.cpp",
    ]
    SOURCES["vtune/ittnotify_static.c"].flags += [
        "-Wno-varargs",
        "-Wno-sign-compare",
        "-Wno-unknown-pragmas",
    ]
    if CONFIG["CC_TYPE"] == "gcc":
        SOURCES["vtune/ittnotify_static.c"].flags += ["-Wno-stringop-overflow"]
        if int(CONFIG["CC_VERSION"].split(".")[0]) >= 8:
            SOURCES["vtune/ittnotify_static.c"].flags += ["-Wno-stringop-truncation"]

DIRS += ["build", "debugger", "frontend", "gc", "irregexp", "jit", "util", "wasm"]

if CONFIG["JS_HAS_TEMPORAL_API"]:
    DIRS += ["builtin/temporal"]

# Bug 1739321 - clang 13+ only emits debuginfo for classes that are actually
# constructed, and we cheat in a number of cases. The flag exists at least
# back to clang 4.
if CONFIG["CC_TYPE"] == "clang":
    CXXFLAGS += ["-fstandalone-debug"]

# Bug 1722102 - This should never be enabled in Release without explicit
# security and SpiderMonkey review.
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1722102#c16
if CONFIG["ENABLE_WASM_MOZ_INTGEMM"]:
    DIRS += ["intgemm"]

if CONFIG["JS_JITSPEW"]:
    DIRS += ["zydis"]

FINAL_LIBRARY = "js"

selfhosted_inputs = [
    "../public/friend/ErrorNumbers.msg",
    # ProfilingCategoryList.h is being indirectly included, and it must be passed
    # here as an input, so it's generated before this self-hosted JS code
    # generation. Otherwise, it will intermittently fail to build.
    "!/mozglue/baseprofiler/public/ProfilingCategoryList.h",
    "builtin/TypedArrayConstants.h",
    "builtin/SelfHostingDefines.h",
    "builtin/Utilities.js",
    "builtin/Array.js",
    "builtin/AsyncFunction.js",
    "builtin/AsyncIteration.js",
    "builtin/BigInt.js",
    "builtin/Date.js",
    "builtin/Error.js",
    "builtin/Generator.js",
    "builtin/Iterator.js",
    "builtin/Map.js",
    "builtin/Number.js",
    "builtin/Object.js",
    "builtin/Promise.js",
    "builtin/Reflect.js",
    "builtin/RegExp.js",
    "builtin/RegExpGlobalReplaceOpt.h.js",
    "builtin/RegExpLocalReplaceOpt.h.js",
    "builtin/String.js",
    "builtin/Set.js",
    "builtin/Sorting.js",
    "builtin/TypedArray.js",
    "builtin/WeakMap.js",
    "builtin/WeakSet.js",
] + (
    [
        "builtin/intl/NumberingSystemsGenerated.h",
        "builtin/intl/Collator.js",
        "builtin/intl/CommonFunctions.js",
        "builtin/intl/CurrencyDataGenerated.js",
        "builtin/intl/DateTimeFormat.js",
        "builtin/intl/DisplayNames.js",
        "builtin/intl/IntlObject.js",
        "builtin/intl/ListFormat.js",
        "builtin/intl/NumberFormat.js",
        "builtin/intl/PluralRules.js",
        "builtin/intl/RelativeTimeFormat.js",
        "builtin/intl/SanctionedSimpleUnitIdentifiersGenerated.js",
        "builtin/intl/Segmenter.js",
    ]
    if CONFIG["JS_HAS_INTL_API"]
    else []
)

if CONFIG["ENABLE_RECORD_TUPLE"]:
    selfhosted_inputs += ["builtin/Tuple.js"]

# Prepare self-hosted JS code for embedding
GeneratedFile(
    "selfhosted.out.h",
    "selfhosted.js",
    script="builtin/embedjs.py",
    entry_point="generate_selfhosted",
    inputs=selfhosted_inputs,
)

GeneratedFile(
    "../public/PrefsGenerated.h",
    script="GeneratePrefs.py",
    entry_point="generate_prefs_header",
    inputs=["../../modules/libpref/init/StaticPrefList.yaml"],
)

if CONFIG["JS_HAS_CTYPES"]:
    if CONFIG["MOZ_SYSTEM_FFI"]:
        CXXFLAGS += CONFIG["MOZ_FFI_CFLAGS"]

if CONFIG["JS_HAS_INTL_API"]:
    DIRS += [
        "../../intl/bidi",
        "../../intl/components",
    ]

    USE_LIBS += ["intlcomponents"]