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# Add assembler flags and includes
8ASFLAGS += CONFIG['FFVPX_ASFLAGS']
9ASFLAGS += ['-I%s/media/ffvpx' % TOPSRCDIR]
10
11if CONFIG['FFVPX_ASFLAGS']:
12    if CONFIG['OS_ARCH'] == 'WINNT':
13        USE_YASM = True
14       # Fix inline symbols and math defines for windows.
15        DEFINES['_USE_MATH_DEFINES'] = True
16        DEFINES['inline'] = "__inline"
17        # 32-bit windows need to prefix symbols with an underscore.
18        if CONFIG['CPU_ARCH'] == 'x86':
19            ASFLAGS += ['-DPREFIX']
20            ASFLAGS += ['-Pconfig_win32.asm']
21        else:
22            ASFLAGS += ['-Pconfig_win64.asm']
23    elif CONFIG['OS_ARCH'] == 'Darwin':
24        USE_YASM = True
25        # 32/64-bit macosx assemblers need to prefix symbols with an underscore.
26        ASFLAGS += [
27            '-Pconfig_darwin64.asm',
28            '-DPREFIX'
29        ]
30    elif CONFIG['CPU_ARCH'] != 'arm' and CONFIG['CPU_ARCH'] != 'aarch4':
31        USE_YASM = True
32        # Default to unix, similar to how ASFLAGS setup works in configure.in
33        ASFLAGS += ['-Pconfig_unix64.asm']
34
35    if USE_YASM:
36        # default disabled components
37        ASFLAGS += ['-Pdefaults_disabled.asm']
38        if int(CONFIG['YASM_MAJOR_VERSION']) == 1 and int(CONFIG['YASM_MINOR_VERSION']) < 2:
39            DEFINES['YASM_MISSING_AVX2'] = True
40            ASFLAGS += [
41                '-DHAVE_AVX2=0',
42                '-DHAVE_AVX2_INTERNAL=0',
43                '-DHAVE_AVX2_EXTERNAL=0',
44            ]
45
46
47LOCAL_INCLUDES += ['/media/ffvpx']
48
49# We allow warnings for third-party code that can be updated from upstream.
50AllowCompilerWarnings()
51
52# Suppress warnings in third-party code.
53if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
54    CFLAGS += [
55        '-Wno-parentheses',
56        '-Wno-pointer-sign',
57        '-Wno-sign-compare',
58        '-Wno-switch',
59        '-Wno-type-limits',
60        '-Wno-unused-function',
61        # XXX This does not seem to have any effect on some versions of GCC.
62        '-Wno-deprecated-declarations',
63    ]
64    if CONFIG['CC_TYPE'] == 'clang':
65        CFLAGS += [
66            '-Wno-incompatible-pointer-types-discards-qualifiers',
67            '-Wno-string-conversion',
68            '-Wno-visibility',
69            # Workaround for https://bugs.llvm.org/show_bug.cgi?id=26828#c4 :
70            '-ffreestanding',
71        ]
72    else:
73        CFLAGS += [
74            '-Wno-discarded-qualifiers',
75            '-Wno-maybe-uninitialized',
76        ]
77    # Force visibility of cpu and av_log symbols.
78    CFLAGS += ['-include', 'libavutil_visibility.h']
79elif CONFIG['CC_TYPE'] in ('msvc', 'clang-cl'):
80    CFLAGS += [
81        '-wd4090', # 'return' : different 'const' qualifiers
82        '-wd4018', # '>' : signed/unsigned mismatch
83        '-wd4305', # 'initializing' : truncation from '__int64' to 'double'
84        '-wd4554', # '>>' : check operator precedence for possible error
85        '-wd4307', # '+' : integral constant overflow'
86        '-wd4028', # formal parameter 1 different from declaration
87        '-wd4056', # overflow in floating-point constant arithmetic
88        '-wd4756', # overflow in constant arithmetic
89        '-wd4005', #'WIN32_LEAN_AND_MEAN' : macro redefinition
90        '-wd4054', # 'type cast' : from function pointer 'FARPROC' to data pointer 'void *'
91        '-wd4189', # local variable is initialized but not referenced
92        '-wd4133', # 'function' : incompatible types - from 'AVSampleFormat *' to 'int *'
93        '-wd4221', # nonstandard extension used
94        '-wd4206', # nonstandard extension used
95        '-wd4702', # unreachable code
96        '-wd4101', # unreferenced local variable
97        '-wd4245', # conversion from 'int' to 'uint32_t', signed/unsigned mismatch
98        '-wd4703', # potentially uninitialized local pointer
99        '-wd4293', # '<<' : shift count negative or too big, undefined behavior
100        '-wd4334', # '<<' : result of 32-bit shift implicitly converted to 64 bits
101        '-wd4996', # The compiler encountered a deprecated declaration.
102        # from FFmpeg configure
103        '-wd4244', '-wd4127', '-wd4018', '-wd4389', '-wd4146', '-wd4701',
104        '-wd4057', '-wd4204', '-wd4706', '-wd4305', '-wd4152', '-wd4324',
105        '-we4013', '-wd4100', '-wd4214', '-wd4307', '-wd4273', '-wd4554',
106    ]
107    LOCAL_INCLUDES += ['/media/ffvpx/compat/atomics/win32']
108DEFINES['HAVE_AV_CONFIG_H'] = True
109
110if CONFIG['MOZ_DEBUG']:
111    # Enable all assertions in debug builds.
112    DEFINES['ASSERT_LEVEL'] = 2
113elif not CONFIG['RELEASE_OR_BETA']:
114    # Enable fast assertions in opt builds of Nightly and Aurora.
115    DEFINES['ASSERT_LEVEL'] = 1
116