BUILD.gn 5.4 KB

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