1# -*- Mode: python; 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/. 6 7include('js-config.mozbuild') 8include('js-cxxflags.mozbuild') 9 10# Directory metadata 11component_engine = ('Core', 'JavaScript Engine') 12component_gc = ('Core', 'JavaScript: GC') 13component_intl = ('Core', 'JavaScript: Internationalization API') 14component_jit = ('Core', 'JavaScript Engine: JIT') 15component_stl = ('Core', 'JavaScript: Standard Library') 16component_wasm = ('Core', 'Javascript: Web Assembly') 17 18FILES_PER_UNIFIED_FILE = 6 19 20# Prevent redefining FILES_PER_UNIFIED_FILE in each sub-directory of js. This 21# will not escape this directory. 22export('FILES_PER_UNIFIED_FILE') 23 24with Files('*'): 25 BUG_COMPONENT = component_engine 26 27with Files('wasm/**'): 28 BUG_COMPONENT = component_wasm 29with Files('builtin/**'): 30 BUG_COMPONENT = component_stl 31with Files('ctypes/**'): 32 BUG_COMPONENT = ('Core', 'js-ctypes') 33with Files('gc/**'): 34 BUG_COMPONENT = component_gc 35with Files('jit/**'): 36 BUG_COMPONENT = component_jit 37 38# File-specific metadata 39for gcfile in ['devtools/rootAnalysis', 'devtools/gc-ubench', 'devtools/gctrace']: 40 with Files(gcfile): 41 BUG_COMPONENT = component_gc 42 43for stlfile in ['jsdate.*', 'jsnum.*']: 44 with Files(stlfile): 45 BUG_COMPONENT = component_stl 46 47with Files('builtin/intl/*'): 48 BUG_COMPONENT = component_intl 49 50if CONFIG['ENABLE_WASM_CRANELIFT']: 51 CONFIGURE_SUBST_FILES += ['rust/extra-bindgen-flags'] 52 53if not CONFIG['JS_DISABLE_SHELL']: 54 DIRS += [ 55 'rust', 56 'shell', 57 ] 58 59 TEST_DIRS += [ 60 'gdb', 61 'jsapi-tests', 62 'tests', 63 ] 64 65 if CONFIG['FUZZING_INTERFACES']: 66 TEST_DIRS += [ 67 'fuzz-tests', 68 ] 69 70if CONFIG['FUZZING_INTERFACES'] and CONFIG['LIBFUZZER']: 71 # In addition to regular coverage provided by trace-pc-guard, 72 # LibFuzzer can use trace-cmp to instrument various compare instructions. 73 # Only use this feature on source files that do a lot of constant 74 # comparisons that would otherwise be hard to guess by LibFuzzer, 75 # as it comes with a larger overhead (requires -use_value_profile=1). 76 include('/tools/fuzzing/libfuzzer-flags.mozbuild') 77 78 # Any files that are targeted by LibFuzzer should be added here so they can 79 # be built with the necessary instrumentation flags, rather than just building 80 # the whole JS engine with instrumentation, to reduce the amount of noise. 81 SOURCES += [ 82 'vm/StructuredClone.cpp', 83 ] 84 SOURCES['vm/StructuredClone.cpp'].flags += libfuzzer_flags 85else: 86 UNIFIED_SOURCES += [ 87 'vm/StructuredClone.cpp', 88 ] 89 90CONFIGURE_SUBST_FILES += [ 91 'devtools/rootAnalysis/Makefile', 92] 93CONFIGURE_DEFINE_FILES += [ 94 'js-confdefs.h', 95] 96 97if not CONFIG['JS_STANDALONE']: 98 CONFIGURE_SUBST_FILES += [ 99 '../../config/autoconf-js.mk', 100 '../../config/emptyvars-js.mk', 101 ] 102 103CONFIGURE_DEFINE_FILES += [ 104 'js-config.h', 105] 106 107if CONFIG['HAVE_DTRACE']: 108 GeneratedFile('javascript-trace.h') 109 EXPORTS += ['!javascript-trace.h'] 110 111# Changes to internal header files, used externally, massively slow down 112# browser builds. Don't add new files here unless you know what you're 113# doing! 114EXPORTS += [ 115 '!js-config.h', 116 'js.msg', 117 'jsapi.h', 118 'jsfriendapi.h', 119 'jspubtd.h', 120 'jstypes.h', 121] 122 123EXPORTS.js += [ 124 '../public/AllocationRecording.h', 125 '../public/AllocPolicy.h', 126 '../public/Array.h', 127 '../public/ArrayBuffer.h', 128 '../public/ArrayBufferMaybeShared.h', 129 '../public/BigInt.h', 130 '../public/BinASTFormat.h', 131 '../public/BuildId.h', 132 '../public/CallArgs.h', 133 '../public/CallNonGenericMethod.h', 134 '../public/CharacterEncoding.h', 135 '../public/Class.h', 136 '../public/ComparisonOperators.h', 137 '../public/CompilationAndEvaluation.h', 138 '../public/CompileOptions.h', 139 '../public/ContextOptions.h', 140 '../public/Conversions.h', 141 '../public/Date.h', 142 '../public/Debug.h', 143 '../public/Equality.h', 144 '../public/ErrorReport.h', 145 '../public/Exception.h', 146 '../public/ForOfIterator.h', 147 '../public/GCAnnotations.h', 148 '../public/GCAPI.h', 149 '../public/GCHashTable.h', 150 '../public/GCPolicyAPI.h', 151 '../public/GCTypeMacros.h', 152 '../public/GCVariant.h', 153 '../public/GCVector.h', 154 '../public/HashTable.h', 155 '../public/HeapAPI.h', 156 '../public/Id.h', 157 '../public/Initialization.h', 158 '../public/JSON.h', 159 '../public/LocaleSensitive.h', 160 '../public/MemoryFunctions.h', 161 '../public/MemoryMetrics.h', 162 '../public/Modules.h', 163 '../public/OffThreadScriptCompilation.h', 164 '../public/Principals.h', 165 '../public/Printf.h', 166 '../public/ProfilingCategory.h', 167 '../public/ProfilingFrameIterator.h', 168 '../public/ProfilingStack.h', 169 '../public/Promise.h', 170 '../public/PropertyDescriptor.h', 171 '../public/PropertySpec.h', 172 '../public/ProtoKey.h', 173 '../public/Proxy.h', 174 '../public/Realm.h', 175 '../public/RealmOptions.h', 176 '../public/RefCounted.h', 177 '../public/RegExp.h', 178 '../public/RegExpFlags.h', 179 '../public/RequiredDefines.h', 180 '../public/Result.h', 181 '../public/RootingAPI.h', 182 '../public/SavedFrameAPI.h', 183 '../public/SharedArrayBuffer.h', 184 '../public/SliceBudget.h', 185 '../public/SourceText.h', 186 '../public/StableStringChars.h', 187 '../public/Stream.h', 188 '../public/StructuredClone.h', 189 '../public/SweepingAPI.h', 190 '../public/Symbol.h', 191 '../public/TraceKind.h', 192 '../public/TraceLoggerAPI.h', 193 '../public/TracingAPI.h', 194 '../public/Transcoding.h', 195 '../public/TypeDecls.h', 196 '../public/UbiNode.h', 197 '../public/UbiNodeBreadthFirst.h', 198 '../public/UbiNodeCensus.h', 199 '../public/UbiNodeDominatorTree.h', 200 '../public/UbiNodePostOrder.h', 201 '../public/UbiNodeShortestPaths.h', 202 '../public/UbiNodeUtils.h', 203 '../public/UniquePtr.h', 204 '../public/Utility.h', 205 '../public/Value.h', 206 '../public/ValueArray.h', 207 '../public/Vector.h', 208 '../public/Warnings.h', 209 '../public/WeakMapPtr.h', 210 '../public/Wrapper.h', 211] 212 213EXPORTS.js.experimental += [ 214 '../public/experimental/CodeCoverage.h', 215 '../public/experimental/SourceHook.h', 216] 217 218UNIFIED_SOURCES += [ 219 'builtin/Array.cpp', 220 'builtin/AtomicsObject.cpp', 221 'builtin/BigInt.cpp', 222 'builtin/Boolean.cpp', 223 'builtin/DataViewObject.cpp', 224 'builtin/Eval.cpp', 225 'builtin/FinalizationRegistryObject.cpp', 226 'builtin/JSON.cpp', 227 'builtin/MapObject.cpp', 228 'builtin/ModuleObject.cpp', 229 'builtin/Object.cpp', 230 'builtin/Profilers.cpp', 231 'builtin/Promise.cpp', 232 'builtin/Reflect.cpp', 233 'builtin/ReflectParse.cpp', 234 'builtin/Stream.cpp', 235 'builtin/streams/MiscellaneousOperations.cpp', 236 'builtin/streams/PipeToState.cpp', 237 'builtin/streams/PullIntoDescriptor.cpp', 238 'builtin/streams/QueueingStrategies.cpp', 239 'builtin/streams/QueueWithSizes.cpp', 240 'builtin/streams/ReadableStream.cpp', 241 'builtin/streams/ReadableStreamBYOBReader.cpp', 242 'builtin/streams/ReadableStreamDefaultController.cpp', 243 'builtin/streams/ReadableStreamDefaultControllerOperations.cpp', 244 'builtin/streams/ReadableStreamDefaultReader.cpp', 245 'builtin/streams/ReadableStreamInternals.cpp', 246 'builtin/streams/ReadableStreamOperations.cpp', 247 'builtin/streams/ReadableStreamReader.cpp', 248 'builtin/streams/StreamAPI.cpp', 249 'builtin/streams/TeeState.cpp', 250 'builtin/streams/WritableStream.cpp', 251 'builtin/streams/WritableStreamDefaultController.cpp', 252 'builtin/streams/WritableStreamDefaultControllerOperations.cpp', 253 'builtin/streams/WritableStreamDefaultWriter.cpp', 254 'builtin/streams/WritableStreamOperations.cpp', 255 'builtin/streams/WritableStreamWriterOperations.cpp', 256 'builtin/String.cpp', 257 'builtin/Symbol.cpp', 258 'builtin/TestingFunctions.cpp', 259 'builtin/TypedObject.cpp', 260 'builtin/WeakMapObject.cpp', 261 'builtin/WeakRefObject.cpp', 262 'builtin/WeakSetObject.cpp', 263 'ds/Bitmap.cpp', 264 'ds/LifoAlloc.cpp', 265 'ds/MemoryProtectionExceptionHandler.cpp', 266 'jsapi.cpp', 267 'jsdate.cpp', 268 'jsexn.cpp', 269 'jsfriendapi.cpp', 270 'jsnum.cpp', 271 'proxy/BaseProxyHandler.cpp', 272 'proxy/CrossCompartmentWrapper.cpp', 273 'proxy/DeadObjectProxy.cpp', 274 'proxy/OpaqueCrossCompartmentWrapper.cpp', 275 'proxy/Proxy.cpp', 276 'proxy/ScriptedProxyHandler.cpp', 277 'proxy/SecurityWrapper.cpp', 278 'proxy/Wrapper.cpp', 279 'threading/Mutex.cpp', 280 'threading/ProtectedData.cpp', 281 'threading/Thread.cpp', 282 'util/AllocPolicy.cpp', 283 'util/CompleteFile.cpp', 284 'util/NativeStack.cpp', 285 'util/Printf.cpp', 286 'util/StringBuffer.cpp', 287 'util/StructuredSpewer.cpp', 288 'util/Text.cpp', 289 'util/Unicode.cpp', 290 'vm/Activation.cpp', 291 'vm/ArgumentsObject.cpp', 292 'vm/ArrayBufferObject.cpp', 293 'vm/ArrayBufferObjectMaybeShared.cpp', 294 'vm/ArrayBufferViewObject.cpp', 295 'vm/AsyncFunction.cpp', 296 'vm/AsyncIteration.cpp', 297 'vm/BigIntType.cpp', 298 'vm/BuildId.cpp', 299 'vm/BytecodeLocation.cpp', 300 'vm/BytecodeUtil.cpp', 301 'vm/Caches.cpp', 302 'vm/CallNonGenericMethod.cpp', 303 'vm/CharacterEncoding.cpp', 304 'vm/CodeCoverage.cpp', 305 'vm/Compartment.cpp', 306 'vm/CompilationAndEvaluation.cpp', 307 'vm/Compression.cpp', 308 'vm/DateTime.cpp', 309 'vm/EnvironmentObject.cpp', 310 'vm/EqualityOperations.cpp', 311 'vm/ErrorObject.cpp', 312 'vm/ErrorReporting.cpp', 313 'vm/Exception.cpp', 314 'vm/ForOfIterator.cpp', 315 'vm/FrameIter.cpp', 316 'vm/FunctionFlags.cpp', 317 'vm/GeckoProfiler.cpp', 318 'vm/GeneratorObject.cpp', 319 'vm/GlobalObject.cpp', 320 'vm/HelperThreads.cpp', 321 'vm/Id.cpp', 322 'vm/Initialization.cpp', 323 'vm/Instrumentation.cpp', 324 'vm/Iteration.cpp', 325 'vm/JitActivation.cpp', 326 'vm/JSAtom.cpp', 327 'vm/JSContext.cpp', 328 'vm/JSFunction.cpp', 329 'vm/JSObject.cpp', 330 'vm/JSONParser.cpp', 331 'vm/JSONPrinter.cpp', 332 'vm/JSScript.cpp', 333 'vm/List.cpp', 334 'vm/MemoryMetrics.cpp', 335 'vm/Modules.cpp', 336 'vm/NativeObject.cpp', 337 'vm/ObjectGroup.cpp', 338 'vm/OffThreadPromiseRuntimeState.cpp', 339 'vm/OffThreadScriptCompilation.cpp', 340 'vm/PIC.cpp', 341 'vm/PlainObject.cpp', 342 'vm/Printer.cpp', 343 'vm/Probes.cpp', 344 'vm/PromiseLookup.cpp', 345 'vm/ProxyObject.cpp', 346 'vm/Realm.cpp', 347 'vm/ReceiverGuard.cpp', 348 'vm/RegExpObject.cpp', 349 'vm/RegExpStatics.cpp', 350 'vm/Runtime.cpp', 351 'vm/SavedStacks.cpp', 352 'vm/Scope.cpp', 353 'vm/SelfHosting.cpp', 354 'vm/Shape.cpp', 355 'vm/SharedArrayObject.cpp', 356 'vm/SharedImmutableStringsCache.cpp', 357 'vm/SourceHook.cpp', 358 'vm/Stack.cpp', 359 'vm/StringType.cpp', 360 'vm/SymbolType.cpp', 361 'vm/TaggedProto.cpp', 362 'vm/ThrowMsgKind.cpp', 363 'vm/Time.cpp', 364 'vm/ToSource.cpp', 365 'vm/TypedArrayObject.cpp', 366 'vm/TypeInference.cpp', 367 'vm/UbiNode.cpp', 368 'vm/UbiNodeCensus.cpp', 369 'vm/UbiNodeShortestPaths.cpp', 370 'vm/Value.cpp', 371 'vm/Warnings.cpp', 372 'vm/Xdr.cpp', 373] 374 375# builtin/RegExp.cpp cannot be built in unified mode because it causes huge 376# win32 test slowdowns 377# jsmath.cpp cannot be built in unified mode because it needs to re-#define the 378# RtlGenRandom declaration's calling convention in <ntsecapi.h> on Windows. 379# util/DoubleToString.cpp cannot be built in unified mode because we want to 380# suppress compiler warnings in third-party dtoa.c. 381# util/Utility.cpp cannot be built in unified mode because it is needed for 382# check-vanilla-allocations. 383# vm/Interpreter.cpp is gigantic and destroys incremental build times for any 384# files unlucky enough to be unified with it. 385SOURCES += [ 386 'builtin/RegExp.cpp', 387 'jsmath.cpp', 388 'util/DoubleToString.cpp', 389 'util/Utility.cpp', 390 'vm/Interpreter.cpp', 391 'vm/ProfilingStack.cpp', 392] 393 394if CONFIG['JS_HAS_INTL_API']: 395 UNIFIED_SOURCES += [ 396 'builtin/intl/Collator.cpp', 397 'builtin/intl/CommonFunctions.cpp', 398 'builtin/intl/DateTimeFormat.cpp', 399 'builtin/intl/DisplayNames.cpp', 400 'builtin/intl/IntlObject.cpp', 401 'builtin/intl/LanguageTag.cpp', 402 'builtin/intl/LanguageTagGenerated.cpp', 403 'builtin/intl/ListFormat.cpp', 404 'builtin/intl/Locale.cpp', 405 'builtin/intl/NumberFormat.cpp', 406 'builtin/intl/PluralRules.cpp', 407 'builtin/intl/RelativeTimeFormat.cpp', 408 'builtin/intl/SharedIntlData.cpp', 409 ] 410 411if CONFIG['MOZ_INSTRUMENTS']: 412 SOURCES += [ 413 'devtools/Instruments.cpp', 414 ] 415 416if CONFIG['ENABLE_TRACE_LOGGING']: 417 SOURCES += [ 418 'vm/TraceLogging.cpp', 419 'vm/TraceLoggingGraph.cpp', 420 'vm/TraceLoggingTypes.cpp', 421 ] 422 423if CONFIG['OS_ARCH'] == 'WINNT': 424 UNIFIED_SOURCES += [ 425 'threading/windows/CpuCount.cpp', 426 'threading/windows/WindowsThread.cpp', 427 ] 428else: 429 UNIFIED_SOURCES += [ 430 'threading/posix/CpuCount.cpp', 431 'threading/posix/PosixThread.cpp', 432 ] 433 434if CONFIG['JS_HAS_CTYPES']: 435 SOURCES += [ 436 'ctypes/CTypes.cpp', 437 'ctypes/Library.cpp', 438 ] 439 if not CONFIG['MOZ_SYSTEM_FFI']: 440 LOCAL_INCLUDES += [ 441 '!ctypes/libffi/include', 442 'ctypes/libffi/src/%s' % CONFIG['FFI_TARGET_DIR'], 443 ] 444 445if CONFIG['MOZ_VTUNE']: 446 SOURCES += [ 447 'vtune/ittnotify_static.c', 448 'vtune/jitprofiling.c', 449 'vtune/VTuneWrapper.cpp', 450 ] 451 SOURCES['vtune/ittnotify_static.c'].flags += [ 452 '-Wno-varargs', 453 '-Wno-unknown-pragmas' 454 ] 455 if CONFIG['CC_TYPE'] == 'gcc': 456 SOURCES['vtune/ittnotify_static.c'].flags += [ 457 '-Wno-stringop-overflow' 458 ] 459 460if not CONFIG['ENABLE_NEW_REGEXP']: 461 UNIFIED_SOURCES += [ 462 'irregexp/NativeRegExpMacroAssembler.cpp', 463 'irregexp/RegExpAST.cpp', 464 'irregexp/RegExpCharacters.cpp', 465 'irregexp/RegExpEngine.cpp', 466 'irregexp/RegExpInterpreter.cpp', 467 'irregexp/RegExpMacroAssembler.cpp', 468 'irregexp/RegExpParser.cpp', 469 'irregexp/RegExpStack.cpp', 470 ] 471 472DIRS += [ 473 'build', 474 'debugger', 475 'frontend', 476 'gc', 477 'jit', 478 'wasm', 479] + (['new-regexp'] if CONFIG['ENABLE_NEW_REGEXP'] else []) 480 481if CONFIG['JS_JITSPEW']: 482 DIRS += ['zydis'] 483 484FINAL_LIBRARY = 'js' 485 486selfhosted_inputs = [ 487 'js.msg', 488 'builtin/TypedObjectConstants.h', 489 'builtin/SelfHostingDefines.h', 490 'builtin/Utilities.js', 491 'builtin/Array.js', 492 'builtin/AsyncFunction.js', 493 'builtin/AsyncIteration.js', 494 'builtin/BigInt.js', 495 'builtin/Classes.js', 496 'builtin/Date.js', 497 'builtin/Error.js', 498 'builtin/Function.js', 499 'builtin/Generator.js', 500 'builtin/Iterator.js', 501 'builtin/Map.js', 502 'builtin/Module.js', 503 'builtin/Number.js', 504 'builtin/Object.js', 505 'builtin/Promise.js', 506 'builtin/Reflect.js', 507 'builtin/RegExp.js', 508 'builtin/RegExpGlobalReplaceOpt.h.js', 509 'builtin/RegExpLocalReplaceOpt.h.js', 510 'builtin/String.js', 511 'builtin/Set.js', 512 'builtin/Sorting.js', 513 'builtin/TypedArray.js', 514 'builtin/TypedObject.js', 515 'builtin/WeakMap.js', 516 'builtin/WeakSet.js' 517] + ([ 518 'builtin/intl/Collator.js', 519 'builtin/intl/CommonFunctions.js', 520 'builtin/intl/CurrencyDataGenerated.js', 521 'builtin/intl/DateTimeFormat.js', 522 'builtin/intl/DisplayNames.js', 523 'builtin/intl/IntlObject.js', 524 'builtin/intl/ListFormat.js', 525 'builtin/intl/NumberFormat.js', 526 'builtin/intl/PluralRules.js', 527 'builtin/intl/RelativeTimeFormat.js', 528 'builtin/intl/SanctionedSimpleUnitIdentifiersGenerated.js', 529] if CONFIG['JS_HAS_INTL_API'] else []) 530 531# Prepare self-hosted JS code for embedding 532GeneratedFile('selfhosted.out.h', 'selfhosted.js', 533 script='builtin/embedjs.py', 534 entry_point='generate_selfhosted', 535 inputs=selfhosted_inputs) 536 537if CONFIG['JS_HAS_CTYPES']: 538 if CONFIG['MOZ_SYSTEM_FFI']: 539 CXXFLAGS += CONFIG['MOZ_FFI_CFLAGS'] 540 541# Suppress warnings in third-party code. 542if CONFIG['CC_TYPE'] in ('clang', 'gcc'): 543 SOURCES['util/DoubleToString.cpp'].flags += ['-Wno-implicit-fallthrough'] 544