media/libdav1d/asm/moz.build
author Mike Hommey <mh+mozilla@glandium.org>
Tue, 07 Apr 2020 15:52:00 +0000
changeset 522816 6663d3dc883b6ad0d0dfa9346f9ceabf2b2c7967
parent 519846 0ce1dba34e1f3ad44ffb59fb883b7f84247d780c
permissions -rw-r--r--
Bug 1627873 - Always unbuffer python output when invoking python commands from mach. r=firefox-build-system-reviewers,rstewart When the build is stalled for some random reason, and mach executed a python subcommand (this may or may not be limited to python 3, I'm not sure, and it doesn't really matter since it's a problem on python 3, which matters most), the subcommand may not have actually sent its last bits of output before the stall because its output is a pipe and in that case python uses buffered outputs. Now, when your build is completely stalled and you ctrl+C, you end up without these bits of output, and in some cases, those bits of output can contain actual information, like... tracebacks. A real life example of this is bug 1624670 when running mach build or mach configure with the patches from bug 1627163 applied, and configure stalls without printing out the ValueError message at all. Differential Revision: https://phabricator.services.mozilla.com/D69925

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

# ASM enabled

ASFLAGS += [
    '-I%s/third_party/dav1d/src/' % TOPSRCDIR,
]

LOCAL_INCLUDES += [
    '/third_party/dav1d/',
    '/third_party/dav1d/include/',
    '/third_party/dav1d/src/',
]

# Don't export DAV1D_API symbols from libxul
# see: third_party/dav1d/include/dav1d/common.h
DEFINES['DAV1D_API'] = ''

CFLAGS += [
    # find the config.h file.
    '-I%s/dist/include/dav1d/' % TOPOBJDIR,
]

# Store the stack alignment that will be used.
stack_alignment = 0

# Attaching config.asm file
if CONFIG['CPU_ARCH'] == 'x86':
    # Default stack alignment can be 4 bytes.
    if CONFIG['OS_TARGET'] == 'WINNT':
        stack_alignment = 4
        ASFLAGS += ['-I%s/media/libdav1d/asm/x86_32/win/' % TOPSRCDIR]
    else:
        ASFLAGS += ['-I%s/media/libdav1d/asm/x86_32/' % TOPSRCDIR]
        stack_alignment = 16
        # Change stack alignment to 16 bytes.
        if CONFIG['CC_TYPE'] == 'clang':
            CFLAGS += ['-mstack-alignment=16']
        elif CONFIG['CC_TYPE'] == 'gcc':
            CFLAGS += ['-mpreferred-stack-boundary=4']
elif CONFIG['CPU_ARCH'] == 'x86_64':
    # Default stack aligment is 16 bytes.
    stack_alignment = 16
    if CONFIG['OS_TARGET'] == 'Darwin':
        ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/osx/' % TOPSRCDIR]
    elif CONFIG['OS_TARGET'] == 'WINNT':
        ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/win/' % TOPSRCDIR]
    elif CONFIG['OS_TARGET'] == 'Android':
        error('Platform %s is not expected' % CONFIG['OS_TARGET'])
    else:
        # The rest of the platforms are all Linux flavors
        # Linux,OpenBSD,NetBSD,FreeBSD,DragonFly,SunOS
        ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/linux/' % TOPSRCDIR]
elif CONFIG['CPU_ARCH'] == 'aarch64':
    stack_alignment = 16
    ASFLAGS += ['-I%s/dist/include/dav1d/' % TOPOBJDIR]
else:
    error('Cpu arch %s is not expected' % CONFIG['CPU_ARCH'])

# Set the macro here instead of config.h
if stack_alignment == 0:
    error('Stack alignment cannot be zero.')
DEFINES['STACK_ALIGNMENT'] = stack_alignment

if CONFIG['CPU_ARCH'] in ('x86', 'x86_64'):
    SOURCES += [
        '../../../third_party/dav1d/src/x86/cpu.c',
    ]

    EXPORTS.dav1d += [
        '../../../third_party/dav1d/src/x86/cpu.h',
        '../../../third_party/dav1d/src/x86/msac.h',
    ]

    # ASM source files
    if CONFIG['CPU_ARCH'] == 'x86_64':
        # Empty file on all other archs. Nasm produces
        # an error when it compiles empty files.
        SOURCES += [
            '../../../third_party/dav1d/src/x86/cdef.asm',
            '../../../third_party/dav1d/src/x86/film_grain.asm',
            '../../../third_party/dav1d/src/x86/ipred.asm',
            '../../../third_party/dav1d/src/x86/itx.asm',
            '../../../third_party/dav1d/src/x86/loopfilter.asm',
            '../../../third_party/dav1d/src/x86/looprestoration.asm',
            '../../../third_party/dav1d/src/x86/mc.asm',
            '../../../third_party/dav1d/src/x86/msac_init.c',
        ]

    SOURCES += [
        '../../../third_party/dav1d/src/x86/cdef_sse.asm',
        '../../../third_party/dav1d/src/x86/cpuid.asm',
        '../../../third_party/dav1d/src/x86/film_grain_ssse3.asm',
        '../../../third_party/dav1d/src/x86/ipred_ssse3.asm',
        '../../../third_party/dav1d/src/x86/itx_ssse3.asm',
        '../../../third_party/dav1d/src/x86/loopfilter_ssse3.asm',
        '../../../third_party/dav1d/src/x86/looprestoration_ssse3.asm',
        '../../../third_party/dav1d/src/x86/mc_ssse3.asm',
        '../../../third_party/dav1d/src/x86/msac.asm',
    ]

    # BITDEPTH
    relative_path = '../../../third_party/dav1d/src/x86/'
    bitdepth_basenames = [
        'cdef_init_tmpl.c',
        'film_grain_init_tmpl.c',
        'ipred_init_tmpl.c',
        'itx_init_tmpl.c',
        'loopfilter_init_tmpl.c',
        'looprestoration_init_tmpl.c',
        'mc_init_tmpl.c',
    ]

    GENERATED_FILES += [
        '16bd_%s' % p for p in bitdepth_basenames
    ]

    SOURCES += [
        '!16bd_%s' % p for p in bitdepth_basenames
    ]

    for f in bitdepth_basenames:
        a = GENERATED_FILES['16bd_%s' % f]
        a.script = '../generate_source.py:add_define'
        a.inputs = [relative_path + f]
        a.flags = ['BITDEPTH', '16']

    GENERATED_FILES += [
        '8bd_%s' % p for p in bitdepth_basenames
    ]

    SOURCES += [
        '!8bd_%s' % p for p in bitdepth_basenames
    ]

    for f in bitdepth_basenames:
        a = GENERATED_FILES['8bd_%s' % f]
        a.script = '../generate_source.py:add_define'
        a.inputs = [relative_path + f]
        a.flags = ['BITDEPTH', '8']
elif CONFIG['CPU_ARCH'] == 'arm' or CONFIG['CPU_ARCH'] == 'aarch64':
    SOURCES += [
        '../../../third_party/dav1d/src/arm/cpu.c',
    ]
    EXPORTS += [
        '../../../third_party/dav1d/src/arm/cpu.h',
        '../../../third_party/dav1d/src/arm/msac.h',
    ]

    # BITDEPTH c file
    relative_path = '../../../third_party/dav1d/src/arm/'
    bitdepth_basenames = [
        'cdef_init_tmpl.c',
        'ipred_init_tmpl.c',
        'itx_init_tmpl.c',
        'loopfilter_init_tmpl.c',
        'looprestoration_init_tmpl.c',
        'mc_init_tmpl.c',
    ]

    GENERATED_FILES += [
        '16bd_%s' % p for p in bitdepth_basenames
    ]

    SOURCES += [
        '!16bd_%s' % p for p in bitdepth_basenames
    ]

    for f in bitdepth_basenames:
        a = GENERATED_FILES['16bd_%s' % f]
        a.script = '../generate_source.py:add_define'
        a.inputs = [relative_path + f]
        a.flags = ['BITDEPTH', '16']

    GENERATED_FILES += [
        '8bd_%s' % p for p in bitdepth_basenames
    ]

    SOURCES += [
        '!8bd_%s' % p for p in bitdepth_basenames
    ]

    for f in bitdepth_basenames:
        a = GENERATED_FILES['8bd_%s' % f]
        a.script = '../generate_source.py:add_define'
        a.inputs = [relative_path + f]
        a.flags = ['BITDEPTH', '8']

    # BITDEPTH .S files
    if CONFIG['CPU_ARCH'] == 'aarch64':
        SOURCES += [
            '../../../third_party/dav1d/src/arm/64/cdef.S',
            '../../../third_party/dav1d/src/arm/64/cdef16.S',
            '../../../third_party/dav1d/src/arm/64/cdef_tmpl.S',
            '../../../third_party/dav1d/src/arm/64/ipred.S',
            '../../../third_party/dav1d/src/arm/64/itx.S',
            '../../../third_party/dav1d/src/arm/64/loopfilter.S',
            '../../../third_party/dav1d/src/arm/64/loopfilter16.S',
            '../../../third_party/dav1d/src/arm/64/looprestoration.S',
            '../../../third_party/dav1d/src/arm/64/looprestoration16.S',
            '../../../third_party/dav1d/src/arm/64/looprestoration_common.S',
            '../../../third_party/dav1d/src/arm/64/looprestoration_tmpl.S',
            '../../../third_party/dav1d/src/arm/64/mc.S',
            '../../../third_party/dav1d/src/arm/64/mc16.S',
            '../../../third_party/dav1d/src/arm/64/msac.S',
        ]
    elif CONFIG['CPU_ARCH'] == 'arm':
        SOURCES += [
            '../../../third_party/dav1d/src/arm/32/cdef.S',
            '../../../third_party/dav1d/src/arm/32/ipred.S',
            '../../../third_party/dav1d/src/arm/32/loopfilter.S',
            '../../../third_party/dav1d/src/arm/32/looprestoration.S',
            '../../../third_party/dav1d/src/arm/32/mc.S',
        ]

if CONFIG['CPU_ARCH'] in ('x86', 'x86_64'):
    USE_NASM = True
elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['OS_TARGET'] == 'WINNT':
    USE_INTEGRATED_CLANGCL_AS = True

FINAL_LIBRARY = 'gkmedias'

# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()