diff --git a/mediapipe/calculators/tensor/BUILD b/mediapipe/calculators/tensor/BUILD index fd926a8fe..9ae884253 100644 --- a/mediapipe/calculators/tensor/BUILD +++ b/mediapipe/calculators/tensor/BUILD @@ -467,10 +467,6 @@ cc_library( "-x objective-c++", "-fobjc-arc", # enable reference-counting ], - linkopts = [ - "-framework CoreVideo", - "-framework MetalKit", - ], tags = ["ios"], deps = [ "inference_calculator_interface", @@ -486,7 +482,13 @@ cc_library( "@org_tensorflow//tensorflow/lite/delegates/gpu:metal_delegate_internal", "@org_tensorflow//tensorflow/lite/delegates/gpu/common:shape", "@org_tensorflow//tensorflow/lite/delegates/gpu/metal:buffer_convert", - ], + ] + select({ + "//mediapipe:apple": [ + "//third_party/apple_frameworks:CoreVideo", + "//third_party/apple_frameworks:MetalKit", + ], + "//conditions:default": [], + }), alwayslink = 1, ) @@ -721,13 +723,6 @@ cc_library( "//conditions:default": [], }), features = ["-layering_check"], # allow depending on tensors_to_detections_calculator_gpu_deps - linkopts = select({ - "//mediapipe:apple": [ - "-framework CoreVideo", - "-framework MetalKit", - ], - "//conditions:default": [], - }), deps = [ ":tensors_to_detections_calculator_cc_proto", "//mediapipe/framework:calculator_framework", @@ -744,6 +739,12 @@ cc_library( ] + selects.with_or({ ":compute_shader_unavailable": [], "//conditions:default": [":tensors_to_detections_calculator_gpu_deps"], + }) + select({ + "//mediapipe:apple": [ + "//third_party/apple_frameworks:CoreVideo", + "//third_party/apple_frameworks:MetalKit", + ], + "//conditions:default": [], }), alwayslink = 1, ) @@ -1333,6 +1334,7 @@ cc_library( "//mediapipe:ios": [ "//mediapipe/gpu:MPPMetalUtil", "//mediapipe/gpu:MPPMetalHelper", + "//third_party/apple_frameworks:MetalKit", ], "//conditions:default": [ "@org_tensorflow//tensorflow/lite/delegates/gpu:gl_delegate", diff --git a/mediapipe/calculators/tflite/BUILD b/mediapipe/calculators/tflite/BUILD index 435ea9fc1..333de2069 100644 --- a/mediapipe/calculators/tflite/BUILD +++ b/mediapipe/calculators/tflite/BUILD @@ -193,13 +193,6 @@ cc_library( ":edge_tpu_pci": ["MEDIAPIPE_EDGE_TPU=pci"], ":edge_tpu_all": ["MEDIAPIPE_EDGE_TPU=all"], }), - linkopts = select({ - "//mediapipe:ios": [ - "-framework CoreVideo", - "-framework MetalKit", - ], - "//conditions:default": [], - }), deps = [ ":tflite_inference_calculator_cc_proto", "//mediapipe/framework:calculator_framework", @@ -222,6 +215,8 @@ cc_library( "@org_tensorflow//tensorflow/lite/delegates/gpu/metal:buffer_convert", "@org_tensorflow//tensorflow/lite/delegates/gpu:metal_delegate", "@org_tensorflow//tensorflow/lite/delegates/gpu:metal_delegate_internal", + "//third_party/apple_frameworks:MetalKit", + "//third_party/apple_frameworks:CoreVideo", ], "//conditions:default": [ "//mediapipe/util/tflite:tflite_gpu_runner", @@ -271,13 +266,6 @@ cc_library( ], "//conditions:default": [], }), - linkopts = select({ - "//mediapipe:ios": [ - "-framework CoreVideo", - "-framework MetalKit", - ], - "//conditions:default": [], - }), deps = [ ":tflite_converter_calculator_cc_proto", "//mediapipe/framework:calculator_framework", @@ -296,6 +284,8 @@ cc_library( "//mediapipe/gpu:MPPMetalHelper", "//mediapipe/objc:mediapipe_framework_ios", "@org_tensorflow//tensorflow/lite/delegates/gpu:metal_delegate", + "//third_party/apple_frameworks:MetalKit", + "//third_party/apple_frameworks:CoreVideo", ], "//conditions:default": [ "//mediapipe/gpu:gl_calculator_helper", @@ -393,13 +383,6 @@ cc_library( ], "//conditions:default": [], }), - linkopts = select({ - "//mediapipe:ios": [ - "-framework CoreVideo", - "-framework MetalKit", - ], - "//conditions:default": [], - }), deps = [ ":tflite_tensors_to_detections_calculator_cc_proto", "//mediapipe/framework:calculator_framework", @@ -420,6 +403,8 @@ cc_library( "//mediapipe/gpu:MPPMetalHelper", "//mediapipe/objc:mediapipe_framework_ios", "@org_tensorflow//tensorflow/lite/delegates/gpu:metal_delegate", + "//third_party/apple_frameworks:MetalKit", + "//third_party/apple_frameworks:CoreVideo", ], "//conditions:default": [ "//mediapipe/gpu:gl_calculator_helper", diff --git a/mediapipe/objc/BUILD b/mediapipe/objc/BUILD index 7df6c8027..20d89d329 100644 --- a/mediapipe/objc/BUILD +++ b/mediapipe/objc/BUILD @@ -89,6 +89,7 @@ objc_library( "//mediapipe/gpu:metal_shared_resources", "//mediapipe/gpu:pixel_buffer_pool_util", "//mediapipe/util:cpu_util", + "//third_party/apple_frameworks:AVFoundation", "//third_party/apple_frameworks:Accelerate", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/memory", diff --git a/third_party/apple_frameworks/BUILD b/third_party/apple_frameworks/BUILD index 05f830e81..62f91b515 100644 --- a/third_party/apple_frameworks/BUILD +++ b/third_party/apple_frameworks/BUILD @@ -32,6 +32,11 @@ cc_library( linkopts = ["-framework Metal"], ) +cc_library( + name = "MetalKit", + linkopts = ["-framework MetalKit"], +) + cc_library( name = "MetalPerformanceShaders", linkopts = ["-framework MetalPerformanceShaders"],