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 9import("libyuv.gni") 10import("//testing/test.gni") 11 12config("libyuv_config") { 13 include_dirs = [ "include" ] 14 if (is_android && current_cpu == "arm64") { 15 ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64" ] 16 } 17 if (is_android && current_cpu != "arm64") { 18 ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker" ] 19 } 20} 21 22# This target is built when no specific target is specified on the command line. 23group("default") { 24 testonly = true 25 deps = [ 26 ":libyuv", 27 ] 28 if (libyuv_include_tests) { 29 deps += [ 30 ":compare", 31 ":convert", 32 ":cpuid", 33 ":libyuv_unittest", 34 ":psnr", 35 ] 36 } 37} 38 39group("libyuv") { 40 public_configs = [ ":libyuv_config" ] 41 42 if (is_win && target_cpu == "x64") { 43 public_deps = [ 44 ":libyuv_internal(//build/toolchain/win:clang_x64)", 45 ] 46 } else { 47 public_deps = [ 48 ":libyuv_internal", 49 ] 50 } 51} 52 53static_library("libyuv_internal") { 54 sources = [ 55 # Headers 56 "include/libyuv.h", 57 "include/libyuv/basic_types.h", 58 "include/libyuv/compare.h", 59 "include/libyuv/convert.h", 60 "include/libyuv/convert_argb.h", 61 "include/libyuv/convert_from.h", 62 "include/libyuv/convert_from_argb.h", 63 "include/libyuv/cpu_id.h", 64 "include/libyuv/mjpeg_decoder.h", 65 "include/libyuv/planar_functions.h", 66 "include/libyuv/rotate.h", 67 "include/libyuv/rotate_argb.h", 68 "include/libyuv/rotate_row.h", 69 "include/libyuv/row.h", 70 "include/libyuv/scale.h", 71 "include/libyuv/scale_argb.h", 72 "include/libyuv/scale_row.h", 73 "include/libyuv/version.h", 74 "include/libyuv/video_common.h", 75 76 # Source Files 77 "source/compare.cc", 78 "source/compare_common.cc", 79 "source/compare_gcc.cc", 80 "source/compare_win.cc", 81 "source/convert.cc", 82 "source/convert_argb.cc", 83 "source/convert_from.cc", 84 "source/convert_from_argb.cc", 85 "source/convert_jpeg.cc", 86 "source/convert_to_argb.cc", 87 "source/convert_to_i420.cc", 88 "source/cpu_id.cc", 89 "source/mjpeg_decoder.cc", 90 "source/mjpeg_validate.cc", 91 "source/planar_functions.cc", 92 "source/rotate.cc", 93 "source/rotate_any.cc", 94 "source/rotate_argb.cc", 95 "source/rotate_common.cc", 96 "source/rotate_dspr2.cc", 97 "source/rotate_gcc.cc", 98 "source/rotate_win.cc", 99 "source/row_any.cc", 100 "source/row_common.cc", 101 "source/row_dspr2.cc", 102 "source/row_gcc.cc", 103 "source/row_win.cc", 104 "source/scale.cc", 105 "source/scale_any.cc", 106 "source/scale_argb.cc", 107 "source/scale_common.cc", 108 "source/scale_dspr2.cc", 109 "source/scale_gcc.cc", 110 "source/scale_win.cc", 111 "source/video_common.cc", 112 ] 113 114 configs += [ ":libyuv_config" ] 115 defines = [] 116 deps = [] 117 118 if (!is_ios) { 119 defines += [ "HAVE_JPEG" ] 120 deps += [ "//third_party:jpeg" ] 121 } 122 123 if (libyuv_use_neon) { 124 deps += [ ":libyuv_neon" ] 125 } 126 127 if (libyuv_use_msa) { 128 deps += [ ":libyuv_msa" ] 129 } 130 131 # Always enable optimization for Release and NaCl builds (to workaround 132 # crbug.com/538243). 133 if (!is_debug || is_nacl) { 134 configs -= [ "//build/config/compiler:default_optimization" ] 135 136 # Enable optimize for speed (-O2) over size (-Os). 137 configs += [ "//build/config/compiler:optimize_max" ] 138 } 139 140 # To enable AVX2 or other cpu optimization, pass flag here 141 # cflags = [ "-mavx2" ] 142} 143 144if (libyuv_use_neon) { 145 static_library("libyuv_neon") { 146 sources = [ 147 # ARM Source Files 148 "source/compare_neon.cc", 149 "source/compare_neon64.cc", 150 "source/rotate_neon.cc", 151 "source/rotate_neon64.cc", 152 "source/row_neon.cc", 153 "source/row_neon64.cc", 154 "source/scale_neon.cc", 155 "source/scale_neon64.cc", 156 ] 157 158 public_configs = [ ":libyuv_config" ] 159 160 # Always enable optimization for Release and NaCl builds (to workaround 161 # crbug.com/538243). 162 if (!is_debug) { 163 configs -= [ "//build/config/compiler:default_optimization" ] 164 165 # Enable optimize for speed (-O2) over size (-Os). 166 configs += [ "//build/config/compiler:optimize_max" ] 167 } 168 169 if (current_cpu != "arm64") { 170 configs -= [ "//build/config/compiler:compiler_arm_fpu" ] 171 cflags = [ "-mfpu=neon" ] 172 } 173 } 174} 175 176if (libyuv_use_msa) { 177 static_library("libyuv_msa") { 178 sources = [ 179 # MSA Source Files 180 "source/rotate_msa.cc", 181 "source/row_msa.cc", 182 "source/scale_msa.cc", 183 ] 184 185 public_configs = [ ":libyuv_config" ] 186 } 187} 188 189if (libyuv_include_tests) { 190 config("libyuv_unittest_warnings_config") { 191 if (!is_win) { 192 cflags = [ 193 # TODO(fbarchard): Fix sign and unused variable warnings. 194 "-Wno-sign-compare", 195 "-Wno-unused-variable", 196 ] 197 } 198 if (is_win) { 199 cflags = [ 200 "/wd4245", # signed/unsigned mismatch 201 "/wd4189", # local variable is initialized but not referenced 202 ] 203 } 204 } 205 config("libyuv_unittest_config") { 206 defines = [ "GTEST_RELATIVE_PATH" ] 207 } 208 209 test("libyuv_unittest") { 210 testonly = true 211 212 sources = [ 213 # sources 214 # headers 215 "unit_test/basictypes_test.cc", 216 "unit_test/color_test.cc", 217 "unit_test/compare_test.cc", 218 "unit_test/convert_test.cc", 219 "unit_test/cpu_test.cc", 220 "unit_test/math_test.cc", 221 "unit_test/planar_test.cc", 222 "unit_test/rotate_argb_test.cc", 223 "unit_test/rotate_test.cc", 224 "unit_test/scale_argb_test.cc", 225 "unit_test/scale_test.cc", 226 "unit_test/unit_test.cc", 227 "unit_test/unit_test.h", 228 "unit_test/video_common_test.cc", 229 ] 230 231 deps = [ 232 ":libyuv", 233 "//testing/gtest", 234 "//third_party/gflags", 235 ] 236 237 configs += [ ":libyuv_unittest_warnings_config" ] 238 239 public_deps = [ 240 "//testing/gtest", 241 ] 242 public_configs = [ ":libyuv_unittest_config" ] 243 244 defines = [] 245 246 if (is_linux) { 247 cflags = [ "-fexceptions" ] 248 } 249 if (is_ios) { 250 configs -= [ "//build/config/compiler:default_symbols" ] 251 configs += [ "//build/config/compiler:symbols" ] 252 cflags = [ "-Wno-sometimes-uninitialized" ] 253 } 254 if (!is_ios && !libyuv_disable_jpeg) { 255 defines += [ "HAVE_JPEG" ] 256 } 257 if (is_android) { 258 deps += [ "//testing/android/native_test:native_test_native_code" ] 259 } 260 261 # TODO(YangZhang): These lines can be removed when high accuracy 262 # YUV to RGB to Neon is ported. 263 if ((target_cpu == "armv7" || target_cpu == "armv7s" || 264 (target_cpu == "arm" && arm_version >= 7) || target_cpu == "arm64") && 265 (arm_use_neon || arm_optionally_use_neon)) { 266 defines += [ "LIBYUV_NEON" ] 267 } 268 269 defines += [ 270 # Enable the following 3 macros to turn off assembly for specified CPU. 271 # "LIBYUV_DISABLE_X86", 272 # "LIBYUV_DISABLE_NEON", 273 # "LIBYUV_DISABLE_DSPR2", 274 # Enable the following macro to build libyuv as a shared library (dll). 275 # "LIBYUV_USING_SHARED_LIBRARY" 276 ] 277 } 278 279 executable("compare") { 280 sources = [ 281 # sources 282 "util/compare.cc", 283 ] 284 deps = [ 285 ":libyuv", 286 ] 287 if (is_linux) { 288 cflags = [ "-fexceptions" ] 289 } 290 } 291 292 executable("convert") { 293 sources = [ 294 # sources 295 "util/convert.cc", 296 ] 297 deps = [ 298 ":libyuv", 299 ] 300 if (is_linux) { 301 cflags = [ "-fexceptions" ] 302 } 303 } 304 305 executable("psnr") { 306 sources = [ 307 # sources 308 "util/psnr.cc", 309 "util/psnr_main.cc", 310 "util/ssim.cc", 311 ] 312 deps = [ 313 ":libyuv", 314 ] 315 316 if (!is_ios && !libyuv_disable_jpeg) { 317 defines = [ "HAVE_JPEG" ] 318 } 319 } 320 321 executable("cpuid") { 322 sources = [ 323 # sources 324 "util/cpuid.c", 325 ] 326 deps = [ 327 ":libyuv", 328 ] 329 } 330} 331