No public description

PiperOrigin-RevId: 560652313
This commit is contained in:
MediaPipe Team 2023-08-28 02:48:00 -07:00 committed by Copybara-Service
parent d0bf0dd021
commit b22dcf9ce6
6 changed files with 237 additions and 99 deletions

View File

@ -14,81 +14,155 @@
licenses(["notice"]) # Apache 2.0
# Note: yes, these need to use "//external:android/crosstool", not
# @androidndk//:default_crosstool.
load("@mediapipe//mediapipe:platforms.bzl", "config_setting_and_platform")
# Generic Android
config_setting(
name = "android",
values = {"crosstool_top": "//external:android/crosstool"},
constraint_values = [
"@platforms//os:android",
],
visibility = ["//visibility:public"],
)
config_setting(
# Android x86 32-bit.
config_setting_and_platform(
name = "android_x86",
values = {
"crosstool_top": "//external:android/crosstool",
"cpu": "x86",
},
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:x86_32",
],
visibility = ["//visibility:public"],
)
config_setting(
# Android x86 64-bit.
config_setting_and_platform(
name = "android_x86_64",
values = {
"crosstool_top": "//external:android/crosstool",
"cpu": "x86_64",
},
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:x86_64",
],
visibility = ["//visibility:public"],
)
config_setting(
name = "android_armeabi",
values = {
"crosstool_top": "//external:android/crosstool",
"cpu": "armeabi",
},
visibility = ["//visibility:public"],
)
config_setting(
# Android ARMv7.
config_setting_and_platform(
name = "android_arm",
values = {
"crosstool_top": "//external:android/crosstool",
"cpu": "armeabi-v7a",
},
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:armv7",
],
visibility = ["//visibility:public"],
)
config_setting(
# Android ARM64.
config_setting_and_platform(
name = "android_arm64",
values = {
"crosstool_top": "//external:android/crosstool",
"cpu": "arm64-v8a",
},
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:arm64",
],
visibility = ["//visibility:public"],
)
# Note: this cannot just match "apple_platform_type": "macos" because that option
# defaults to "macos" even when building on Linux!
alias(
# Generic MacOS.
config_setting(
name = "macos",
actual = select({
":macos_i386": ":macos_i386",
":macos_x86_64": ":macos_x86_64",
":macos_arm64": ":macos_arm64",
"//conditions:default": ":macos_i386", # Arbitrarily chosen from above.
}),
constraint_values = [
"@platforms//os:macos",
],
visibility = ["//visibility:public"],
)
# Note: this also matches on crosstool_top so that it does not produce ambiguous
# selectors when used together with "android".
# MacOS x86 64-bit.
config_setting_and_platform(
name = "macos_x86_64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
visibility = ["//visibility:public"],
)
# MacOS ARM64.
config_setting_and_platform(
name = "macos_arm64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:arm64",
],
visibility = ["//visibility:public"],
)
# Generic iOS.
config_setting(
name = "ios",
values = {
"crosstool_top": "@bazel_tools//tools/cpp:toolchain",
"apple_platform_type": "ios",
},
constraint_values = [
"@platforms//os:ios",
],
visibility = ["//visibility:public"],
)
# iOS device ARM32.
config_setting_and_platform(
name = "ios_armv7",
constraint_values = [
"@platforms//os:ios",
"@platforms//cpu:arm",
],
visibility = ["//visibility:public"],
)
# iOS device ARM64.
config_setting_and_platform(
name = "ios_arm64",
constraint_values = [
"@platforms//os:ios",
"@platforms//cpu:arm64",
],
visibility = ["//visibility:public"],
)
# iOS device ARM64E.
config_setting_and_platform(
name = "ios_arm64e",
constraint_values = [
"@platforms//os:ios",
"@platforms//cpu:arm64e",
],
visibility = ["//visibility:public"],
)
# iOS simulator x86 32-bit.
config_setting_and_platform(
name = "ios_i386",
constraint_values = [
"@platforms//os:ios",
"@platforms//cpu:x86_32",
"@build_bazel_apple_support//constraints:simulator",
],
visibility = ["//visibility:public"],
)
# iOS simulator x86 64-bit.
config_setting_and_platform(
name = "ios_x86_64",
constraint_values = [
"@platforms//os:ios",
"@platforms//cpu:x86_64",
"@build_bazel_apple_support//constraints:simulator",
],
visibility = ["//visibility:public"],
)
# iOS simulator ARM64.
config_setting_and_platform(
name = "ios_sim_arm64",
constraint_values = [
"@platforms//os:ios",
"@platforms//cpu:arm64",
"@build_bazel_apple_support//constraints:simulator",
],
visibility = ["//visibility:public"],
)
@ -102,52 +176,24 @@ alias(
visibility = ["//visibility:public"],
)
config_setting(
name = "macos_i386",
values = {
"apple_platform_type": "macos",
"cpu": "darwin",
},
visibility = ["//visibility:public"],
)
config_setting(
name = "macos_x86_64",
values = {
"apple_platform_type": "macos",
"cpu": "darwin_x86_64",
},
visibility = ["//visibility:public"],
)
config_setting(
name = "macos_arm64",
values = {
"apple_platform_type": "macos",
"cpu": "darwin_arm64",
},
visibility = ["//visibility:public"],
)
[
config_setting(
name = arch,
values = {"cpu": arch},
visibility = ["//visibility:public"],
)
for arch in [
"ios_i386",
"ios_x86_64",
"ios_armv7",
"ios_arm64",
"ios_arm64e",
"ios_sim_arm64",
]
]
config_setting(
# Windows 64-bit.
config_setting_and_platform(
name = "windows",
values = {"cpu": "x64_windows"},
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
visibility = ["//visibility:public"],
)
# Linux 64-bit.
config_setting_and_platform(
name = "linux",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
visibility = ["//visibility:public"],
)
exports_files(

View File

@ -197,7 +197,6 @@ def _mediapipe_jni(name, gen_libmediapipe, calculators = []):
name = name + "_opencv_cc_lib",
srcs = select({
"//mediapipe:android_arm64": ["@android_opencv//:libopencv_java3_so_arm64-v8a"],
"//mediapipe:android_armeabi": ["@android_opencv//:libopencv_java3_so_armeabi-v7a"],
"//mediapipe:android_arm": ["@android_opencv//:libopencv_java3_so_armeabi-v7a"],
"//mediapipe:android_x86": ["@android_opencv//:libopencv_java3_so_x86"],
"//mediapipe:android_x86_64": ["@android_opencv//:libopencv_java3_so_x86_64"],

38
mediapipe/platforms.bzl Normal file
View File

@ -0,0 +1,38 @@
# Copyright 2023 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.
"""Build rule to generate 'config_setting' and 'platform' with the same constraints."""
def config_setting_and_platform(
name,
constraint_values = [],
visibility = None):
"""Defines a 'config_setting' and 'platform' with the same constraints.
Args:
name: the name for the 'config_setting'. The platform will be suffixed with '_platform'.
constraint_values: the constraints to meet.
visibility: the target visibility.
"""
native.config_setting(
name = name,
constraint_values = constraint_values,
visibility = visibility,
)
native.platform(
name = name + "_platform",
constraint_values = constraint_values,
visibility = visibility,
)

View File

@ -300,7 +300,6 @@ def _mediapipe_tasks_aar(name, srcs, manifest, java_proto_lite_targets, native_l
name = name + "_jni_opencv_cc_lib",
srcs = select({
"//mediapipe:android_arm64": ["@android_opencv//:libopencv_java3_so_arm64-v8a"],
"//mediapipe:android_armeabi": ["@android_opencv//:libopencv_java3_so_armeabi-v7a"],
"//mediapipe:android_arm": ["@android_opencv//:libopencv_java3_so_armeabi-v7a"],
"//mediapipe:android_x86": ["@android_opencv//:libopencv_java3_so_x86"],
"//mediapipe:android_x86_64": ["@android_opencv//:libopencv_java3_so_x86_64"],

61
platform_mappings Normal file
View File

@ -0,0 +1,61 @@
# This file allows automatically mapping flags such as '--cpu' to the more
# modern Bazel platforms (https://bazel.build/concepts/platforms).
# In particular, Bazel platforms lack support for Apple for now if no such
# mapping is put into place. It's inspired from:
# https://github.com/bazelbuild/rules_apple/issues/1764
flags:
--cpu=x86
--crosstool_top=//external:android/crosstool
@mediapipe//mediapipe:android_x86_platform
--cpu=x86_64
--crosstool_top=//external:android/crosstool
@mediapipe//mediapipe:android_x86_64_platform
--cpu=armeabi-v7a
--crosstool_top=//external:android/crosstool
@mediapipe//mediapipe:android_arm_platform
--cpu=arm64-v8a
--crosstool_top=//external:android/crosstool
@mediapipe//mediapipe:android_arm64_platform
--cpu=darwin_x86_64
--apple_platform_type=macos
@@mediapipe//mediapipe:macos_x86_64_platform
--cpu=darwin_arm64
--apple_platform_type=macos
@@mediapipe//mediapipe:macos_arm64_platform
--cpu=ios_i386
--apple_platform_type=ios
@@mediapipe//mediapipe:ios_i386_platform
--cpu=ios_x86_64
--apple_platform_type=ios
@@mediapipe//mediapipe:ios_x86_64_platform
--cpu=ios_sim_arm64
--apple_platform_type=ios
@@mediapipe//mediapipe:ios_sim_arm64_platform
--cpu=ios_armv7
--apple_platform_type=ios
@@mediapipe//mediapipe:ios_armv7_platform
--cpu=ios_arm64
--apple_platform_type=ios
@@mediapipe//mediapipe:ios_arm64_platform
--cpu=ios_arm64e
--apple_platform_type=ios
@@mediapipe//mediapipe:ios_arm64e_platform
--cpu=x64_windows
@mediapipe//mediapipe:windows_platform
--cpu=k8
@mediapipe//mediapipe:linux_platform

5
third_party/BUILD vendored
View File

@ -32,9 +32,6 @@ cc_library(
"//mediapipe:android_x86_64": [
"@com_github_glog_glog_no_gflags//:glog",
],
"//mediapipe:android_armeabi": [
"@com_github_glog_glog_no_gflags//:glog",
],
"//mediapipe:android_arm": [
"@com_github_glog_glog_no_gflags//:glog",
],
@ -249,7 +246,6 @@ alias(
actual = select({
"//mediapipe:android_x86": "@android_opencv//:libopencv_x86",
"//mediapipe:android_x86_64": "@android_opencv//:libopencv_x86_64",
"//mediapipe:android_armeabi": "@android_opencv//:libopencv_armeabi-v7a",
"//mediapipe:android_arm": "@android_opencv//:libopencv_armeabi-v7a",
"//mediapipe:android_arm64": "@android_opencv//:libopencv_arm64-v8a",
"//mediapipe:ios": "@ios_opencv//:opencv",
@ -265,7 +261,6 @@ cc_library(
deps = select({
"//mediapipe:android_x86": [],
"//mediapipe:android_x86_64": [],
"//mediapipe:android_armeabi": [],
"//mediapipe:android_arm": [],
"//mediapipe:android_arm64": [],
"//mediapipe:ios": [],