2019-06-17 01:03:25 +02:00
|
|
|
# Copyright 2019 The MediaPipe Authors.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
2023-06-07 00:03:56 +02:00
|
|
|
load("@rules_foreign_cc//foreign_cc:cmake.bzl", "cmake")
|
2023-05-05 22:34:46 +02:00
|
|
|
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
|
|
|
|
2019-06-17 01:03:25 +02:00
|
|
|
licenses(["notice"]) # Apache License 2.0
|
|
|
|
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
|
2023-12-19 18:17:17 +01:00
|
|
|
exports_files(["LICENSE"])
|
2023-05-08 23:35:09 +02:00
|
|
|
|
2020-05-21 18:46:31 +02:00
|
|
|
cc_library(
|
|
|
|
name = "glog",
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = select({
|
|
|
|
"//mediapipe:android_x86": [
|
2020-08-30 05:41:10 +02:00
|
|
|
"@com_github_glog_glog_no_gflags//:glog",
|
2020-05-21 18:46:31 +02:00
|
|
|
],
|
|
|
|
"//mediapipe:android_x86_64": [
|
2020-08-30 05:41:10 +02:00
|
|
|
"@com_github_glog_glog_no_gflags//:glog",
|
2020-05-21 18:46:31 +02:00
|
|
|
],
|
|
|
|
"//mediapipe:android_arm": [
|
2020-08-30 05:41:10 +02:00
|
|
|
"@com_github_glog_glog_no_gflags//:glog",
|
2020-05-21 18:46:31 +02:00
|
|
|
],
|
|
|
|
"//mediapipe:android_arm64": [
|
2020-08-30 05:41:10 +02:00
|
|
|
"@com_github_glog_glog_no_gflags//:glog",
|
2020-05-21 18:46:31 +02:00
|
|
|
],
|
|
|
|
"//mediapipe:ios": [
|
2020-08-30 05:41:10 +02:00
|
|
|
"@com_github_glog_glog_no_gflags//:glog",
|
2020-05-21 18:46:31 +02:00
|
|
|
],
|
|
|
|
"//mediapipe:macos": [
|
|
|
|
"@com_github_glog_glog//:glog",
|
|
|
|
],
|
|
|
|
"//mediapipe:windows": [
|
2023-09-27 00:08:36 +02:00
|
|
|
"@com_github_glog_glog_windows//:glog",
|
2020-05-21 18:46:31 +02:00
|
|
|
],
|
|
|
|
"//conditions:default": [
|
|
|
|
"@com_github_glog_glog//:glog",
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
|
2020-08-30 05:41:10 +02:00
|
|
|
config_setting(
|
|
|
|
name = "opencv_source_build",
|
|
|
|
define_values = {
|
|
|
|
"OPENCV": "source",
|
|
|
|
},
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
2023-04-27 23:47:22 +02:00
|
|
|
config_setting(
|
|
|
|
name = "opencv_ios_arm64_source_build",
|
2023-05-05 22:34:46 +02:00
|
|
|
define_values = {
|
|
|
|
"OPENCV": "source",
|
|
|
|
},
|
2023-04-27 23:47:22 +02:00
|
|
|
values = {
|
|
|
|
"apple_platform_type": "ios",
|
2023-04-27 23:56:29 +02:00
|
|
|
"cpu": "ios_arm64",
|
2023-04-27 23:47:22 +02:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
config_setting(
|
|
|
|
name = "opencv_ios_sim_arm64_source_build",
|
2023-05-05 22:34:46 +02:00
|
|
|
define_values = {
|
|
|
|
"OPENCV": "source",
|
|
|
|
},
|
2023-04-27 23:47:22 +02:00
|
|
|
values = {
|
2023-04-27 23:56:29 +02:00
|
|
|
"apple_platform_type": "ios",
|
|
|
|
"cpu": "ios_sim_arm64",
|
2023-04-27 23:47:22 +02:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
config_setting(
|
|
|
|
name = "opencv_ios_x86_64_source_build",
|
|
|
|
define_values = {
|
|
|
|
"OPENCV": "source",
|
|
|
|
},
|
2023-05-05 22:34:46 +02:00
|
|
|
values = {
|
|
|
|
"apple_platform_type": "ios",
|
|
|
|
"cpu": "ios_x86_64",
|
|
|
|
},
|
2023-04-27 23:47:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
config_setting(
|
|
|
|
name = "opencv_ios_sim_fat_source_build",
|
|
|
|
define_values = {
|
|
|
|
"OPENCV": "source",
|
|
|
|
},
|
2023-05-05 22:34:46 +02:00
|
|
|
values = {
|
|
|
|
"apple_platform_type": "ios",
|
2023-05-06 01:07:09 +02:00
|
|
|
"ios_multi_cpus": "sim_arm64,x86_64",
|
2023-05-05 22:34:46 +02:00
|
|
|
},
|
2023-04-27 23:47:22 +02:00
|
|
|
)
|
|
|
|
|
2020-08-30 05:41:10 +02:00
|
|
|
alias(
|
2019-06-17 01:03:25 +02:00
|
|
|
name = "opencv",
|
2020-08-30 05:41:10 +02:00
|
|
|
actual = select({
|
|
|
|
":opencv_source_build": ":opencv_cmake",
|
2023-05-05 22:34:46 +02:00
|
|
|
":opencv_ios_sim_arm64_source_build": "@ios_opencv_source//:opencv",
|
|
|
|
":opencv_ios_arm64_source_build": "@ios_opencv_source//:opencv",
|
2023-05-06 01:07:09 +02:00
|
|
|
":opencv_ios_x86_64_source_build": "@ios_opencv_source//:opencv",
|
2020-08-30 05:41:10 +02:00
|
|
|
"//conditions:default": ":opencv_binary",
|
|
|
|
}),
|
2019-06-17 01:03:25 +02:00
|
|
|
visibility = ["//visibility:public"],
|
2020-08-30 05:41:10 +02:00
|
|
|
)
|
|
|
|
|
2023-05-05 22:34:46 +02:00
|
|
|
bzl_library(
|
|
|
|
name = "opencv_ios_xcframework_files_bzl",
|
|
|
|
srcs = ["opencv_ios_xcframework_files.bzl"],
|
|
|
|
visibility = ["//visibility:private"],
|
|
|
|
)
|
|
|
|
|
|
|
|
bzl_library(
|
|
|
|
name = "opencv_ios_source_bzl",
|
|
|
|
srcs = ["opencv_ios_source.bzl"],
|
|
|
|
visibility = ["//visibility:private"],
|
|
|
|
)
|
2020-08-30 05:41:10 +02:00
|
|
|
|
|
|
|
# Note: this determines the order in which the libraries are passed to the
|
|
|
|
# linker, so if library A depends on library B, library B must come _after_.
|
|
|
|
# Hence core is at the bottom.
|
|
|
|
OPENCV_MODULES = [
|
|
|
|
"calib3d",
|
|
|
|
"features2d",
|
|
|
|
"highgui",
|
|
|
|
"video",
|
|
|
|
"videoio",
|
|
|
|
"imgcodecs",
|
|
|
|
"imgproc",
|
|
|
|
"core",
|
|
|
|
]
|
|
|
|
|
|
|
|
# Note: passing both BUILD_SHARED_LIBS=ON and BUILD_STATIC_LIBS=ON to cmake
|
|
|
|
# still only builds the shared libraries, so we have to choose one or the
|
|
|
|
# other. We build shared libraries by default, but this variable can be used
|
|
|
|
# to switch to static libraries.
|
|
|
|
OPENCV_SHARED_LIBS = True
|
|
|
|
|
|
|
|
OPENCV_SO_VERSION = "3.4"
|
|
|
|
|
2023-06-07 00:03:56 +02:00
|
|
|
cmake(
|
2020-08-30 05:41:10 +02:00
|
|
|
name = "opencv_cmake",
|
|
|
|
# Values to be passed as -Dkey=value on the CMake command line;
|
|
|
|
# here are serving to provide some CMake script configuration options
|
|
|
|
cache_entries = {
|
|
|
|
"CMAKE_BUILD_TYPE": "Release",
|
|
|
|
# The module list is always sorted alphabetically so that we do not
|
|
|
|
# cause a rebuild when changing the link order.
|
|
|
|
"BUILD_LIST": ",".join(sorted(OPENCV_MODULES)),
|
|
|
|
"BUILD_TESTS": "OFF",
|
|
|
|
"BUILD_PERF_TESTS": "OFF",
|
|
|
|
"BUILD_EXAMPLES": "OFF",
|
|
|
|
"BUILD_SHARED_LIBS": "ON" if OPENCV_SHARED_LIBS else "OFF",
|
|
|
|
"WITH_ITT": "OFF",
|
|
|
|
"WITH_JASPER": "OFF",
|
2021-03-25 23:01:44 +01:00
|
|
|
"WITH_JPEG": "ON",
|
|
|
|
"WITH_PNG": "ON",
|
|
|
|
"WITH_TIFF": "ON",
|
2023-03-13 23:35:11 +01:00
|
|
|
"WITH_OPENCL": "OFF",
|
2020-08-30 05:41:10 +02:00
|
|
|
"WITH_WEBP": "OFF",
|
2021-03-25 23:01:44 +01:00
|
|
|
# Optimization flags
|
|
|
|
"CV_ENABLE_INTRINSICS": "ON",
|
|
|
|
"WITH_EIGEN": "ON",
|
|
|
|
"WITH_PTHREADS": "ON",
|
|
|
|
"WITH_PTHREADS_PF": "ON",
|
2020-08-30 05:41:10 +02:00
|
|
|
# When building tests, by default Bazel builds them in dynamic mode.
|
|
|
|
# See https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary.linkstatic
|
|
|
|
# For example, when building //mediapipe/calculators/video:opencv_video_encoder_calculator_test,
|
|
|
|
# the dependency //mediapipe/framework/formats:image_frame_opencv will
|
|
|
|
# be built as a shared library, which depends on a cv::Mat constructor,
|
|
|
|
# and expects it to be provided by the main exacutable. The main
|
|
|
|
# executable depends on libimage_frame_opencv.so and links in
|
|
|
|
# libopencv_core.a, which contains cv::Mat. However, if
|
|
|
|
# libopencv_core.a marks its symbols as hidden, then cv::Mat is in
|
|
|
|
# opencv_video_encoder_calculator_test but it is not exported, so
|
|
|
|
# libimage_frame_opencv.so fails to find it.
|
|
|
|
"OPENCV_SKIP_VISIBILITY_HIDDEN": "ON" if not OPENCV_SHARED_LIBS else "OFF",
|
|
|
|
# The COPY actions in modules/python/python_loader.cmake have issues with symlinks.
|
|
|
|
# In any case, we don't use this.
|
|
|
|
"OPENCV_SKIP_PYTHON_LOADER": "ON",
|
|
|
|
# Need to set this too, for the same reason.
|
|
|
|
"BUILD_opencv_python": "OFF",
|
|
|
|
# Ccache causes issues in some of our CI setups. It's not clear that
|
|
|
|
# ccache would be able to work across sandboxed Bazel builds, either.
|
|
|
|
# In any case, Bazel does its own caching of the rule's outputs.
|
|
|
|
"ENABLE_CCACHE": "OFF",
|
|
|
|
},
|
|
|
|
lib_source = "@opencv//:all",
|
|
|
|
linkopts = [] if OPENCV_SHARED_LIBS else [
|
|
|
|
# When using static libraries, the binary that eventually depends on the
|
|
|
|
# libraries also needs to link in their dependencies, which therefore
|
|
|
|
# have to be listed here.
|
|
|
|
# This list depends on which dependencies CMake finds when it configures
|
|
|
|
# the build, and so depends on what is installed on the local system.
|
|
|
|
# After building, the linkopts for the current setup can be extracted
|
|
|
|
# from lib/pkgconfig/opencv.pc in bazel-out
|
|
|
|
"-ljpeg",
|
|
|
|
"-lpng",
|
|
|
|
"-lz",
|
|
|
|
"-ltiff",
|
|
|
|
"-lImath",
|
|
|
|
"-lIlmImf",
|
|
|
|
"-lIex",
|
|
|
|
"-lHalf",
|
|
|
|
"-lIlmThread",
|
|
|
|
"-ldc1394",
|
|
|
|
"-lavcodec",
|
|
|
|
"-lavformat",
|
|
|
|
"-lavutil",
|
|
|
|
"-lswscale",
|
|
|
|
"-lavresample",
|
|
|
|
"-ldl",
|
|
|
|
"-lm",
|
|
|
|
"-lpthread",
|
|
|
|
"-lrt",
|
2023-03-15 22:21:50 +01:00
|
|
|
],
|
2023-06-07 00:03:56 +02:00
|
|
|
out_shared_libs = select({
|
2020-08-30 05:41:10 +02:00
|
|
|
"@bazel_tools//src/conditions:darwin": ["libopencv_%s.%s.dylib" % (module, OPENCV_SO_VERSION) for module in OPENCV_MODULES],
|
|
|
|
# Only the shared objects listed here will be linked in the directory
|
|
|
|
# that Bazel adds to the RUNPATH of dependent executables. You cannot
|
|
|
|
# list both the versioned and unversioned name of the .so, and the
|
|
|
|
# versioned name is the one that the executables actually reference.
|
|
|
|
"//conditions:default": ["libopencv_%s.so.%s" % (module, OPENCV_SO_VERSION) for module in OPENCV_MODULES],
|
|
|
|
}) if OPENCV_SHARED_LIBS else None,
|
2023-06-07 00:03:56 +02:00
|
|
|
out_static_libs = [
|
2020-08-30 05:41:10 +02:00
|
|
|
"libopencv_%s.a" % module
|
|
|
|
for module in OPENCV_MODULES
|
|
|
|
] if not OPENCV_SHARED_LIBS else None,
|
|
|
|
)
|
|
|
|
|
|
|
|
alias(
|
|
|
|
name = "opencv_binary",
|
|
|
|
actual = select({
|
|
|
|
"//mediapipe:android_x86": "@android_opencv//:libopencv_x86",
|
|
|
|
"//mediapipe:android_x86_64": "@android_opencv//:libopencv_x86_64",
|
|
|
|
"//mediapipe:android_arm": "@android_opencv//:libopencv_armeabi-v7a",
|
|
|
|
"//mediapipe:android_arm64": "@android_opencv//:libopencv_arm64-v8a",
|
|
|
|
"//mediapipe:ios": "@ios_opencv//:opencv",
|
|
|
|
"//mediapipe:macos": "@macos_opencv//:opencv",
|
|
|
|
"//mediapipe:windows": "@windows_opencv//:opencv",
|
|
|
|
"//conditions:default": "@linux_opencv//:opencv",
|
2019-06-17 01:03:25 +02:00
|
|
|
}),
|
|
|
|
)
|
|
|
|
|
2019-08-17 03:49:25 +02:00
|
|
|
cc_library(
|
|
|
|
name = "libffmpeg",
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = select({
|
|
|
|
"//mediapipe:android_x86": [],
|
|
|
|
"//mediapipe:android_x86_64": [],
|
|
|
|
"//mediapipe:android_arm": [],
|
|
|
|
"//mediapipe:android_arm64": [],
|
|
|
|
"//mediapipe:ios": [],
|
|
|
|
"//mediapipe:macos": [
|
|
|
|
"@macos_ffmpeg//:libffmpeg",
|
|
|
|
],
|
|
|
|
"//conditions:default": [
|
|
|
|
"@linux_ffmpeg//:libffmpeg",
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
|
2019-06-17 01:03:25 +02:00
|
|
|
android_library(
|
2019-08-17 03:49:25 +02:00
|
|
|
name = "androidx_annotation",
|
2019-06-17 01:03:25 +02:00
|
|
|
exports = [
|
2019-08-17 03:49:25 +02:00
|
|
|
"@maven//:androidx_annotation_annotation",
|
2019-06-17 01:03:25 +02:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
android_library(
|
|
|
|
name = "androidx_appcompat",
|
|
|
|
exports = [
|
2019-06-28 01:19:43 +02:00
|
|
|
"@maven//:androidx_appcompat_appcompat",
|
2019-06-17 01:03:25 +02:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-08-17 03:49:25 +02:00
|
|
|
android_library(
|
|
|
|
name = "androidx_constraint_layout",
|
|
|
|
exports = [
|
|
|
|
"@maven//:androidx_constraintlayout_constraintlayout",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
android_library(
|
|
|
|
name = "androidx_core",
|
|
|
|
exports = [
|
|
|
|
"@maven//:androidx_core_core",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
android_library(
|
|
|
|
name = "androidx_legacy_support_v4",
|
|
|
|
exports = [
|
|
|
|
"@maven//:androidx_legacy_legacy_support_v4",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
android_library(
|
|
|
|
name = "androidx_material",
|
|
|
|
exports = [
|
|
|
|
"@maven//:com_google_android_material_material",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
android_library(
|
|
|
|
name = "androidx_recyclerview",
|
|
|
|
exports = [
|
|
|
|
"@maven//:androidx_recyclerview_recyclerview",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2020-10-16 11:40:55 +02:00
|
|
|
android_library(
|
|
|
|
name = "camerax_camera2",
|
|
|
|
exports = [
|
|
|
|
"@maven//:androidx_camera_camera_camera2",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-11-21 21:01:51 +01:00
|
|
|
android_library(
|
2019-06-17 01:03:25 +02:00
|
|
|
name = "camerax_core",
|
2019-11-21 21:01:51 +01:00
|
|
|
exports = [
|
|
|
|
"@maven//:androidx_camera_camera_core",
|
|
|
|
],
|
2019-06-17 01:03:25 +02:00
|
|
|
)
|
|
|
|
|
2019-11-21 21:01:51 +01:00
|
|
|
android_library(
|
2020-10-16 11:40:55 +02:00
|
|
|
name = "camerax_lifecycle",
|
2019-11-21 21:01:51 +01:00
|
|
|
exports = [
|
2020-10-16 11:40:55 +02:00
|
|
|
"@maven//:androidx_camera_camera_lifecycle",
|
2019-11-21 21:01:51 +01:00
|
|
|
],
|
2019-06-17 01:03:25 +02:00
|
|
|
)
|
2021-05-05 03:30:15 +02:00
|
|
|
|
|
|
|
java_plugin(
|
|
|
|
name = "autovalue_plugin",
|
|
|
|
processor_class = "com.google.auto.value.processor.AutoValueProcessor",
|
|
|
|
deps = [
|
|
|
|
"@maven//:com_google_auto_value_auto_value",
|
|
|
|
"@maven//:com_google_auto_value_auto_value_annotations",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2021-06-24 23:10:25 +02:00
|
|
|
java_plugin(
|
|
|
|
name = "autobuilder_plugin",
|
|
|
|
processor_class = "com.google.auto.value.processor.AutoBuilderProcessor",
|
|
|
|
deps = [
|
|
|
|
"@maven//:com_google_auto_value_auto_value",
|
|
|
|
"@maven//:com_google_auto_value_auto_value_annotations",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2021-05-05 03:30:15 +02:00
|
|
|
java_library(
|
|
|
|
name = "autovalue",
|
|
|
|
exported_plugins = [
|
|
|
|
":autovalue_plugin",
|
2021-06-24 23:10:25 +02:00
|
|
|
":autobuilder_plugin",
|
2021-05-05 03:30:15 +02:00
|
|
|
],
|
|
|
|
neverlink = 1,
|
|
|
|
exports = [
|
|
|
|
"@maven//:com_google_auto_value_auto_value",
|
|
|
|
"@maven//:com_google_auto_value_auto_value_annotations",
|
|
|
|
],
|
|
|
|
)
|
2023-07-13 19:08:35 +02:00
|
|
|
|
2023-07-27 00:02:27 +02:00
|
|
|
java_import(
|
2023-07-13 19:08:35 +02:00
|
|
|
name = "any_java_proto",
|
2023-07-27 00:02:27 +02:00
|
|
|
jars = [
|
|
|
|
"@com_google_protobuf//java/core:libcore.jar",
|
2023-07-13 19:08:35 +02:00
|
|
|
],
|
|
|
|
)
|