Revert of Add build targets for Opus tests. (patchset #2 id:20001 of https://coderevi...
[chromium-blink-merge.git] / third_party / opus / BUILD.gn
blob8f51d09ffd4bd6f8808bf4054fbcb919465b4795
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/arm.gni")
6 import("//build/config/mips.gni")
8 # If fixed point implementation shall be used (otherwise float).
9 # TODO(wtc): change "mipselx" to "mipsel" in this file when the compilation
10 # errors in the MIPS optimizations are fixed.
11 use_opus_fixed_point =
12     cpu_arch == "arm" || cpu_arch == "arm64" || cpu_arch == "mipselx"
14 # If ARM optimizations shall be used to accelerate performance.
15 use_opus_arm_optimization = cpu_arch == "arm"
17 # If MIPS optimizations shall be used to accelerate performance.
18 use_opus_mips_optimization = cpu_arch == "mipselx"
20 # If OPUS Run Time CPU Detections (RTCD) shall be used.
21 # Based on the conditions in celt/arm/armcpu.c:
22 # defined(_MSC_VER) || defined(__linux__).
23 use_opus_rtcd = cpu_arch == "arm" && (is_win || is_android || is_linux)
25 config("opus_config") {
26   include_dirs = [ "src/include" ]
29 if (use_opus_rtcd) {
30   action("convert_rtcd_assembler") {
31     script = "convert_rtcd_assembler.py"
32     outputs = [
33       "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
34     ]
35     args = [
36       rebase_path("//third_party/opus/src/celt/arm/arm2gnu.pl", root_build_dir),
37       rebase_path("//third_party/opus/src/celt/arm/celt_pitch_xcorr_arm.s",
38                   root_build_dir),
39       rebase_path("$target_gen_dir/celt_pitch_xcorr_arm_gnu.S", root_build_dir),
40     ]
41   }
44 source_set("opus") {
45   gypi_values = exec_script("//build/gypi_to_gn.py",
46                             [ rebase_path("opus_srcs.gypi") ],
47                             "scope",
48                             [ "opus_srcs.gypi" ])
49   sources = gypi_values.opus_common_sources
51   defines = [
52     "OPUS_BUILD",
53     "OPUS_EXPORT=",
54   ]
56   include_dirs = [
57     "src/celt",
58     "src/silk",
59   ]
61   configs -= [ "//build/config/compiler:chromium_code" ]
62   configs += [ "//build/config/compiler:no_chromium_code" ]
63   public_configs = [ ":opus_config" ]
65   if (is_win) {
66     defines += [
67       "USE_ALLOCA",
68       "inline=__inline",
69     ]
71     cflags = [
72       "/wd4305",  # Disable truncation warning in celt/pitch.c .
73       "/wd4334",  # Disable 32-bit shift warning in src/opus_encoder.c .
74     ]
75   } else {
76     defines += [
77       "HAVE_LRINT",
78       "HAVE_LRINTF",
79       "VAR_ARRAYS",
80     ]
81   }
83   if (is_posix && !is_android) {
84     # Suppress a warning given by opus_decoder.c that tells us
85     # optimizations are turned off.
86     cflags = [ "-Wno-#pragma-messages" ]
87   }
89   if (!is_debug && is_posix && (cpu_arch == "arm" || cpu_arch == "arm64")) {
90     configs -= [ "//build/config/compiler:optimize" ]
91     configs += [ "//build/config/compiler:optimize_max" ]
92   }
94   if (use_opus_fixed_point) {
95     sources += gypi_values.opus_fixed_sources
97     defines += [ "FIXED_POINT" ]
99     include_dirs += [ "src/silk/fixed" ]
100   } else {
101     sources += gypi_values.opus_float_sources
103     include_dirs += [ "src/silk/float" ]
104   }
106   if (use_opus_arm_optimization) {
107     sources += [
108       "src/celt/arm/fixed_armv4.h",
109       "src/celt/arm/fixed_armv5e.h",
110       "src/celt/arm/kiss_fft_armv4.h",
111       "src/celt/arm/kiss_fft_armv5e.h",
112       "src/celt/pitch_arm.h",
113       "src/silk/arm/macro_armv4.h",
114       "src/silk/arm/macro_armv5e.h",
115       "src/silk/arm/SigProc_FIX_armv4.h",
116       "src/silk/arm/SigProc_FIX_armv5e.h",
117     ]
119     defines += [
120       "OPUS_ARM_ASM",
121       "OPUS_ARM_INLINE_ASM",
122       "OPUS_ARM_INLINE_EDSP",
123     ]
125     if (use_opus_rtcd) {
126       sources += [
127         "src/celt/arm/arm_celt_map.c",
128         "src/celt/arm/armcpu.c",
129         "src/celt/arm/armcpu.h",
130         "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
131       ]
133       defines += [
134         "OPUS_ARM_MAY_HAVE_EDSP",
135         "OPUS_ARM_MAY_HAVE_MEDIA",
136         "OPUS_ARM_MAY_HAVE_NEON",
137         "OPUS_HAVE_RTCD",
138       ]
140       deps = [
141         ":convert_rtcd_assembler",
142       ]
143     }
144   }
146   if (use_opus_mips_optimization) {
147     sources += [
148       "src/celt/mips/celt_mipsr1.h",
149       "src/celt/mips/fixed_generic_mipsr1.h",
150       "src/celt/mips/kiss_fft_mipsr1.h",
151       "src/celt/mips/mdct_mipsr1.h",
152       "src/celt/mips/pitch_mipsr1.h",
153       "src/celt/mips/vq_mipsr1.c",
154       "src/celt/mips/vq_mipsr1.h",
155       "src/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h",
156       "src/silk/fixed/mips/prefilter_FIX_mipsr1.h",
157       "src/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h",
158       "src/silk/mips/NSQ_del_dec_mipsr1.h",
159       "src/silk/mips/macros_mipsr1.h",
160       "src/silk/mips/sigproc_fix_mipsr1.h",
161     ]
163     defines += [
164       "MIPSr1_ASM",
165       "USE_ALLOCA",
166     ]
167   }
170 executable("opus_compare") {
171   sources = [
172     "src/src/opus_compare.c",
173   ]
175   configs -= [ "//build/config/compiler:chromium_code" ]
176   configs += [ "//build/config/compiler:no_chromium_code" ]
178   include_dirs = [
179     "src/celt",
180     "src/silk",
181   ]
183   if (is_win) {
184     defines = [ "inline=__inline" ]
185   }
186   if (is_android) {
187     libs = [ "log" ]
188   }
189   if (is_clang) {
190     cflags = [ "-Wno-absolute-value" ]
191   }
193   deps = [
194     ":opus",
195   ]
198 executable("opus_demo") {
199   sources = [
200     "src/src/opus_demo.c",
201   ]
203   configs -= [ "//build/config/compiler:chromium_code" ]
204   configs += [ "//build/config/compiler:no_chromium_code" ]
206   include_dirs = [
207     "src/celt",
208     "src/silk",
209   ]
211   if (is_win) {
212     defines = [ "inline=__inline" ]
213   }
214   if (is_android) {
215     libs = [ "log" ]
216   }
217   if (is_clang) {
218     cflags = [ "-Wno-absolute-value" ]
219   }
221   deps = [
222     ":opus",
223   ]