Plumb GuestView Detach API
[chromium-blink-merge.git] / third_party / opus / BUILD.gn
blob696234d9e2ec79efc826e2ea6341fb8480dd1998
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")
7 # If fixed point implementation shall be used (otherwise float).
8 use_opus_fixed_point = cpu_arch == "arm" || cpu_arch == "arm64"
10 # If ARM optimizations shall be used to accelerate performance.
11 use_opus_arm_optimization = cpu_arch == "arm"
13 # If OPUS Run Time CPU Detections (RTCD) shall be used.
14 # Based on the conditions in celt/arm/armcpu.c:
15 # defined(_MSC_VER) || defined(__linux__).
16 use_opus_rtcd = cpu_arch == "arm" && (is_win || is_android || is_linux)
18 config("opus_config") {
19   include_dirs = [ "src/include" ]
22 if (use_opus_rtcd) {
23   action("convert_rtcd_assembler") {
24     script = "convert_rtcd_assembler.py"
25     outputs = [ "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S" ]
26     args = [
27       rebase_path("//third_party/opus/src/celt/arm/arm2gnu.pl", root_build_dir),
28       rebase_path("//third_party/opus/src/celt/arm/celt_pitch_xcorr_arm.s",
29                   root_build_dir),
30       rebase_path("$target_gen_dir/celt_pitch_xcorr_arm_gnu.S", root_build_dir),
31     ]
32   }
35 source_set("opus") {
36   gypi_values = exec_script("//build/gypi_to_gn.py",
37                             [ rebase_path("opus_srcs.gypi") ],
38                             "scope",
39                             [ "opus_srcs.gypi" ])
40   sources = gypi_values.opus_common_sources
42   defines = [
43     "OPUS_BUILD",
44     "OPUS_EXPORT=",
45   ]
47   include_dirs = [
48     "src/celt",
49     "src/silk",
50   ]
52   configs -= [ "//build/config/compiler:chromium_code" ]
53   configs += [ "//build/config/compiler:no_chromium_code" ]
54   public_configs = [ ":opus_config" ]
56   if (is_win) {
57     defines += [
58       "USE_ALLOCA",
59       "inline=__inline",
60     ]
62     cflags = [
63       "/wd4305",  # Disable truncation warning in celt/pitch.c .
64       "/wd4334",  # Disable 32-bit shift warning in src/opus_encoder.c .
65     ]
66   } else {
67     defines += [
68       "HAVE_LRINT",
69       "HAVE_LRINTF",
70       "VAR_ARRAYS",
71     ]
72   }
74   if (is_posix && !is_android) {
75     # Suppress a warning given by opus_decoder.c that tells us
76     # optimizations are turned off.
77     cflags = [ "-Wno-#pragma-messages" ]
78   }
80   if (!is_debug && is_posix && (cpu_arch == "arm" || cpu_arch == "arm64")) {
81     configs -= [ "//build/config/compiler:optimize" ]
82     configs += [ "//build/config/compiler:optimize_max" ]
83   }
85   if (use_opus_fixed_point) {
86     sources += gypi_values.opus_fixed_sources
88     defines += [ "FIXED_POINT" ]
90     include_dirs += [ "src/silk/fixed" ]
91   } else {
92     sources += gypi_values.opus_float_sources
94     include_dirs += [ "src/silk/float" ]
95   }
97   if (use_opus_arm_optimization) {
98     sources += [
99       "src/celt/arm/fixed_armv4.h",
100       "src/celt/arm/fixed_armv5e.h",
101       "src/celt/arm/kiss_fft_armv4.h",
102       "src/celt/arm/kiss_fft_armv5e.h",
103       "src/celt/pitch_arm.h",
104       "src/silk/arm/macro_armv4.h",
105       "src/silk/arm/macro_armv5e.h",
106       "src/silk/arm/SigProc_FIX_armv4.h",
107       "src/silk/arm/SigProc_FIX_armv5e.h",
108     ]
110     defines += [
111       "OPUS_ARM_ASM",
112       "OPUS_ARM_INLINE_ASM",
113       "OPUS_ARM_INLINE_EDSP",
114     ]
116     if (use_opus_rtcd) {
117       sources += [
118         "src/celt/arm/arm_celt_map.c",
119         "src/celt/arm/armcpu.c",
120         "src/celt/arm/armcpu.h",
121         "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
122       ]
124       defines += [
125         "OPUS_ARM_MAY_HAVE_EDSP",
126         "OPUS_ARM_MAY_HAVE_MEDIA",
127         "OPUS_ARM_MAY_HAVE_NEON",
128         "OPUS_HAVE_RTCD",
129       ]
131       deps = [
132         ":convert_rtcd_assembler",
133       ]
134     }
135   }
138 executable("opus_demo") {
139   sources = [
140     "src/src/opus_demo.c",
141   ]
143   configs -= [ "//build/config/compiler:chromium_code" ]
144   configs += [ "//build/config/compiler:no_chromium_code" ]
146   include_dirs = [
147     "src/celt",
148     "src/silk",
149   ]
151   if (is_win) {
152     defines = [ "inline=__inline" ]
153   }
154   if (is_android) {
155     libs = [ "log" ]
156   }
157   if (is_clang) {
158     cflags = [ "-Wno-absolute-value" ]
159   }
161   deps = [
162     ":opus",
163   ]