js/src/moz.build
author Benjamin Bouvier <benj@benj.me>
Thu, 14 Feb 2019 11:52:57 +0100
changeset 459535 2d4f87a0212e0a57e8ed39ebe9516a18b4e4ef3e
parent 459206 51c3380d5b9456e9307f35ff09678634a7d0ee7b
child 459686 26fb2a868911021c586ca56d64ede136ae28c015
permissions -rwxr-xr-x
Bug 1527861: Allow disabling BinAST compilation; r=tcampbell Differential Revision: https://phabricator.services.mozilla.com/D19765

# -*- 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 CONFIG['JS_BUNDLED_EDITLINE']:
    DIRS += ['editline']

if not CONFIG['JS_DISABLE_SHELL']:
    DIRS += ['shell']

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

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',
    ]

CONFIGURE_SUBST_FILES += [
    'devtools/rootAnalysis/Makefile',
]
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']:
    GENERATED_FILES += ['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',
    'js.msg',
    'jsapi.h',
    'jsfriendapi.h',
    'jspubtd.h',
    'jstypes.h',
    'perf/jsperf.h',
]

EXPORTS.js += [
    '../public/AllocPolicy.h',
    '../public/BuildId.h',
    '../public/CallArgs.h',
    '../public/CallNonGenericMethod.h',
    '../public/CharacterEncoding.h',
    '../public/Class.h',
    '../public/CompilationAndEvaluation.h',
    '../public/CompileOptions.h',
    '../public/ContextOptions.h',
    '../public/Conversions.h',
    '../public/Date.h',
    '../public/Debug.h',
    '../public/Equality.h',
    '../public/ErrorReport.h',
    '../public/GCAnnotations.h',
    '../public/GCAPI.h',
    '../public/GCHashTable.h',
    '../public/GCPolicyAPI.h',
    '../public/GCVariant.h',
    '../public/GCVector.h',
    '../public/HashTable.h',
    '../public/HeapAPI.h',
    '../public/Id.h',
    '../public/Initialization.h',
    '../public/JSON.h',
    '../public/LocaleSensitive.h',
    '../public/MemoryFunctions.h',
    '../public/MemoryMetrics.h',
    '../public/OffThreadScriptCompilation.h',
    '../public/Principals.h',
    '../public/Printf.h',
    '../public/ProfilingFrameIterator.h',
    '../public/ProfilingStack.h',
    '../public/Promise.h',
    '../public/PropertyDescriptor.h',
    '../public/PropertySpec.h',
    '../public/ProtoKey.h',
    '../public/Proxy.h',
    '../public/Realm.h',
    '../public/RefCounted.h',
    '../public/RequiredDefines.h',
    '../public/Result.h',
    '../public/RootingAPI.h',
    '../public/SavedFrameAPI.h',
    '../public/SliceBudget.h',
    '../public/SourceText.h',
    '../public/StableStringChars.h',
    '../public/Stream.h',
    '../public/StructuredClone.h',
    '../public/SweepingAPI.h',
    '../public/Symbol.h',
    '../public/TraceKind.h',
    '../public/TraceLoggerAPI.h',
    '../public/TracingAPI.h',
    '../public/TrackedOptimizationInfo.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/Vector.h',
    '../public/WeakMapPtr.h',
    '../public/Wrapper.h',
]

UNIFIED_SOURCES += [
    'builtin/Array.cpp',
    'builtin/AtomicsObject.cpp',
    'builtin/BigInt.cpp',
    'builtin/Boolean.cpp',
    'builtin/DataViewObject.cpp',
    'builtin/Eval.cpp',
    'builtin/intl/Collator.cpp',
    'builtin/intl/CommonFunctions.cpp',
    'builtin/intl/DateTimeFormat.cpp',
    'builtin/intl/IntlObject.cpp',
    'builtin/intl/NumberFormat.cpp',
    'builtin/intl/PluralRules.cpp',
    'builtin/intl/RelativeTimeFormat.cpp',
    'builtin/intl/SharedIntlData.cpp',
    'builtin/JSON.cpp',
    'builtin/MapObject.cpp',
    'builtin/ModuleObject.cpp',
    'builtin/Object.cpp',
    'builtin/Profilers.cpp',
    'builtin/Promise.cpp',
    'builtin/Reflect.cpp',
    'builtin/ReflectParse.cpp',
    'builtin/Stream.cpp',
    'builtin/String.cpp',
    'builtin/Symbol.cpp',
    'builtin/TestingFunctions.cpp',
    'builtin/TypedObject.cpp',
    'builtin/WeakMapObject.cpp',
    'builtin/WeakSetObject.cpp',
    'devtools/sharkctl.cpp',
    'ds/Bitmap.cpp',
    'ds/LifoAlloc.cpp',
    'ds/MemoryProtectionExceptionHandler.cpp',
    'irregexp/NativeRegExpMacroAssembler.cpp',
    'irregexp/RegExpAST.cpp',
    'irregexp/RegExpCharacters.cpp',
    'irregexp/RegExpEngine.cpp',
    'irregexp/RegExpInterpreter.cpp',
    'irregexp/RegExpMacroAssembler.cpp',
    'irregexp/RegExpParser.cpp',
    'irregexp/RegExpStack.cpp',
    'jsapi.cpp',
    'jsdate.cpp',
    'jsexn.cpp',
    'jsfriendapi.cpp',
    'jsnum.cpp',
    'perf/jsperf.cpp',
    'proxy/BaseProxyHandler.cpp',
    'proxy/CrossCompartmentWrapper.cpp',
    'proxy/DeadObjectProxy.cpp',
    'proxy/OpaqueCrossCompartmentWrapper.cpp',
    'proxy/Proxy.cpp',
    'proxy/ScriptedProxyHandler.cpp',
    'proxy/SecurityWrapper.cpp',
    'proxy/Wrapper.cpp',
    'threading/Mutex.cpp',
    'threading/ProtectedData.cpp',
    'util/AllocPolicy.cpp',
    'util/CompleteFile.cpp',
    'util/NativeStack.cpp',
    'util/Printf.cpp',
    'util/StringBuffer.cpp',
    'util/StructuredSpewer.cpp',
    'util/Text.cpp',
    'util/Unicode.cpp',
    'vm/ArgumentsObject.cpp',
    'vm/ArrayBufferObject.cpp',
    'vm/ArrayBufferViewObject.cpp',
    'vm/AsyncFunction.cpp',
    'vm/AsyncIteration.cpp',
    'vm/BigIntType.cpp',
    'vm/BuildId.cpp',
    'vm/BytecodeUtil.cpp',
    'vm/Caches.cpp',
    'vm/CallNonGenericMethod.cpp',
    'vm/CharacterEncoding.cpp',
    'vm/CodeCoverage.cpp',
    'vm/Compartment.cpp',
    'vm/CompilationAndEvaluation.cpp',
    'vm/Compression.cpp',
    'vm/DateTime.cpp',
    'vm/Debugger.cpp',
    'vm/DebuggerMemory.cpp',
    'vm/EnvironmentObject.cpp',
    'vm/EqualityOperations.cpp',
    'vm/ErrorObject.cpp',
    'vm/ErrorReporting.cpp',
    'vm/ForOfIterator.cpp',
    'vm/GeckoProfiler.cpp',
    'vm/GeneratorObject.cpp',
    'vm/GlobalObject.cpp',
    'vm/HelperThreads.cpp',
    'vm/Id.cpp',
    'vm/Initialization.cpp',
    'vm/Iteration.cpp',
    'vm/JSAtom.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/NativeObject.cpp',
    'vm/ObjectGroup.cpp',
    'vm/OffThreadScriptCompilation.cpp',
    'vm/PIC.cpp',
    'vm/Printer.cpp',
    'vm/Probes.cpp',
    'vm/ProxyObject.cpp',
    'vm/Realm.cpp',
    'vm/ReceiverGuard.cpp',
    'vm/RegExpObject.cpp',
    'vm/RegExpStatics.cpp',
    'vm/Runtime.cpp',
    'vm/SavedStacks.cpp',
    'vm/Scope.cpp',
    'vm/SelfHosting.cpp',
    'vm/Shape.cpp',
    'vm/SharedArrayObject.cpp',
    'vm/SharedImmutableStringsCache.cpp',
    'vm/Stack.cpp',
    'vm/StringType.cpp',
    'vm/SymbolType.cpp',
    'vm/TaggedProto.cpp',
    'vm/Time.cpp',
    'vm/TypedArrayObject.cpp',
    'vm/TypeInference.cpp',
    'vm/UbiNode.cpp',
    'vm/UbiNodeCensus.cpp',
    'vm/UbiNodeShortestPaths.cpp',
    'vm/UnboxedObject.cpp',
    'vm/Value.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.
# jsutil.cpp cannot be built in unified mode because it is needed for
#   check-vanilla-allocations.
# perf/ProfilingStack.cpp cannot be built in unified mode because we want to
#   suppress warnings due to usage of the system allocator, and this allows it
#   to have a deterministic object name.
# util/DoubleToString.cpp cannot be built in unified mode because we want to
#   suppress compiler warnings in third-party dtoa.c.
# 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',
    'jsutil.cpp',
    'util/DoubleToString.cpp',
    'vm/Interpreter.cpp',
    'vm/ProfilingStack.cpp',
]

if CONFIG['JS_POSIX_NSPR']:
    UNIFIED_SOURCES += [
        'vm/PosixNSPR.cpp',
    ]

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

if CONFIG['ENABLE_TRACE_LOGGING']:
    SOURCES += [
        'vm/TraceLogging.cpp',
        'vm/TraceLoggingGraph.cpp',
        'vm/TraceLoggingTypes.cpp',
    ]

if CONFIG['OS_ARCH'] == 'WINNT':
    UNIFIED_SOURCES += [
        'threading/windows/CpuCount.cpp',
        'threading/windows/Thread.cpp',
    ]
else:
    UNIFIED_SOURCES += [
        'threading/posix/CpuCount.cpp',
        'threading/posix/Thread.cpp',
    ]

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-unknown-pragmas']

if CONFIG['HAVE_LINUX_PERF_EVENT_H']:
    SOURCES += [
        'perf/pm_linux.cpp'
    ]
    if CONFIG['LINUX_HEADERS_INCLUDES']:
        SOURCES['perf/pm_linux.cpp'].flags += [CONFIG['LINUX_HEADERS_INCLUDES']]
else:
    SOURCES += [
        'perf/pm_stub.cpp'
    ]

DIRS += [
    'build',
    'frontend',
    'gc',
    'jit',
    'wasm',
]

FINAL_LIBRARY = 'js'

# Prepare self-hosted JS code for embedding
GENERATED_FILES += [('selfhosted.out.h', 'selfhosted.js')]
selfhosted = GENERATED_FILES[('selfhosted.out.h', 'selfhosted.js')]
selfhosted.script = 'builtin/embedjs.py:generate_selfhosted'
selfhosted.inputs = [
    'js.msg',
    'builtin/TypedObjectConstants.h',
    'builtin/SelfHostingDefines.h',
    'builtin/Utilities.js',
    'builtin/Array.js',
    'builtin/AsyncIteration.js',
    'builtin/Classes.js',
    'builtin/Date.js',
    'builtin/Error.js',
    'builtin/Function.js',
    'builtin/Generator.js',
    'builtin/intl/Collator.js',
    'builtin/intl/CommonFunctions.js',
    'builtin/intl/CurrencyDataGenerated.js',
    'builtin/intl/DateTimeFormat.js',
    'builtin/intl/IntlObject.js',
    'builtin/intl/LangTagMappingsGenerated.js',
    'builtin/intl/NumberFormat.js',
    'builtin/intl/PluralRules.js',
    'builtin/intl/RelativeTimeFormat.js',
    'builtin/Iterator.js',
    'builtin/Map.js',
    'builtin/Module.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/TypedObject.js',
    'builtin/WeakMap.js',
    'builtin/WeakSet.js'
]

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

# Suppress warnings in third-party code.
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
    SOURCES['util/DoubleToString.cpp'].flags += ['-Wno-implicit-fallthrough']