moz.build (5183B)
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 with Files("*"): 8 BUG_COMPONENT = ("Core", "Audio/Video") 9 10 EXPORTS.opus += [ 11 "include/opus.h", 12 "include/opus_defines.h", 13 "include/opus_multistream.h", 14 "include/opus_types.h", 15 ] 16 17 # We allow warnings for third-party code that can be updated from upstream. 18 AllowCompilerWarnings() 19 20 FINAL_LIBRARY = "gkcodecs" 21 NoVisibilityFlags() 22 23 DEFINES["OPUS_BUILD"] = True 24 DEFINES["OPUS_VERSION"] = "807c93d1b539e6e097e1e437b6d4603b67a7bc10" 25 DEFINES["USE_ALLOCA"] = True 26 DEFINES["ENABLE_HARDENING"] = True 27 28 # Don"t export symbols 29 DEFINES["OPUS_EXPORT"] = "" 30 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 40 41 if CONFIG["MOZ_DEBUG"]: 42 DEFINES["ENABLE_ASSERTIONS"] = True 43 44 if CONFIG["OS_ARCH"] in ("Linux", "Darwin", "DragonFly", "FreeBSD", 45 "NetBSD", "OpenBSD"): 46 DEFINES["HAVE_LRINTF"] = True 47 48 if CONFIG["OS_ARCH"] == "WINNT": 49 DEFINES["inline"] = "__inline" 50 if CONFIG["CC_TYPE"] in ("clang", "gcc"): 51 DEFINES["HAVE_LRINTF"] = True 52 53 54 if CONFIG["OS_ARCH"] == "SunOS": 55 DEFINES["HAVE_ALLOCA_H"] = True 56 57 if not CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]: 58 DEFINES["FIXED_POINT"] = 1 59 DEFINES["DISABLE_FLOAT_API"] = True 60 61 if CONFIG["OS_ARCH"] == "Linux": 62 OS_LIBS += [ 63 "m", 64 ] 65 66 LOCAL_INCLUDES += [ 67 "celt", 68 "include", 69 "silk", 70 "silk/fixed", 71 "silk/float", 72 "src", 73 ] 74 75 # sources.mozbuild is generated from gen-sources.py when a new libopus is 76 # imported. 77 include("sources.mozbuild") 78 79 UNIFIED_SOURCES += celt_sources 80 UNIFIED_SOURCES += silk_sources 81 UNIFIED_SOURCES += opus_sources 82 SOURCES += opus_nonunified_sources 83 84 if CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]: 85 UNIFIED_SOURCES += silk_sources_float 86 UNIFIED_SOURCES += opus_sources_float 87 else: 88 UNIFIED_SOURCES += silk_sources_fixed 89 90 if CONFIG["TARGET_CPU"] in ("x86", "x86_64"): 91 DEFINES["OPUS_HAVE_RTCD"] = True 92 DEFINES["CPU_INFO_BY_ASM"] = True 93 DEFINES["OPUS_X86_MAY_HAVE_SSE"] = True 94 DEFINES["OPUS_X86_MAY_HAVE_SSE2"] = True 95 DEFINES["OPUS_X86_MAY_HAVE_SSE4_1"] = True 96 DEFINES["OPUS_X86_MAY_HAVE_AVX"] = True 97 SOURCES += celt_sources_x86_rtcd 98 SOURCES += celt_sources_sse 99 SOURCES += celt_sources_sse2 100 SOURCES += celt_sources_sse4_1 101 SOURCES += silk_sources_x86_rtcd 102 SOURCES += silk_sources_sse4_1 103 if not CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]: 104 SOURCES += silk_sources_fixed_sse4_1 105 for f in SOURCES: 106 if f in celt_sources_sse: 107 SOURCES[f].flags += CONFIG["SSE_FLAGS"] 108 if f in celt_sources_sse2: 109 SOURCES[f].flags += CONFIG["SSE2_FLAGS"] 110 if f in celt_sources_sse4_1 or \ 111 f in silk_sources_sse4_1 or \ 112 f in silk_sources_fixed_sse4_1: 113 SOURCES[f].flags += ["-msse4.1"] 114 115 if CONFIG["TARGET_CPU"] == "arm" and CONFIG["GNU_AS"]: 116 GeneratedFile( 117 "celt_pitch_xcorr_arm-gnu.s", 118 script="arm2gnu.py", 119 entry_point="generate", 120 inputs=["celt/arm/arm2gnu.pl", "celt/arm/celt_pitch_xcorr_arm.s"], 121 ) 122 GeneratedFile( 123 "celt/arm/armopts-gnu.S", 124 script="arm2gnu.py", 125 entry_point="generate", 126 inputs=["celt/arm/arm2gnu.pl", 127 "celt/arm/armopts.s"], 128 ) 129 130 SOURCES += celt_sources_arm_rtcd 131 SOURCES += [ 132 "!celt_pitch_xcorr_arm-gnu.s" 133 ] 134 # -Os is significantly slower, enable -O3 unless optimization is disabled 135 if CONFIG["MOZ_OPTIMIZE"]: 136 CFLAGS += [ 137 "-O3", 138 ] 139 CXXFLAGS += [ 140 "-O3", 141 ] 142 # These flags are a lie; they"re just used to enable the requisite 143 # opcodes; actual arch detection is done at runtime. 144 ASFLAGS += [ 145 "-march=armv7-a", 146 ] 147 ASFLAGS += CONFIG["NEON_FLAGS"] 148 149 if CONFIG["TARGET_CPU"] == "aarch64" and CONFIG["CC_TYPE"] in ("clang", "gcc"): 150 DEFINES["OPUS_ARM_PRESUME_AARCH64_NEON_INTR"] = True 151 DEFINES["OPUS_ARM_PRESUME_NEON"] = True 152 DEFINES["OPUS_ARM_PRESUME_NEON_INTR"] = True 153 SOURCES += celt_sources_arm_neon_intr 154 SOURCES += silk_sources_arm_neon_intr 155 if CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]: 156 DEFINES["OPUS_ARM_MAY_HAVE_NEON"] = True 157 DEFINES["OPUS_ARM_MAY_HAVE_NEON_INTR"] = True 158 else: 159 SOURCES += silk_sources_fixed_arm_neon_intr 160 161 # Suppress warnings in third-party code. 162 if CONFIG["CC_TYPE"] in ("clang", "gcc"): 163 if CONFIG["CC_TYPE"] == "clang": 164 CFLAGS += ["-Wno-#pragma-messages"] 165 166 # Add libFuzzer configuration directives 167 include("/tools/fuzzing/libfuzzer-config.mozbuild")