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/.
8 BUG_COMPONENT = ("Core", "Audio/Video")
12 "include/opus_defines.h",
13 "include/opus_multistream.h",
14 "include/opus_types.h",
17 # We allow warnings for third-party code that can be updated from upstream.
18 AllowCompilerWarnings()
20 FINAL_LIBRARY = "gkcodecs"
23 DEFINES["OPUS_BUILD"] = True
24 DEFINES["OPUS_VERSION"] = "ab4e83598e7fc8b2ce82dc633a0fc0c452b629aa"
25 DEFINES["USE_ALLOCA"] = True
26 DEFINES["ENABLE_HARDENING"] = True
28 # Don"t export symbols
29 DEFINES["OPUS_EXPORT"] = ""
31 if CONFIG["TARGET_CPU"] == "arm" and CONFIG["GNU_AS"]:
32 DEFINES["OPUS_ARM_ASM"] = True
33 DEFINES["OPUS_ARM_EXTERNAL_ASM"] = True
34 DEFINES["OPUS_ARM_INLINE_ASM"] = True
35 if int(CONFIG["ARM_ARCH"]) >= 6:
36 DEFINES["OPUS_ARM_INLINE_EDSP"] = True
37 DEFINES["OPUS_ARM_MAY_HAVE_EDSP"] = True
38 DEFINES["OPUS_ARM_MAY_HAVE_MEDIA"] = True
39 DEFINES["OPUS_ARM_MAY_HAVE_NEON"] = True
41 if CONFIG["MOZ_DEBUG"]:
42 DEFINES["ENABLE_ASSERTIONS"] = True
44 if CONFIG["OS_ARCH"] in ("Linux", "Darwin", "DragonFly", "FreeBSD",
46 DEFINES["HAVE_LRINTF"] = True
48 if CONFIG["OS_ARCH"] == "WINNT":
49 DEFINES["inline"] = "__inline"
50 if CONFIG["CC_TYPE"] in ("clang", "gcc"):
51 DEFINES["HAVE_LRINTF"] = True
53 if CONFIG["OS_ARCH"] == "AIX":
54 DEFINES["alloca"] = "__alloca"
56 if CONFIG["OS_ARCH"] == "SunOS":
57 DEFINES["HAVE_ALLOCA_H"] = True
59 if not CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]:
60 DEFINES["FIXED_POINT"] = 1
61 DEFINES["DISABLE_FLOAT_API"] = True
63 if CONFIG["OS_ARCH"] == "Linux":
77 # sources.mozbuild is generated from gen-sources.py when a new libopus is
79 include("sources.mozbuild")
81 UNIFIED_SOURCES += celt_sources
82 UNIFIED_SOURCES += silk_sources
83 UNIFIED_SOURCES += opus_sources
84 SOURCES += opus_nonunified_sources
86 if CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]:
87 UNIFIED_SOURCES += silk_sources_float
88 UNIFIED_SOURCES += opus_sources_float
90 UNIFIED_SOURCES += silk_sources_fixed
92 if CONFIG["TARGET_CPU"] in ("x86", "x86_64"):
93 DEFINES["OPUS_HAVE_RTCD"] = True
94 DEFINES["CPU_INFO_BY_ASM"] = True
95 DEFINES["OPUS_X86_MAY_HAVE_SSE"] = True
96 DEFINES["OPUS_X86_MAY_HAVE_SSE2"] = True
97 DEFINES["OPUS_X86_MAY_HAVE_SSE4_1"] = True
98 DEFINES["OPUS_X86_MAY_HAVE_AVX"] = True
99 SOURCES += celt_sources_x86_rtcd
100 SOURCES += celt_sources_sse
101 SOURCES += celt_sources_sse2
102 SOURCES += celt_sources_sse4_1
103 SOURCES += silk_sources_x86_rtcd
104 SOURCES += silk_sources_sse4_1
105 if not CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]:
106 SOURCES += silk_sources_fixed_sse4_1
108 if f in celt_sources_sse:
109 SOURCES[f].flags += CONFIG["SSE_FLAGS"]
110 if f in celt_sources_sse2:
111 SOURCES[f].flags += CONFIG["SSE2_FLAGS"]
112 if f in celt_sources_sse4_1 or \
113 f in silk_sources_sse4_1 or \
114 f in silk_sources_fixed_sse4_1:
115 SOURCES[f].flags += ["-msse4.1"]
117 if CONFIG["TARGET_CPU"] == "arm" and CONFIG["GNU_AS"]:
118 SOURCES += celt_sources_arm_rtcd
120 "!celt_pitch_xcorr_arm-gnu.s"
122 # -Os is significantly slower, enable -O3 unless optimization is disabled
123 if CONFIG["MOZ_OPTIMIZE"]:
130 # These flags are a lie; they"re just used to enable the requisite
131 # opcodes; actual arch detection is done at runtime.
135 ASFLAGS += CONFIG["NEON_FLAGS"]
137 if CONFIG["TARGET_CPU"] == "aarch64" and CONFIG["CC_TYPE"] in ("clang", "gcc"):
138 DEFINES["OPUS_ARM_PRESUME_AARCH64_NEON_INTR"] = True
139 DEFINES["OPUS_ARM_PRESUME_NEON"] = True
140 DEFINES["OPUS_ARM_PRESUME_NEON_INTR"] = True
141 SOURCES += celt_sources_arm_neon_intr
142 SOURCES += silk_sources_arm_neon_intr
143 if CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]:
144 DEFINES["OPUS_ARM_MAY_HAVE_NEON"] = True
145 DEFINES["OPUS_ARM_MAY_HAVE_NEON_INTR"] = True
147 SOURCES += silk_sources_fixed_arm_neon_intr
149 # Suppress warnings in third-party code.
150 if CONFIG["CC_TYPE"] in ("clang", "gcc"):
151 if CONFIG["CC_TYPE"] == "clang":
152 CFLAGS += ["-Wno-#pragma-messages"]
154 # Add libFuzzer configuration directives
155 include("/tools/fuzzing/libfuzzer-config.mozbuild")