# -*- 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/.

with Files('**'):
    BUG_COMPONENT = ('Core', 'String')

EXPORTS += [
    'nsASCIIMask.h',
    'nsAString.h',
    'nsCharTraits.h',
    'nsDependentString.h',
    'nsDependentSubstring.h',
    'nsLiteralString.h',
    'nsPrintfCString.h',
    'nsPromiseFlatString.h',
    'nsReadableUtils.h',
    'nsString.h',
    'nsStringBuffer.h',
    'nsStringFlags.h',
    'nsStringFwd.h',
    'nsStringIterator.h',
    'nsSubstring.h',
    'nsSubstringTuple.h',
    'nsTDependentString.h',
    'nsTDependentSubstring.h',
    'nsTextFormatter.h',
    'nsTLiteralString.h',
    'nsTPromiseFlatString.h',
    'nsTString.h',
    'nsTStringRepr.h',
    'nsTSubstring.h',
    'nsTSubstringTuple.h',
    'nsUTF8Utils.h',
]

UNIFIED_SOURCES += [
    'nsASCIIMask.cpp',
    'nsDependentString.cpp',
    'nsDependentSubstring.cpp',
    'nsPromiseFlatString.cpp',
    'nsReadableUtils.cpp',
    'nsString.cpp',
    'nsStringComparator.cpp',
    'nsStringObsolete.cpp',
    'nsSubstring.cpp',
    'nsSubstringTuple.cpp',
    'nsTextFormatter.cpp',
    'precompiled_templates.cpp',
]

# Are we targeting x86 or x86-64?  If so, compile the SSE2 functions for
# nsUTF8Utils.cpp and nsReadableUtils.cpp.
if CONFIG['INTEL_ARCHITECTURE']:
    SOURCES += ['nsUTF8UtilsSSE2.cpp']
    SOURCES['nsUTF8UtilsSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
    SOURCES += ['nsReadableUtilsSSE2.cpp']
    SOURCES['nsReadableUtilsSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']

if CONFIG['BUILD_ARM_NEON'] or CONFIG['CPU_ARCH'] == 'aarch64':
    SOURCES += ['nsUTF8UtilsNEON.cpp']
    SOURCES['nsUTF8UtilsNEON.cpp'].flags += CONFIG['NEON_FLAGS']

# MSVC 2017 has a bug that incorrectly generates C5037 warning which
# hits the template string code. We need to disable this warning as a
# workaround. See https://developercommunity.visualstudio.com/
# content/problem/81223/incorrect-error-c5037-with-permissive.html
if CONFIG['CC_TYPE'] in ('msvc', 'clang-cl'):
    CXXFLAGS += ['-wd5037']

FINAL_LIBRARY = 'xul'
