Fix for Geolocation webTCT failures
[platform/framework/web/chromium-efl.git] / third_party / openh264 / BUILD.gn
1 # Copyright 2015 The Chromium Authors
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import("//build/config/chromeos/ui_mode.gni")
6 import("//build/config/sanitizers/sanitizers.gni")
7 import("//third_party/nasm/nasm_assemble.gni")
8 import("//third_party/openh264/openh264_sources.gni")
9
10 # Config shared by all openh264 targets.
11 config("config") {
12   cflags = []
13   defines = []
14
15   if (is_chromeos && current_cpu == "arm") {
16     # HAVE_NEON and __chromeos__ are needed for enabling NEON on ChromeOS
17     # devices.
18     defines += [
19       "HAVE_NEON",
20       "__chromeos__",
21     ]
22   }
23
24   # GCC and clang flags. MSVS (is_win && !is_clang) does not use cflags.
25   if (!is_win || is_clang) {
26     cflags += [
27       "-Wno-format",
28       "-Wno-format-security",
29       "-Wno-header-hygiene",
30       "-Wno-unused-function",
31       "-Wno-unused-value",
32     ]
33   }
34
35   # Platform-specific defines.
36   if (is_android) {
37     # Android NDK is necessary for its cpufeatures and this define is what
38     # OpenH264 code uses to check if it should be used.
39     defines += [ "ANDROID_NDK" ]
40   }
41 }
42
43 # MSAN builds are flaky with assembler. crbug.com/685168
44
45 use_assembler = (is_win || is_mac || is_linux || is_chromeos) &&
46                 (current_cpu == "x86" || current_cpu == "x64") && !is_msan
47
48 # This IF statement will make the targets visible only on specific builds,
49 # which will lead to failures on other platforms if accidentally invoked.
50 if (use_assembler) {
51   asm_defines = []
52   if (!is_component_build) {
53     if (is_apple) {
54       asm_defines += [ "WELS_PRIVATE_EXTERN=private_extern" ]
55     } else if (is_linux || is_chromeos || is_android || is_fuchsia) {
56       asm_defines += [ "WELS_PRIVATE_EXTERN=hidden" ]
57     }
58   }
59
60   nasm_assemble("openh264_common_asm") {
61     include_dirs = openh264_common_include_dirs
62     sources = openh264_common_sources_asm_x86
63     defines = asm_defines
64     if (current_cpu == "x86") {
65       defines += [
66         "X86_32",
67         "X86_32_PICASM",
68       ]
69     } else {  # x64
70       if (is_mac) {
71         defines += [
72           "PREFIX",
73           "UNIX64",
74         ]
75       } else if (is_win) {
76         defines += [ "WIN64" ]
77       } else if (is_linux || is_chromeos) {
78         defines += [ "UNIX64" ]
79       }
80     }
81   }
82
83   nasm_assemble("openh264_processing_asm") {
84     include_dirs = openh264_processing_include_dirs
85     include_dirs += [ "./src/codec/common/x86" ]
86     sources = openh264_processing_sources_asm_x86
87     defines = asm_defines
88     if (current_cpu == "x86") {
89       defines += [
90         "X86_32",
91         "X86_32_PICASM",
92       ]
93     } else {  # x64
94       if (is_mac) {
95         defines += [
96           "PREFIX",
97           "UNIX64",
98         ]
99       } else if (is_win) {
100         defines += [ "WIN64" ]
101       } else if (is_linux || is_chromeos) {
102         defines += [ "UNIX64" ]
103       }
104     }
105   }
106
107   nasm_assemble("openh264_encoder_asm") {
108     include_dirs = openh264_encoder_include_dirs
109     include_dirs += [ "./src/codec/common/x86" ]
110     sources = openh264_encoder_sources_asm_x86
111     defines = asm_defines
112     if (current_cpu == "x86") {
113       defines += [
114         "X86_32",
115         "X86_32_PICASM",
116       ]
117     } else {  # x64
118       if (is_mac) {
119         defines += [
120           "PREFIX",
121           "UNIX64",
122         ]
123       } else if (is_win) {
124         defines += [ "WIN64" ]
125       } else if (is_linux || is_chromeos) {
126         defines += [ "UNIX64" ]
127       }
128     }
129   }
130 }  # if (is_win || is_linux || is_chromeos)
131
132 source_set("common") {
133   sources = openh264_common_sources
134   if (is_chromeos && current_cpu == "arm") {
135     sources += openh264_common_sources_asm_arm
136   }
137   include_dirs = openh264_common_include_dirs
138
139   configs -= [ "//build/config/compiler:chromium_code" ]
140   configs += [ "//build/config/compiler:no_chromium_code" ]
141   configs += [ ":config" ]
142   deps = []
143   if (use_assembler) {
144     defines = [ "X86_ASM" ]
145     deps += [ ":openh264_common_asm" ]
146   }
147   if (is_android) {
148     deps += [
149       # Defines "android_get/setCpu..." functions. The original OpenH264 build
150       # files replaces these using macros for "wels_..." versions of the same
151       # functions. We do not have access to these and use the <cpu-features.h>
152       # ones instead.
153       "//third_party/cpu_features:ndk_compat",
154     ]
155   }
156 }
157
158 source_set("processing") {
159   sources = openh264_processing_sources
160   if (is_chromeos && current_cpu == "arm") {
161     sources += openh264_processing_sources_asm_arm
162   }
163   include_dirs = openh264_processing_include_dirs
164
165   configs -= [ "//build/config/compiler:chromium_code" ]
166   configs += [ "//build/config/compiler:no_chromium_code" ]
167   configs += [ ":config" ]
168   deps = [ ":common" ]
169   if (use_assembler) {
170     defines = [ "X86_ASM" ]
171     deps += [ ":openh264_processing_asm" ]
172   }
173 }
174
175 source_set("encoder") {
176   sources = openh264_encoder_sources
177   if (is_chromeos && current_cpu == "arm") {
178     sources += openh264_encoder_sources_asm_arm
179   }
180   include_dirs = openh264_encoder_include_dirs
181
182   configs -= [ "//build/config/compiler:chromium_code" ]
183   configs += [ "//build/config/compiler:no_chromium_code" ]
184   configs += [ ":config" ]
185
186   # TODO: Remove after fixing always-true condition
187   # third_party/openh264/src/codec/encoder/core/src/encoder_ext.cpp:142.
188   if (is_clang) {
189     configs -= [ "//build/config/clang:extra_warnings" ]
190   }
191   deps = [
192     ":common",
193     ":processing",
194   ]
195   if (use_assembler) {
196     defines = [ "X86_ASM" ]
197     deps += [ ":openh264_encoder_asm" ]
198   }
199 }