aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Jansen <jansene@google.com>2024-05-22 21:48:55 -0700
committerErwin Jansen <jansene@google.com>2024-05-23 08:33:17 -0700
commit6586f274ea4711dc100032bb31725fc2b862bba6 (patch)
tree147424879a31feae5df5c327860f46092bb7ae67
parent700efa3f1737275e171bf1efc6f43f95b5173e50 (diff)
downloadlibyuv-6586f274ea4711dc100032bb31725fc2b862bba6.tar.gz
Add bazel build file
Test: bazel test @libyuv//:libyuv_unittest Bug: 342029930 Change-Id: I5f796ade9c852376b1770b95fc8e90c0438ba87d
-rw-r--r--BUILD.bazel238
-rw-r--r--WORKSPACE1
2 files changed, 239 insertions, 0 deletions
diff --git a/BUILD.bazel b/BUILD.bazel
new file mode 100644
index 00000000..a52fa6d9
--- /dev/null
+++ b/BUILD.bazel
@@ -0,0 +1,238 @@
+load("@bazel_skylib//lib:selects.bzl", "selects")
+load("@rules_license//rules:license.bzl", "license")
+load("@rules_license//rules:license_kind.bzl", "license_kind")
+
+package(
+ default_applicable_licenses = [":license"],
+ default_visibility = ["//visibility:public"],
+)
+
+license(
+ name = "license",
+ license_kinds = [
+ ":SPDX-license-identifier-BSD-3-Clause",
+ ],
+ visibility = [":__subpackages__"],
+)
+
+license_kind(
+ name = "SPDX-license-identifier-BSD-3-Clause",
+ conditions = ["notice"],
+ url = "https://spdx.org/licenses/BSD-3-Clause.html",
+)
+
+config_setting(
+ name = "linux_aarch64",
+ constraint_values = [
+ "@platforms//cpu:aarch64",
+ "@platforms//os:linux",
+ ],
+)
+
+config_setting(
+ name = "linux_x86_64",
+ constraint_values = [
+ "@platforms//cpu:x86_64",
+ "@platforms//os:linux",
+ ],
+)
+
+config_setting(
+ name = "osx_apple",
+ constraint_values = [
+ "@platforms//os:osx",
+ "@platforms//cpu:aarch64",
+ ],
+)
+
+config_setting(
+ name = "osx_intel",
+ constraint_values = [
+ "@platforms//os:osx",
+ "@platforms//cpu:x86_64",
+ ],
+)
+
+config_setting(
+ name = "windows_x86_64",
+ constraint_values = [
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
+ ],
+)
+
+selects.config_setting_group(
+ name = "aarch64",
+ match_any = [
+ ":linux_aarch64",
+ ":osx_apple",
+ ],
+)
+
+selects.config_setting_group(
+ name = "x86_64",
+ match_any = [
+ ":linux_x86_64",
+ ":windows_x86_64",
+ ":osx_intel",
+ ],
+)
+
+NEON_COPTS = select({
+ ":aarch64": [
+ "-DLIBYUV_NEON",
+ "-march=armv8-a+dotprod+i8mm",
+ ],
+ "//conditions:default": [],
+})
+
+PLATFORM_COPTS = [
+ "-DLIBYUV_USE_ABSL_FLAGS",
+ "-DHAVE_JPEG",
+]
+
+ALL_COPTS = NEON_COPTS + PLATFORM_COPTS
+
+cc_library(
+ name = "libyuv_neon_impl",
+ srcs = glob(
+ [
+ "source/*neon*.cc",
+ "include/libyuv/*.h",
+ ],
+ ),
+ copts = ALL_COPTS,
+ includes = ["include"],
+ visibility = ["//visibility:private"],
+ alwayslink = 1,
+)
+
+cc_library(
+ name = "libyuv",
+ srcs = [
+ "source/compare.cc",
+ "source/compare_common.cc",
+ "source/compare_gcc.cc",
+ "source/compare_win.cc",
+ "source/convert.cc",
+ "source/convert_argb.cc",
+ "source/convert_from.cc",
+ "source/convert_from_argb.cc",
+ "source/convert_jpeg.cc",
+ "source/convert_to_argb.cc",
+ "source/convert_to_i420.cc",
+ "source/cpu_id.cc",
+ "source/mjpeg_decoder.cc",
+ "source/mjpeg_validate.cc",
+ "source/planar_functions.cc",
+ "source/rotate.cc",
+ "source/rotate_any.cc",
+ "source/rotate_argb.cc",
+ "source/rotate_common.cc",
+ "source/rotate_gcc.cc",
+ "source/rotate_win.cc",
+ "source/row_any.cc",
+ "source/row_common.cc",
+ "source/row_gcc.cc",
+ "source/row_rvv.cc",
+ "source/row_win.cc",
+ "source/scale.cc",
+ "source/scale_any.cc",
+ "source/scale_argb.cc",
+ "source/scale_common.cc",
+ "source/scale_gcc.cc",
+ "source/scale_rgb.cc",
+ "source/scale_rvv.cc",
+ "source/scale_uv.cc",
+ "source/scale_win.cc",
+ "source/video_common.cc",
+ ],
+ hdrs = [
+ "include/libyuv.h",
+ "include/libyuv/basic_types.h",
+ "include/libyuv/compare.h",
+ "include/libyuv/compare_row.h",
+ "include/libyuv/convert.h",
+ "include/libyuv/convert_argb.h",
+ "include/libyuv/convert_from.h",
+ "include/libyuv/convert_from_argb.h",
+ "include/libyuv/cpu_id.h",
+ "include/libyuv/loongson_intrinsics.h",
+ "include/libyuv/macros_msa.h",
+ "include/libyuv/mjpeg_decoder.h",
+ "include/libyuv/planar_functions.h",
+ "include/libyuv/rotate.h",
+ "include/libyuv/rotate_argb.h",
+ "include/libyuv/rotate_row.h",
+ "include/libyuv/row.h",
+ "include/libyuv/scale.h",
+ "include/libyuv/scale_argb.h",
+ "include/libyuv/scale_rgb.h",
+ "include/libyuv/scale_row.h",
+ "include/libyuv/scale_uv.h",
+ "include/libyuv/version.h",
+ "include/libyuv/video_common.h",
+ ],
+ copts = ALL_COPTS,
+ includes = ["include"],
+ deps = ["@libjpeg_turbo//:jpeg"] +
+ select({
+ ":aarch64": [
+ ":libyuv_neon_impl",
+ ],
+ "//conditions:default": [],
+ }),
+)
+
+cc_test(
+ name = "libyuv_unittest",
+ srcs = [
+ "unit_test/basictypes_test.cc",
+ "unit_test/color_test.cc",
+ "unit_test/compare_test.cc",
+ "unit_test/convert_argb_test.cc",
+ "unit_test/convert_test.cc",
+ "unit_test/cpu_test.cc",
+ "unit_test/cpu_thread_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_plane_test.cc",
+ "unit_test/scale_rgb_test.cc",
+ "unit_test/scale_test.cc",
+ "unit_test/scale_uv_test.cc",
+ "unit_test/unit_test.cc",
+ "unit_test/unit_test.h",
+ "unit_test/video_common_test.cc",
+ ],
+ copts = ALL_COPTS + ["-DLIBYUV_USE_ABSL_FLAGS"],
+ deps = [
+ ":libyuv",
+ "@com_google_absl//absl/flags:flag",
+ "@com_google_absl//absl/flags:parse",
+ "@com_google_googletest//:gtest_main",
+ ],
+)
+
+cc_binary(
+ name = "yuvconvert",
+ srcs = ["util/yuvconvert.cc"],
+ copts = ALL_COPTS,
+ deps = [":libyuv"],
+)
+
+cc_binary(
+ name = "compare",
+ srcs = ["util/compare.cc"],
+ copts = ALL_COPTS,
+ deps = [":libyuv"],
+)
+
+cc_test(
+ name = "i444tonv12_eg",
+ srcs = ["util/i444tonv12_eg.cc"],
+ copts = ALL_COPTS,
+ deps = [":libyuv"],
+)
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 00000000..fc7f532e
--- /dev/null
+++ b/WORKSPACE
@@ -0,0 +1 @@
+workspace(name = "libyuv")