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
7# Directory metadata
8component_engine = ('Core', 'JavaScript Engine')
9component_gc     = ('Core', 'JavaScript: GC')
10component_intl   = ('Core', 'JavaScript: Internationalization API')
11component_jit    = ('Core', 'JavaScript Engine: JIT')
12component_stl    = ('Core', 'JavaScript: Standard Library')
13
14FILES_PER_UNIFIED_FILE = 6
15
16with Files('../public/**'):
17    BUG_COMPONENT = component_engine
18with Files('*'):
19    BUG_COMPONENT = component_engine
20
21with Files('wasm/**'):
22    BUG_COMPONENT = component_jit
23with Files('builtin/**'):
24    BUG_COMPONENT = component_stl
25with Files('ctypes/**'):
26    BUG_COMPONENT = ('Core', 'js-ctypes')
27with Files('gc/**'):
28    BUG_COMPONENT = component_gc
29with Files('jit/**'):
30    BUG_COMPONENT = component_jit
31
32# File-specific metadata
33for gcfile in ['jsgc*', 'devtools/rootAnalysis', 'devtools/gc-ubench', 'devtools/gctrace']:
34    with Files(gcfile):
35        BUG_COMPONENT = component_gc
36for header in ('GCAnnotations.h', 'GCAPI.h', 'HeapAPI.h', 'RootingAPI.h', 'SliceBudget.h', 'SweepingAPI.h', 'TraceKind.h', 'TracingAPI.h', 'WeakMapPtr.h'):
37    with Files('../public/' + header):
38        BUG_COMPONENT = component_gc
39
40for stlfile in ['jsarray.*', 'jsbool*', 'jsdate.*', 'jsnum.*', 'json.*', 'jsstr.*']:
41    with Files(stlfile):
42        BUG_COMPONENT = component_stl
43
44with Files('builtin/Intl*'):
45    BUG_COMPONENT = component_intl
46with Files('builtin/make_intl_data.py'):
47    BUG_COMPONENT = component_intl
48
49with Files('../public/TrackedOptimizationInfo.h'):
50    BUG_COMPONENT = component_jit
51
52
53if CONFIG['JS_BUNDLED_EDITLINE']:
54    DIRS += ['editline']
55
56if not CONFIG['JS_DISABLE_SHELL']:
57    DIRS += ['shell']
58
59TEST_DIRS += ['jsapi-tests', 'tests', 'gdb']
60
61CONFIGURE_SUBST_FILES += [
62    'devtools/rootAnalysis/Makefile',
63    'js-config',
64    'js.pc',
65]
66CONFIGURE_DEFINE_FILES += [
67    'js-confdefs.h',
68]
69
70if not CONFIG['JS_STANDALONE']:
71    LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = True
72
73    CONFIGURE_SUBST_FILES += [
74        '../../config/autoconf-js.mk',
75        '../../config/emptyvars-js.mk',
76    ]
77
78CONFIGURE_DEFINE_FILES += [
79    'js-config.h',
80]
81
82if CONFIG['HAVE_DTRACE']:
83    GENERATED_FILES += ['javascript-trace.h']
84
85    EXPORTS += ['!javascript-trace.h']
86
87# Changes to internal header files, used externally, massively slow down
88# browser builds.  Don't add new files here unless you know what you're
89# doing!
90EXPORTS += [
91    '!js-config.h',
92    'js.msg',
93    'jsalloc.h',
94    'jsapi.h',
95    'jsbytecode.h',
96    'jsclist.h',
97    'jscpucfg.h',
98    'jsfriendapi.h',
99    'jsprf.h',
100    'jsprototypes.h',
101    'jspubtd.h',
102    'jstypes.h',
103    'jsversion.h',
104    'jswrapper.h',
105    'perf/jsperf.h',
106]
107
108# If you add a header here, add it to js/src/jsapi-tests/testIntTypesABI.cpp so
109# that we ensure we don't over-expose our internal integer typedefs.  Note that
110# LegacyIntTypes.h below is deliberately exempted from this requirement.
111EXPORTS.js += [
112    '../public/CallArgs.h',
113    '../public/CallNonGenericMethod.h',
114    '../public/CharacterEncoding.h',
115    '../public/Class.h',
116    '../public/Conversions.h',
117    '../public/Date.h',
118    '../public/Debug.h',
119    '../public/GCAnnotations.h',
120    '../public/GCAPI.h',
121    '../public/GCHashTable.h',
122    '../public/GCPolicyAPI.h',
123    '../public/GCVariant.h',
124    '../public/GCVector.h',
125    '../public/HashTable.h',
126    '../public/HeapAPI.h',
127    '../public/Id.h',
128    '../public/Initialization.h',
129    '../public/LegacyIntTypes.h',
130    '../public/MemoryMetrics.h',
131    '../public/Principals.h',
132    '../public/ProfilingFrameIterator.h',
133    '../public/ProfilingStack.h',
134    '../public/Proxy.h',
135    '../public/Realm.h',
136    '../public/RequiredDefines.h',
137    '../public/RootingAPI.h',
138    '../public/SliceBudget.h',
139    '../public/StructuredClone.h',
140    '../public/SweepingAPI.h',
141    '../public/TraceKind.h',
142    '../public/TracingAPI.h',
143    '../public/TrackedOptimizationInfo.h',
144    '../public/TypeDecls.h',
145    '../public/UbiNode.h',
146    '../public/UbiNodeBreadthFirst.h',
147    '../public/UbiNodeCensus.h',
148    '../public/UbiNodeDominatorTree.h',
149    '../public/UbiNodePostOrder.h',
150    '../public/UbiNodeShortestPaths.h',
151    '../public/UniquePtr.h',
152    '../public/Utility.h',
153    '../public/Value.h',
154    '../public/Vector.h',
155    '../public/WeakMapPtr.h',
156]
157
158UNIFIED_SOURCES += [
159    'builtin/AtomicsObject.cpp',
160    'builtin/Eval.cpp',
161    'builtin/Intl.cpp',
162    'builtin/MapObject.cpp',
163    'builtin/ModuleObject.cpp',
164    'builtin/Object.cpp',
165    'builtin/Profilers.cpp',
166    'builtin/Promise.cpp',
167    'builtin/Reflect.cpp',
168    'builtin/ReflectParse.cpp',
169    'builtin/SIMD.cpp',
170    'builtin/SymbolObject.cpp',
171    'builtin/TestingFunctions.cpp',
172    'builtin/TypedObject.cpp',
173    'builtin/WeakMapObject.cpp',
174    'builtin/WeakSetObject.cpp',
175    'devtools/sharkctl.cpp',
176    'ds/LifoAlloc.cpp',
177    'ds/MemoryProtectionExceptionHandler.cpp',
178    'frontend/BytecodeCompiler.cpp',
179    'frontend/BytecodeEmitter.cpp',
180    'frontend/FoldConstants.cpp',
181    'frontend/NameFunctions.cpp',
182    'frontend/ParseNode.cpp',
183    'frontend/TokenStream.cpp',
184    'gc/Allocator.cpp',
185    'gc/Barrier.cpp',
186    'gc/GCTrace.cpp',
187    'gc/Iteration.cpp',
188    'gc/Marking.cpp',
189    'gc/Memory.cpp',
190    'gc/MemoryProfiler.cpp',
191    'gc/Nursery.cpp',
192    'gc/RootMarking.cpp',
193    'gc/Statistics.cpp',
194    'gc/Tracer.cpp',
195    'gc/Verifier.cpp',
196    'gc/Zone.cpp',
197    'irregexp/NativeRegExpMacroAssembler.cpp',
198    'irregexp/RegExpAST.cpp',
199    'irregexp/RegExpEngine.cpp',
200    'irregexp/RegExpInterpreter.cpp',
201    'irregexp/RegExpMacroAssembler.cpp',
202    'irregexp/RegExpParser.cpp',
203    'irregexp/RegExpStack.cpp',
204    'jit/AliasAnalysis.cpp',
205    'jit/AliasAnalysisShared.cpp',
206    'jit/AlignmentMaskAnalysis.cpp',
207    'jit/BacktrackingAllocator.cpp',
208    'jit/Bailouts.cpp',
209    'jit/BaselineBailouts.cpp',
210    'jit/BaselineCacheIR.cpp',
211    'jit/BaselineCompiler.cpp',
212    'jit/BaselineDebugModeOSR.cpp',
213    'jit/BaselineFrame.cpp',
214    'jit/BaselineFrameInfo.cpp',
215    'jit/BaselineIC.cpp',
216    'jit/BaselineInspector.cpp',
217    'jit/BaselineJIT.cpp',
218    'jit/BitSet.cpp',
219    'jit/BytecodeAnalysis.cpp',
220    'jit/C1Spewer.cpp',
221    'jit/CacheIR.cpp',
222    'jit/CodeGenerator.cpp',
223    'jit/CompileWrappers.cpp',
224    'jit/Disassembler.cpp',
225    'jit/EagerSimdUnbox.cpp',
226    'jit/EdgeCaseAnalysis.cpp',
227    'jit/EffectiveAddressAnalysis.cpp',
228    'jit/ExecutableAllocator.cpp',
229    'jit/FlowAliasAnalysis.cpp',
230    'jit/FoldLinearArithConstants.cpp',
231    'jit/InstructionReordering.cpp',
232    'jit/Ion.cpp',
233    'jit/IonAnalysis.cpp',
234    'jit/IonBuilder.cpp',
235    'jit/IonCaches.cpp',
236    'jit/IonOptimizationLevels.cpp',
237    'jit/JitcodeMap.cpp',
238    'jit/JitFrames.cpp',
239    'jit/JitOptions.cpp',
240    'jit/JitSpewer.cpp',
241    'jit/JSONSpewer.cpp',
242    'jit/LICM.cpp',
243    'jit/Linker.cpp',
244    'jit/LIR.cpp',
245    'jit/LoopUnroller.cpp',
246    'jit/Lowering.cpp',
247    'jit/MacroAssembler.cpp',
248    'jit/MCallOptimize.cpp',
249    'jit/MIR.cpp',
250    'jit/MIRGraph.cpp',
251    'jit/MoveResolver.cpp',
252    'jit/OptimizationTracking.cpp',
253    'jit/PerfSpewer.cpp',
254    'jit/ProcessExecutableMemory.cpp',
255    'jit/RangeAnalysis.cpp',
256    'jit/Recover.cpp',
257    'jit/RegisterAllocator.cpp',
258    'jit/RematerializedFrame.cpp',
259    'jit/Safepoints.cpp',
260    'jit/ScalarReplacement.cpp',
261    'jit/shared/BaselineCompiler-shared.cpp',
262    'jit/shared/CodeGenerator-shared.cpp',
263    'jit/shared/Lowering-shared.cpp',
264    'jit/SharedIC.cpp',
265    'jit/Sink.cpp',
266    'jit/Snapshots.cpp',
267    'jit/StupidAllocator.cpp',
268    'jit/TypedObjectPrediction.cpp',
269    'jit/TypePolicy.cpp',
270    'jit/ValueNumbering.cpp',
271    'jit/VMFunctions.cpp',
272    'jit/WasmBCE.cpp',
273    'jsalloc.cpp',
274    'jsapi.cpp',
275    'jsbool.cpp',
276    'jscntxt.cpp',
277    'jscompartment.cpp',
278    'jsdate.cpp',
279    'jsexn.cpp',
280    'jsfriendapi.cpp',
281    'jsfun.cpp',
282    'jsgc.cpp',
283    'jsiter.cpp',
284    'jsnativestack.cpp',
285    'jsnum.cpp',
286    'jsobj.cpp',
287    'json.cpp',
288    'jsopcode.cpp',
289    'jsprf.cpp',
290    'jspropertytree.cpp',
291    'jsscript.cpp',
292    'jsstr.cpp',
293    'jswatchpoint.cpp',
294    'jsweakmap.cpp',
295    'perf/jsperf.cpp',
296    'proxy/BaseProxyHandler.cpp',
297    'proxy/CrossCompartmentWrapper.cpp',
298    'proxy/DeadObjectProxy.cpp',
299    'proxy/OpaqueCrossCompartmentWrapper.cpp',
300    'proxy/Proxy.cpp',
301    'proxy/ScriptedProxyHandler.cpp',
302    'proxy/SecurityWrapper.cpp',
303    'proxy/Wrapper.cpp',
304    'threading/Mutex.cpp',
305    'vm/ArgumentsObject.cpp',
306    'vm/ArrayBufferObject.cpp',
307    'vm/AsyncFunction.cpp',
308    'vm/Caches.cpp',
309    'vm/CallNonGenericMethod.cpp',
310    'vm/CharacterEncoding.cpp',
311    'vm/CodeCoverage.cpp',
312    'vm/Compression.cpp',
313    'vm/DateTime.cpp',
314    'vm/Debugger.cpp',
315    'vm/DebuggerMemory.cpp',
316    'vm/EnvironmentObject.cpp',
317    'vm/ErrorObject.cpp',
318    'vm/ForOfIterator.cpp',
319    'vm/GeneratorObject.cpp',
320    'vm/GlobalObject.cpp',
321    'vm/HelperThreads.cpp',
322    'vm/Id.cpp',
323    'vm/Interpreter.cpp',
324    'vm/JSONParser.cpp',
325    'vm/MemoryMetrics.cpp',
326    'vm/NativeObject.cpp',
327    'vm/ObjectGroup.cpp',
328    'vm/PIC.cpp',
329    'vm/Printer.cpp',
330    'vm/Probes.cpp',
331    'vm/ProxyObject.cpp',
332    'vm/Realm.cpp',
333    'vm/ReceiverGuard.cpp',
334    'vm/RegExpObject.cpp',
335    'vm/RegExpStatics.cpp',
336    'vm/Runtime.cpp',
337    'vm/SavedStacks.cpp',
338    'vm/Scope.cpp',
339    'vm/SelfHosting.cpp',
340    'vm/Shape.cpp',
341    'vm/SharedArrayObject.cpp',
342    'vm/SharedImmutableStringsCache.cpp',
343    'vm/SPSProfiler.cpp',
344    'vm/Stack.cpp',
345    'vm/Stopwatch.cpp',
346    'vm/String.cpp',
347    'vm/StringBuffer.cpp',
348    'vm/StructuredClone.cpp',
349    'vm/Symbol.cpp',
350    'vm/TaggedProto.cpp',
351    'vm/Time.cpp',
352    'vm/TypedArrayObject.cpp',
353    'vm/TypeInference.cpp',
354    'vm/UbiNode.cpp',
355    'vm/UbiNodeCensus.cpp',
356    'vm/UbiNodeShortestPaths.cpp',
357    'vm/UnboxedObject.cpp',
358    'vm/Unicode.cpp',
359    'vm/Value.cpp',
360    'vm/WeakMapPtr.cpp',
361    'vm/Xdr.cpp',
362    'wasm/AsmJS.cpp',
363    'wasm/WasmBaselineCompile.cpp',
364    'wasm/WasmBinaryFormat.cpp',
365    'wasm/WasmBinaryIterator.cpp',
366    'wasm/WasmBinaryToAST.cpp',
367    'wasm/WasmBinaryToExperimentalText.cpp',
368    'wasm/WasmBinaryToText.cpp',
369    'wasm/WasmCode.cpp',
370    'wasm/WasmCompartment.cpp',
371    'wasm/WasmCompile.cpp',
372    'wasm/WasmFrameIterator.cpp',
373    'wasm/WasmGenerator.cpp',
374    'wasm/WasmInstance.cpp',
375    'wasm/WasmIonCompile.cpp',
376    'wasm/WasmJS.cpp',
377    'wasm/WasmModule.cpp',
378    'wasm/WasmSignalHandlers.cpp',
379    'wasm/WasmStubs.cpp',
380    'wasm/WasmTable.cpp',
381    'wasm/WasmTextToBinary.cpp',
382    'wasm/WasmTextUtils.cpp',
383    'wasm/WasmTypes.cpp'
384]
385
386# jsarray.cpp and jsatom.cpp cannot be built in unified mode because
387# xpcshell is broken during packaging when compiled with gcc-4.8.2
388# builtin/RegExp.cpp cannot be built in unified mode because it is built
389# without PGO
390# frontend/Parser.cpp cannot be built in unified mode because of explicit
391# template instantiations.
392# jsdtoa.cpp cannot be built in unified mode because we want to suppress
393# compiler warnings in third-party dtoa.c.
394# jsmath.cpp cannot be built in unified mode because it needs to pull rand_s
395# from <stdlib.h> on Windows through a preprocessor define.
396# jsutil.cpp cannot be built in unified mode because it is needed for
397# check-vanilla-allocations.
398# StoreBuffer.cpp cannot be built in unified because its template
399# instantiations may or may not be needed depending on what it gets bundled
400# with.
401SOURCES += [
402    'builtin/RegExp.cpp',
403    'frontend/Parser.cpp',
404    'gc/StoreBuffer.cpp',
405    'jsarray.cpp',
406    'jsatom.cpp',
407    'jsdtoa.cpp',
408    'jsmath.cpp',
409    'jsutil.cpp',
410    'vm/Initialization.cpp',
411]
412
413if CONFIG['JS_POSIX_NSPR']:
414    UNIFIED_SOURCES += [
415        'vm/PosixNSPR.cpp',
416    ]
417
418if CONFIG['MOZ_INSTRUMENTS']:
419    SOURCES += [
420        'devtools/Instruments.cpp',
421    ]
422
423if CONFIG['ENABLE_TRACE_LOGGING']:
424    SOURCES += [
425        'vm/TraceLogging.cpp',
426        'vm/TraceLoggingGraph.cpp',
427        'vm/TraceLoggingTypes.cpp',
428    ]
429
430if not CONFIG['ENABLE_ION']:
431    UNIFIED_SOURCES += [
432        'jit/none/Trampoline-none.cpp'
433    ]
434elif CONFIG['JS_CODEGEN_X86'] or CONFIG['JS_CODEGEN_X64']:
435    UNIFIED_SOURCES += [
436        'jit/x86-shared/Architecture-x86-shared.cpp',
437        'jit/x86-shared/Assembler-x86-shared.cpp',
438        'jit/x86-shared/AssemblerBuffer-x86-shared.cpp',
439        'jit/x86-shared/BaselineCompiler-x86-shared.cpp',
440        'jit/x86-shared/BaselineIC-x86-shared.cpp',
441        'jit/x86-shared/CodeGenerator-x86-shared.cpp',
442        'jit/x86-shared/Lowering-x86-shared.cpp',
443        'jit/x86-shared/MacroAssembler-x86-shared.cpp',
444        'jit/x86-shared/MoveEmitter-x86-shared.cpp',
445    ]
446    SOURCES += [
447        'jit/x86-shared/Disassembler-x86-shared.cpp',  # using namespace js::jit::X86Encoding;
448    ]
449    if CONFIG['JS_CODEGEN_X64']:
450        UNIFIED_SOURCES += [
451            'jit/x64/Assembler-x64.cpp',
452            'jit/x64/Bailouts-x64.cpp',
453            'jit/x64/BaselineCompiler-x64.cpp',
454            'jit/x64/BaselineIC-x64.cpp',
455            'jit/x64/CodeGenerator-x64.cpp',
456            'jit/x64/Lowering-x64.cpp',
457            'jit/x64/MacroAssembler-x64.cpp',
458            'jit/x64/SharedIC-x64.cpp',
459            'jit/x64/Trampoline-x64.cpp',
460        ]
461    else:
462        UNIFIED_SOURCES += [
463            'jit/x86/Assembler-x86.cpp',
464            'jit/x86/Bailouts-x86.cpp',
465            'jit/x86/BaselineCompiler-x86.cpp',
466            'jit/x86/BaselineIC-x86.cpp',
467            'jit/x86/CodeGenerator-x86.cpp',
468            'jit/x86/Lowering-x86.cpp',
469            'jit/x86/MacroAssembler-x86.cpp',
470            'jit/x86/SharedIC-x86.cpp',
471            'jit/x86/Trampoline-x86.cpp',
472        ]
473elif CONFIG['JS_CODEGEN_ARM']:
474    UNIFIED_SOURCES += [
475        'jit/arm/Architecture-arm.cpp',
476        'jit/arm/Assembler-arm.cpp',
477        'jit/arm/Bailouts-arm.cpp',
478        'jit/arm/BaselineCompiler-arm.cpp',
479        'jit/arm/BaselineIC-arm.cpp',
480        'jit/arm/CodeGenerator-arm.cpp',
481        'jit/arm/disasm/Constants-arm.cpp',
482        'jit/arm/disasm/Disasm-arm.cpp',
483        'jit/arm/Lowering-arm.cpp',
484        'jit/arm/MacroAssembler-arm.cpp',
485        'jit/arm/MoveEmitter-arm.cpp',
486        'jit/arm/SharedIC-arm.cpp',
487        'jit/arm/Trampoline-arm.cpp',
488    ]
489    if CONFIG['JS_SIMULATOR_ARM']:
490        UNIFIED_SOURCES += [
491            'jit/arm/Simulator-arm.cpp'
492        ]
493        # Configuration used only for testing.
494        if CONFIG['OS_ARCH'] == 'Linux' or CONFIG['OS_ARCH'] == 'Darwin':
495            CXXFLAGS += [ '-msse2', '-mfpmath=sse' ]
496    elif CONFIG['OS_ARCH'] == 'Darwin':
497        SOURCES += [
498            'jit/arm/llvm-compiler-rt/arm/aeabi_idivmod.S',
499            'jit/arm/llvm-compiler-rt/arm/aeabi_uidivmod.S',
500        ]
501elif CONFIG['JS_CODEGEN_ARM64']:
502    UNIFIED_SOURCES += [
503        'jit/arm64/Architecture-arm64.cpp',
504        'jit/arm64/Assembler-arm64.cpp',
505        'jit/arm64/Bailouts-arm64.cpp',
506        'jit/arm64/BaselineIC-arm64.cpp',
507        'jit/arm64/CodeGenerator-arm64.cpp',
508        'jit/arm64/Lowering-arm64.cpp',
509        'jit/arm64/MacroAssembler-arm64.cpp',
510        'jit/arm64/MoveEmitter-arm64.cpp',
511        'jit/arm64/SharedIC-arm64.cpp',
512        'jit/arm64/Trampoline-arm64.cpp',
513        'jit/arm64/vixl/Assembler-vixl.cpp',
514        'jit/arm64/vixl/Cpu-vixl.cpp',
515        'jit/arm64/vixl/Decoder-vixl.cpp',
516        'jit/arm64/vixl/Disasm-vixl.cpp',
517        'jit/arm64/vixl/Instructions-vixl.cpp',
518        'jit/arm64/vixl/Instrument-vixl.cpp',
519        'jit/arm64/vixl/MacroAssembler-vixl.cpp',
520        'jit/arm64/vixl/MozAssembler-vixl.cpp',
521        'jit/arm64/vixl/MozInstructions-vixl.cpp',
522        'jit/arm64/vixl/Utils-vixl.cpp'
523    ]
524    if CONFIG['JS_SIMULATOR_ARM64']:
525        UNIFIED_SOURCES += [
526            'jit/arm64/vixl/Debugger-vixl.cpp',
527            'jit/arm64/vixl/Logic-vixl.cpp',
528            'jit/arm64/vixl/MozSimulator-vixl.cpp',
529            'jit/arm64/vixl/Simulator-vixl.cpp'
530        ]
531elif CONFIG['JS_CODEGEN_MIPS32'] or CONFIG['JS_CODEGEN_MIPS64']:
532    UNIFIED_SOURCES += [
533        'jit/mips-shared/Architecture-mips-shared.cpp',
534        'jit/mips-shared/Assembler-mips-shared.cpp',
535        'jit/mips-shared/Bailouts-mips-shared.cpp',
536        'jit/mips-shared/BaselineCompiler-mips-shared.cpp',
537        'jit/mips-shared/BaselineIC-mips-shared.cpp',
538        'jit/mips-shared/CodeGenerator-mips-shared.cpp',
539        'jit/mips-shared/Lowering-mips-shared.cpp',
540        'jit/mips-shared/MacroAssembler-mips-shared.cpp',
541        'jit/mips-shared/MoveEmitter-mips-shared.cpp',
542    ]
543    if CONFIG['JS_CODEGEN_MIPS32']:
544        UNIFIED_SOURCES += [
545            'jit/mips32/Architecture-mips32.cpp',
546            'jit/mips32/Assembler-mips32.cpp',
547            'jit/mips32/Bailouts-mips32.cpp',
548            'jit/mips32/BaselineCompiler-mips32.cpp',
549            'jit/mips32/BaselineIC-mips32.cpp',
550            'jit/mips32/CodeGenerator-mips32.cpp',
551            'jit/mips32/Lowering-mips32.cpp',
552            'jit/mips32/MacroAssembler-mips32.cpp',
553            'jit/mips32/MoveEmitter-mips32.cpp',
554            'jit/mips32/SharedIC-mips32.cpp',
555            'jit/mips32/Trampoline-mips32.cpp',
556        ]
557        if CONFIG['JS_SIMULATOR_MIPS32']:
558            UNIFIED_SOURCES += [
559                'jit/mips32/Simulator-mips32.cpp'
560            ]
561    elif CONFIG['JS_CODEGEN_MIPS64']:
562        UNIFIED_SOURCES += [
563            'jit/mips64/Architecture-mips64.cpp',
564            'jit/mips64/Assembler-mips64.cpp',
565            'jit/mips64/Bailouts-mips64.cpp',
566            'jit/mips64/BaselineCompiler-mips64.cpp',
567            'jit/mips64/BaselineIC-mips64.cpp',
568            'jit/mips64/CodeGenerator-mips64.cpp',
569            'jit/mips64/Lowering-mips64.cpp',
570            'jit/mips64/MacroAssembler-mips64.cpp',
571            'jit/mips64/MoveEmitter-mips64.cpp',
572            'jit/mips64/SharedIC-mips64.cpp',
573            'jit/mips64/Trampoline-mips64.cpp',
574        ]
575        if CONFIG['JS_SIMULATOR_MIPS64']:
576            UNIFIED_SOURCES += [
577                'jit/mips64/Simulator-mips64.cpp'
578            ]
579
580if CONFIG['OS_ARCH'] == 'WINNT':
581    SOURCES += [
582        'threading/windows/ConditionVariable.cpp',
583        'threading/windows/MutexImpl.cpp',
584        'threading/windows/Thread.cpp',
585    ]
586    # _CRT_RAND_S must be #defined before #including stdlib.h to get rand_s()
587    DEFINES['_CRT_RAND_S'] = True
588else:
589    SOURCES += [
590        'threading/posix/ConditionVariable.cpp',
591        'threading/posix/MutexImpl.cpp',
592        'threading/posix/Thread.cpp',
593    ]
594
595if CONFIG['JS_HAS_CTYPES']:
596    SOURCES += [
597        'ctypes/CTypes.cpp',
598        'ctypes/Library.cpp',
599    ]
600    if not CONFIG['MOZ_SYSTEM_FFI']:
601        LOCAL_INCLUDES += [
602            '!ctypes/libffi/include',
603            'ctypes/libffi/src/%s' % CONFIG['FFI_TARGET_DIR'],
604        ]
605
606if CONFIG['MOZ_VTUNE']:
607    SOURCES += [
608        'vtune/jitprofiling.c'
609    ]
610
611if CONFIG['HAVE_LINUX_PERF_EVENT_H']:
612    SOURCES += [
613        'perf/pm_linux.cpp'
614    ]
615    if CONFIG['LINUX_HEADERS_INCLUDES']:
616        SOURCES['perf/pm_linux.cpp'].flags += [CONFIG['LINUX_HEADERS_INCLUDES']]
617else:
618    SOURCES += [
619        'perf/pm_stub.cpp'
620    ]
621
622GENERATED_FILES += ['jsautokw.h']
623jsautokw = GENERATED_FILES['jsautokw.h']
624jsautokw.script = 'jsautokw.py'
625jsautokw.inputs += [
626    'vm/Keywords.h'
627]
628
629# JavaScript must be built shared, even for static builds, as it is used by
630# other modules which are always built shared. Failure to do so results in
631# the js code getting copied into xpinstall and jsd as well as mozilla-bin,
632# and then the static data cells used for locking no longer work.
633#
634# In fact, we now build both a static and a shared library, as the
635# JS shell would like to link to the static library.
636
637if CONFIG['JS_SHARED_LIBRARY']:
638    GeckoSharedLibrary('js', linkage=None)
639    SHARED_LIBRARY_NAME = CONFIG['JS_LIBRARY_NAME']
640    SDK_LIBRARY = True
641else:
642    Library('js')
643
644FORCE_STATIC_LIB = True
645STATIC_LIBRARY_NAME = 'js_static'
646
647if CONFIG['ENABLE_INTL_API']:
648    if not CONFIG['MOZ_ICU_DATA_ARCHIVE']:
649        USE_LIBS += [
650            'icu',
651        ]
652    else:
653        # Linking 'icu' will pull in the stubdata library,
654        # which the shell doesn't want, so link the other bits.
655        USE_LIBS += [
656            'icui18n',
657            'icuuc',
658        ]
659
660USE_LIBS += [
661    'nspr',
662    'zlib',
663]
664
665if CONFIG['NIGHTLY_BUILD']:
666    DEFINES['ENABLE_BINARYDATA'] = True
667
668if CONFIG['NIGHTLY_BUILD']:
669    DEFINES['ENABLE_SIMD'] = True
670
671# Also set in shell/moz.build
672DEFINES['ENABLE_SHARED_ARRAY_BUFFER'] = True
673
674DEFINES['EXPORT_JS_API'] = True
675
676if CONFIG['JS_HAS_CTYPES']:
677    DEFINES['JS_HAS_CTYPES'] = True
678    for var in ('DLL_PREFIX', 'DLL_SUFFIX'):
679        DEFINES[var] = '"%s"' % CONFIG[var]
680
681if CONFIG['MOZ_LINKER']:
682    DEFINES['MOZ_LINKER'] = True
683
684if CONFIG['_MSC_VER']:
685    if CONFIG['CPU_ARCH'] == 'x86':
686        SOURCES['builtin/RegExp.cpp'].no_pgo = True # Bug 772303
687    elif CONFIG['CPU_ARCH'] == 'x86_64' and CONFIG['JS_HAS_CTYPES']:
688        SOURCES['ctypes/CTypes.cpp'].no_pgo = True # Bug 810661
689    # Prevent floating point errors caused by VC++ optimizations
690    # XXX We should add this to CXXFLAGS, too?
691    CFLAGS += ['-fp:precise']
692    # C4805 warns mixing bool with other integral types in computation.
693    # But given the conversion from bool is specified, and this is a
694    # pattern widely used in code in js/src, suppress this warning here.
695    CXXFLAGS += ['-wd4805']
696    # C4661 ("no suitable definition provided for explicit template
697    # instantiation request") is emitted for all Parser methods that
698    # have a Parser<FullParseHandler> definition but no
699    # Parser<SyntaxParseHandler> definition, see bug 1167030.
700    CXXFLAGS += ['-wd4661']
701    CXXFLAGS += ['-we4067', '-we4258', '-we4275']
702    CXXFLAGS += ['-wd4146'] # FIXME: unary minus operator applied to unsigned type (bug 1229189)
703
704    # This is intended as a temporary hack to support building with VS2015.
705    # 'noexcept' used with no exception handling mode specified;
706    # termination on exception is not guaranteed. Specify /EHsc
707    CXXFLAGS += ['-wd4577']
708    CXXFLAGS += ['-wd4312']
709
710if CONFIG['OS_ARCH'] not in ('WINNT', 'HP-UX'):
711    OS_LIBS += [
712        'm',
713    ]
714
715if CONFIG['OS_ARCH'] == 'FreeBSD':
716    OS_LIBS += [
717        '-pthread',
718    ]
719
720if CONFIG['OS_ARCH'] == 'Linux':
721    OS_LIBS += [
722        'dl',
723    ]
724
725if CONFIG['OS_ARCH'] == 'SunOS':
726    OS_LIBS += [
727        'posix4',
728        'dl',
729        'nsl',
730        'socket',
731    ]
732
733OS_LIBS += CONFIG['REALTIME_LIBS']
734
735CFLAGS += CONFIG['MOZ_ICU_CFLAGS']
736CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
737
738# Prepare self-hosted JS code for embedding
739GENERATED_FILES += [('selfhosted.out.h', 'selfhosted.js')]
740selfhosted = GENERATED_FILES[('selfhosted.out.h', 'selfhosted.js')]
741selfhosted.script = 'builtin/embedjs.py:generate_selfhosted'
742selfhosted.inputs = [
743    'js.msg',
744    'builtin/TypedObjectConstants.h',
745    'builtin/SelfHostingDefines.h',
746    'builtin/Utilities.js',
747    'builtin/Array.js',
748    'builtin/Classes.js',
749    'builtin/Date.js',
750    'builtin/Error.js',
751    'builtin/Function.js',
752    'builtin/Generator.js',
753    'builtin/Intl.js',
754    'builtin/IntlData.js',
755    'builtin/Iterator.js',
756    'builtin/Map.js',
757    'builtin/Module.js',
758    'builtin/Number.js',
759    'builtin/Object.js',
760    'builtin/Reflect.js',
761    'builtin/RegExp.js',
762    'builtin/RegExpGlobalReplaceOpt.h.js',
763    'builtin/RegExpLocalReplaceOpt.h.js',
764    'builtin/String.js',
765    'builtin/Set.js',
766    'builtin/Sorting.js',
767    'builtin/TypedArray.js',
768    'builtin/TypedObject.js',
769    'builtin/WeakMap.js',
770    'builtin/WeakSet.js'
771]
772
773if CONFIG['SPIDERMONKEY_PROMISE']:
774    selfhosted.inputs += ['builtin/Promise.js']
775
776if CONFIG['JS_HAS_CTYPES']:
777    if CONFIG['MOZ_SYSTEM_FFI']:
778        CXXFLAGS += CONFIG['MOZ_FFI_CFLAGS']
779    else:
780        # Windows needs this to be linked with a static library.
781        DEFINES['FFI_BUILDING'] = True
782
783if CONFIG['GNU_CXX']:
784    CXXFLAGS += ['-Wno-shadow', '-Werror=format']
785
786# Suppress warnings in third-party code.
787if CONFIG['CLANG_CXX']:
788    SOURCES['jsdtoa.cpp'].flags += ['-Wno-implicit-fallthrough']
789