2
0

BUILD.gn 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. # Copyright 2014 The LibYuv Project Authors. All rights reserved.
  2. #
  3. # Use of this source code is governed by a BSD-style license
  4. # that can be found in the LICENSE file in the root of the source
  5. # tree. An additional intellectual property rights grant can be found
  6. # in the file PATENTS. All contributing project authors may
  7. # be found in the AUTHORS file in the root of the source tree.
  8. import("libyuv.gni")
  9. import("//testing/test.gni")
  10. config("libyuv_config") {
  11. include_dirs = [ "include" ]
  12. if (is_android && current_cpu=="arm64") {
  13. ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64" ]
  14. }
  15. if (is_android && current_cpu != "arm64") {
  16. ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker" ]
  17. }
  18. }
  19. static_library("libyuv") {
  20. sources = [
  21. # Headers
  22. "include/libyuv.h",
  23. "include/libyuv/basic_types.h",
  24. "include/libyuv/compare.h",
  25. "include/libyuv/convert.h",
  26. "include/libyuv/convert_argb.h",
  27. "include/libyuv/convert_from.h",
  28. "include/libyuv/convert_from_argb.h",
  29. "include/libyuv/cpu_id.h",
  30. "include/libyuv/mjpeg_decoder.h",
  31. "include/libyuv/planar_functions.h",
  32. "include/libyuv/rotate.h",
  33. "include/libyuv/rotate_argb.h",
  34. "include/libyuv/rotate_row.h",
  35. "include/libyuv/row.h",
  36. "include/libyuv/scale.h",
  37. "include/libyuv/scale_argb.h",
  38. "include/libyuv/scale_row.h",
  39. "include/libyuv/version.h",
  40. "include/libyuv/video_common.h",
  41. # Source Files
  42. "source/compare.cc",
  43. "source/compare_common.cc",
  44. "source/compare_gcc.cc",
  45. "source/compare_win.cc",
  46. "source/convert.cc",
  47. "source/convert_argb.cc",
  48. "source/convert_from.cc",
  49. "source/convert_from_argb.cc",
  50. "source/convert_jpeg.cc",
  51. "source/convert_to_argb.cc",
  52. "source/convert_to_i420.cc",
  53. "source/cpu_id.cc",
  54. "source/mjpeg_decoder.cc",
  55. "source/mjpeg_validate.cc",
  56. "source/planar_functions.cc",
  57. "source/rotate.cc",
  58. "source/rotate_any.cc",
  59. "source/rotate_argb.cc",
  60. "source/rotate_common.cc",
  61. "source/rotate_mips.cc",
  62. "source/rotate_gcc.cc",
  63. "source/rotate_win.cc",
  64. "source/row_any.cc",
  65. "source/row_common.cc",
  66. "source/row_mips.cc",
  67. "source/row_gcc.cc",
  68. "source/row_win.cc",
  69. "source/scale.cc",
  70. "source/scale_any.cc",
  71. "source/scale_argb.cc",
  72. "source/scale_common.cc",
  73. "source/scale_mips.cc",
  74. "source/scale_gcc.cc",
  75. "source/scale_win.cc",
  76. "source/video_common.cc",
  77. ]
  78. public_configs = [ ":libyuv_config" ]
  79. defines = []
  80. deps = []
  81. if (!is_ios) {
  82. defines += [ "HAVE_JPEG" ]
  83. deps += [ "//third_party:jpeg" ]
  84. }
  85. if (libyuv_use_neon) {
  86. deps += [ ":libyuv_neon" ]
  87. }
  88. if (libyuv_use_msa) {
  89. deps += [ ":libyuv_msa" ]
  90. }
  91. if (is_nacl) {
  92. # Always enable optimization under NaCl to workaround crbug.com/538243 .
  93. configs -= [ "//build/config/compiler:default_optimization" ]
  94. configs += [ "//build/config/compiler:optimize_max" ]
  95. }
  96. }
  97. if (libyuv_use_neon) {
  98. static_library("libyuv_neon") {
  99. sources = [
  100. # ARM Source Files
  101. "source/compare_neon.cc",
  102. "source/compare_neon64.cc",
  103. "source/rotate_neon.cc",
  104. "source/rotate_neon64.cc",
  105. "source/row_neon.cc",
  106. "source/row_neon64.cc",
  107. "source/scale_neon.cc",
  108. "source/scale_neon64.cc",
  109. ]
  110. public_configs = [ ":libyuv_config" ]
  111. if (current_cpu != "arm64") {
  112. configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
  113. cflags = [ "-mfpu=neon" ]
  114. }
  115. }
  116. }
  117. if (libyuv_use_msa) {
  118. static_library("libyuv_msa") {
  119. sources = [
  120. # MSA Source Files
  121. "source/row_msa.cc",
  122. ]
  123. public_configs = [ ":libyuv_config" ]
  124. }
  125. }
  126. if (libyuv_include_tests) {
  127. config("libyuv_unittest_warnings_config") {
  128. if (!is_win) {
  129. cflags = [
  130. # TODO(fbarchard): Fix sign and unused variable warnings.
  131. "-Wno-sign-compare",
  132. "-Wno-unused-variable"
  133. ]
  134. }
  135. if (is_win) {
  136. cflags = [
  137. "/wd4245", # signed/unsigned mismatch
  138. "/wd4189", # local variable is initialized but not referenced
  139. ]
  140. }
  141. }
  142. config("libyuv_unittest_config") {
  143. defines = [ "GTEST_RELATIVE_PATH" ]
  144. }
  145. test("libyuv_unittest") {
  146. testonly = true
  147. sources = [
  148. # headers
  149. "unit_test/unit_test.h",
  150. # sources
  151. "unit_test/basictypes_test.cc",
  152. "unit_test/compare_test.cc",
  153. "unit_test/color_test.cc",
  154. "unit_test/convert_test.cc",
  155. "unit_test/cpu_test.cc",
  156. "unit_test/math_test.cc",
  157. "unit_test/planar_test.cc",
  158. "unit_test/rotate_argb_test.cc",
  159. "unit_test/rotate_test.cc",
  160. "unit_test/scale_argb_test.cc",
  161. "unit_test/scale_test.cc",
  162. "unit_test/unit_test.cc",
  163. "unit_test/video_common_test.cc",
  164. ]
  165. deps = [
  166. ":libyuv",
  167. "//testing/gtest",
  168. "//third_party/gflags",
  169. ]
  170. configs += [ ":libyuv_unittest_warnings_config" ]
  171. public_deps = [ "//testing/gtest" ]
  172. public_configs = [ ":libyuv_unittest_config" ]
  173. defines = []
  174. if (is_linux) {
  175. cflags = [ "-fexceptions" ]
  176. }
  177. if (is_ios) {
  178. configs -= [ "//build/config/compiler:default_symbols" ]
  179. configs += [ "//build/config/compiler:symbols" ]
  180. cflags = [ "-Wno-sometimes-uninitialized" ]
  181. }
  182. if (!is_ios && !libyuv_disable_jpeg) {
  183. defines += [ "HAVE_JPEG" ]
  184. }
  185. if (is_android) {
  186. deps += [ "//testing/android/native_test:native_test_native_code" ]
  187. }
  188. # TODO(YangZhang): These lines can be removed when high accuracy
  189. # YUV to RGB to Neon is ported.
  190. if ((target_cpu=="armv7" || target_cpu=="armv7s" ||
  191. (target_cpu=="arm" && arm_version >= 7) || target_cpu=="arm64") &&
  192. (arm_use_neon || arm_optionally_use_neon)) {
  193. defines += [ "LIBYUV_NEON" ]
  194. }
  195. defines += [
  196. # Enable the following 3 macros to turn off assembly for specified CPU.
  197. # "LIBYUV_DISABLE_X86",
  198. # "LIBYUV_DISABLE_NEON",
  199. # "LIBYUV_DISABLE_MIPS",
  200. # Enable the following macro to build libyuv as a shared library (dll).
  201. # "LIBYUV_USING_SHARED_LIBRARY"
  202. ]
  203. }
  204. executable("compare") {
  205. sources = [
  206. # sources
  207. "util/compare.cc"
  208. ]
  209. deps = [ ":libyuv" ]
  210. if (is_linux) {
  211. cflags = [ "-fexceptions" ]
  212. }
  213. }
  214. executable("convert") {
  215. sources = [
  216. # sources
  217. "util/convert.cc"
  218. ]
  219. deps = [ ":libyuv" ]
  220. if (is_linux) {
  221. cflags = [ "-fexceptions" ]
  222. }
  223. }
  224. executable("psnr") {
  225. sources = [
  226. # sources
  227. "util/psnr_main.cc",
  228. "util/psnr.cc",
  229. "util/ssim.cc"
  230. ]
  231. deps = [ ":libyuv" ]
  232. if (!is_ios && !libyuv_disable_jpeg) {
  233. defines = [ "HAVE_JPEG" ]
  234. }
  235. }
  236. executable("cpuid") {
  237. sources = [
  238. # sources
  239. "util/cpuid.c"
  240. ]
  241. deps = [ ":libyuv" ]
  242. }
  243. }