aboutsummaryrefslogtreecommitdiff
path: root/files/BUILD.gn
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2017-02-22 18:01:07 -0800
committerFrank Barchard <fbarchard@google.com>2017-03-06 09:54:15 -0800
commitb83bb38f0a92bedeb52baa31e515220927ef53bb (patch)
treea31c9da19db3f909cad22293ad2964d1c41c953a /files/BUILD.gn
parent04676c9f110180a5ae1fa259a38fab17101c6b5b (diff)
downloadlibyuv-b83bb38f0a92bedeb52baa31e515220927ef53bb.tar.gz
libyuv r1645 to fix android build warnings
r1602 under android.mk had unused parameter build warnings. The warnings were disabled. This CL fixes the source and re-enables the warning. Bug: 35099807 Test: mm for libyuv builds cleanly. Change-Id: If6b344ca39b2c321e277421cdeb817a5b1cc2514
Diffstat (limited to 'files/BUILD.gn')
-rw-r--r--files/BUILD.gn225
1 files changed, 198 insertions, 27 deletions
diff --git a/files/BUILD.gn b/files/BUILD.gn
index b091cbc2..57771b72 100644
--- a/files/BUILD.gn
+++ b/files/BUILD.gn
@@ -6,19 +6,37 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
-import("//build/config/arm.gni")
-import("//build/config/sanitizers/sanitizers.gni")
+import("libyuv.gni")
+import("//testing/test.gni")
config("libyuv_config") {
- include_dirs = [
- ".",
- "include",
- ]
+ include_dirs = [ "include" ]
+ if (is_android && current_cpu=="arm64") {
+ ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64" ]
+ }
+ if (is_android && current_cpu != "arm64") {
+ ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker" ]
+ }
}
-use_neon = current_cpu == "arm64" || (current_cpu == "arm" && (arm_use_neon || arm_optionally_use_neon))
+# This target is built when no specific target is specified on the command line.
+group("default") {
+ testonly = true
+ deps = [
+ ":libyuv",
+ ]
+ if (libyuv_include_tests) {
+ deps += [
+ ":compare",
+ ":convert",
+ ":cpuid",
+ ":libyuv_unittest",
+ ":psnr",
+ ]
+ }
+}
-source_set("libyuv") {
+static_library("libyuv") {
sources = [
# Headers
"include/libyuv.h",
@@ -61,57 +79,56 @@ source_set("libyuv") {
"source/rotate_any.cc",
"source/rotate_argb.cc",
"source/rotate_common.cc",
- "source/rotate_mips.cc",
+ "source/rotate_dspr2.cc",
"source/rotate_gcc.cc",
"source/rotate_win.cc",
"source/row_any.cc",
"source/row_common.cc",
- "source/row_mips.cc",
+ "source/row_dspr2.cc",
"source/row_gcc.cc",
"source/row_win.cc",
"source/scale.cc",
"source/scale_any.cc",
"source/scale_argb.cc",
"source/scale_common.cc",
- "source/scale_mips.cc",
+ "source/scale_dspr2.cc",
"source/scale_gcc.cc",
"source/scale_win.cc",
"source/video_common.cc",
]
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [ "//build/config/compiler:no_chromium_code" ]
-
public_configs = [ ":libyuv_config" ]
defines = []
+ deps = []
if (!is_ios) {
defines += [ "HAVE_JPEG" ]
+ deps += [ "//third_party:jpeg" ]
}
- if (is_msan) {
- # MemorySanitizer does not support assembly code yet.
- # http://crbug.com/344505
- defines += [ "LIBYUV_DISABLE_X86" ]
+ if (libyuv_use_neon) {
+ deps += [ ":libyuv_neon" ]
}
- deps = [
- "//third_party:jpeg",
- ]
-
- if (use_neon) {
- deps += [ ":libyuv_neon" ]
+ if (libyuv_use_msa) {
+ deps += [ ":libyuv_msa" ]
}
- if (is_nacl) {
- # Always enable optimization under NaCl to workaround crbug.com/538243 .
+ # Always enable optimization for Release and NaCl builds (to workaround
+ # crbug.com/538243).
+ if (!is_debug || is_nacl) {
configs -= [ "//build/config/compiler:default_optimization" ]
+ # Enable optimize for speed (-O2) over size (-Os).
configs += [ "//build/config/compiler:optimize_max" ]
}
+
+ # To enable AVX2 or other cpu optimization, pass flag here
+ # cflags = [ "-mavx2" ]
+
}
-if (use_neon) {
+if (libyuv_use_neon) {
static_library("libyuv_neon") {
sources = [
# ARM Source Files
@@ -127,9 +144,163 @@ if (use_neon) {
public_configs = [ ":libyuv_config" ]
+ # Always enable optimization for Release and NaCl builds (to workaround
+ # crbug.com/538243).
+ if (!is_debug) {
+ configs -= [ "//build/config/compiler:default_optimization" ]
+ # Enable optimize for speed (-O2) over size (-Os).
+ configs += [ "//build/config/compiler:optimize_max" ]
+ }
+
if (current_cpu != "arm64") {
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
}
}
+
+if (libyuv_use_msa) {
+ static_library("libyuv_msa") {
+ sources = [
+ # MSA Source Files
+ "source/row_msa.cc",
+ "source/scale_msa.cc",
+ "source/rotate_msa.cc",
+ ]
+
+ public_configs = [ ":libyuv_config" ]
+ }
+}
+
+if (libyuv_include_tests) {
+ config("libyuv_unittest_warnings_config") {
+ if (!is_win) {
+ cflags = [
+ # TODO(fbarchard): Fix sign and unused variable warnings.
+ "-Wno-sign-compare",
+ "-Wno-unused-variable"
+ ]
+ }
+ if (is_win) {
+ cflags = [
+ "/wd4245", # signed/unsigned mismatch
+ "/wd4189", # local variable is initialized but not referenced
+ ]
+ }
+ }
+ config("libyuv_unittest_config") {
+ defines = [ "GTEST_RELATIVE_PATH" ]
+ }
+
+ test("libyuv_unittest") {
+ testonly = true
+
+ sources = [
+ # headers
+ "unit_test/unit_test.h",
+ # sources
+ "unit_test/basictypes_test.cc",
+ "unit_test/compare_test.cc",
+ "unit_test/color_test.cc",
+ "unit_test/convert_test.cc",
+ "unit_test/cpu_test.cc",
+ "unit_test/math_test.cc",
+ "unit_test/planar_test.cc",
+ "unit_test/rotate_argb_test.cc",
+ "unit_test/rotate_test.cc",
+ "unit_test/scale_argb_test.cc",
+ "unit_test/scale_test.cc",
+ "unit_test/unit_test.cc",
+ "unit_test/video_common_test.cc",
+ ]
+
+ deps = [
+ ":libyuv",
+ "//testing/gtest",
+ "//third_party/gflags",
+ ]
+
+ configs += [ ":libyuv_unittest_warnings_config" ]
+
+ public_deps = [ "//testing/gtest" ]
+ public_configs = [ ":libyuv_unittest_config" ]
+
+ defines = []
+
+ if (is_linux) {
+ cflags = [ "-fexceptions" ]
+ }
+ if (is_ios) {
+ configs -= [ "//build/config/compiler:default_symbols" ]
+ configs += [ "//build/config/compiler:symbols" ]
+ cflags = [ "-Wno-sometimes-uninitialized" ]
+ }
+ if (!is_ios && !libyuv_disable_jpeg) {
+ defines += [ "HAVE_JPEG" ]
+ }
+ if (is_android) {
+ deps += [ "//testing/android/native_test:native_test_native_code" ]
+ }
+
+ # TODO(YangZhang): These lines can be removed when high accuracy
+ # YUV to RGB to Neon is ported.
+ if ((target_cpu=="armv7" || target_cpu=="armv7s" ||
+ (target_cpu=="arm" && arm_version >= 7) || target_cpu=="arm64") &&
+ (arm_use_neon || arm_optionally_use_neon)) {
+ defines += [ "LIBYUV_NEON" ]
+ }
+
+ defines += [
+ # Enable the following 3 macros to turn off assembly for specified CPU.
+ # "LIBYUV_DISABLE_X86",
+ # "LIBYUV_DISABLE_NEON",
+ # "LIBYUV_DISABLE_DSPR2",
+ # Enable the following macro to build libyuv as a shared library (dll).
+ # "LIBYUV_USING_SHARED_LIBRARY"
+ ]
+ }
+
+ executable("compare") {
+ sources = [
+ # sources
+ "util/compare.cc"
+ ]
+ deps = [ ":libyuv" ]
+ if (is_linux) {
+ cflags = [ "-fexceptions" ]
+ }
+ }
+
+ executable("convert") {
+ sources = [
+ # sources
+ "util/convert.cc"
+ ]
+ deps = [ ":libyuv" ]
+ if (is_linux) {
+ cflags = [ "-fexceptions" ]
+ }
+ }
+
+ executable("psnr") {
+ sources = [
+ # sources
+ "util/psnr_main.cc",
+ "util/psnr.cc",
+ "util/ssim.cc"
+ ]
+ deps = [ ":libyuv" ]
+
+ if (!is_ios && !libyuv_disable_jpeg) {
+ defines = [ "HAVE_JPEG" ]
+ }
+ }
+
+ executable("cpuid") {
+ sources = [
+ # sources
+ "util/cpuid.c"
+ ]
+ deps = [ ":libyuv" ]
+ }
+}