Added targets to build iOs framework
This commit is contained in:
parent
e15d98298f
commit
ddbdb88415
81
mediapipe/tasks/ios/BUILD
Normal file
81
mediapipe/tasks/ios/BUILD
Normal file
|
@ -0,0 +1,81 @@
|
|||
# Copyright 2023 The MediaPipe Authors. All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
load(
|
||||
"//mediapipe/tasks/ios:ios.bzl",
|
||||
"MPP_TASK_MINIMUM_OS_VERSION",
|
||||
"strip_api_include_path_prefix",
|
||||
)
|
||||
load(
|
||||
"@build_bazel_rules_apple//apple:apple.bzl",
|
||||
"apple_static_xcframework",
|
||||
"apple_static_library",
|
||||
)
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
strip_api_include_path_prefix(
|
||||
name = "strip_api_include_path",
|
||||
hdr_labels = [
|
||||
"//mediapipe/tasks/ios/common:sources/MPPCommon.h",
|
||||
"//mediapipe/tasks/ios/components/containers:sources/MPPCategory.h",
|
||||
"//mediapipe/tasks/ios/components/containers:sources/MPPClassificationResult.h",
|
||||
"//mediapipe/tasks/ios/components/containers:sources/MPPEmbedding.h",
|
||||
"//mediapipe/tasks/ios/components/containers:sources/MPPEmbeddingResult.h",
|
||||
"//mediapipe/tasks/ios/core:sources/MPPBaseOptions.h",
|
||||
"//mediapipe/tasks/ios/core:sources/MPPTaskOptions.h",
|
||||
"//mediapipe/tasks/ios/core:sources/MPPTaskResult.h",
|
||||
"//mediapipe/tasks/ios/text/text_classifier:sources/MPPTextClassifier.h",
|
||||
"//mediapipe/tasks/ios/text/text_classifier:sources/MPPTextClassifierOptions.h",
|
||||
"//mediapipe/tasks/ios/text/text_classifier:sources/MPPTextClassifierResult.h",
|
||||
"//mediapipe/tasks/ios/text/text_embedder:sources/MPPTextEmbedder.h",
|
||||
"//mediapipe/tasks/ios/text/text_embedder:sources/MPPTextEmbedderOptions.h",
|
||||
"//mediapipe/tasks/ios/text/text_embedder:sources/MPPTextEmbedderResult.h",
|
||||
],
|
||||
)
|
||||
|
||||
apple_static_xcframework(
|
||||
name = "MediaPipeTaskText_framework",
|
||||
public_hdrs = [
|
||||
":MPPBaseOptions.h",
|
||||
":MPPCategory.h",
|
||||
":MPPClassificationResult.h",
|
||||
":MPPEmbedding.h",
|
||||
":MPPEmbeddingResult.h",
|
||||
":MPPCommon.h",
|
||||
":MPPTaskOptions.h",
|
||||
":MPPTaskResult.h",
|
||||
":MPPTextClassifier.h",
|
||||
":MPPTextClassifierOptions.h",
|
||||
":MPPTextClassifierResult.h",
|
||||
":MPPTextEmbedder.h",
|
||||
":MPPTextEmbedderOptions.h",
|
||||
":MPPTextEmbedderResult.h",
|
||||
],
|
||||
bundle_name = "MediaPipeTaskText",
|
||||
ios = {
|
||||
"simulator" : ["arm64", "x86_64"],
|
||||
"device" : ["arm64"],
|
||||
},
|
||||
minimum_os_versions = {
|
||||
"ios": MPP_TASK_MINIMUM_OS_VERSION,
|
||||
},
|
||||
deps = [
|
||||
"//mediapipe/tasks/ios/text/text_classifier:MPPTextClassifier",
|
||||
"//mediapipe/tasks/ios/text/text_embedder:MPPTextEmbedder",
|
||||
"@org_tensorflow//third_party/icu/data:conversion_data",
|
||||
],
|
||||
)
|
|
@ -1,3 +1,40 @@
|
|||
"""MediaPipe Task Library Helper Rules for iOS"""
|
||||
|
||||
MPP_TASK_MINIMUM_OS_VERSION = "11.0"
|
||||
|
||||
# When the static framework is built with bazel, the all header files are moved
|
||||
# to the "Headers" directory with no header path prefixes. This auxiliary rule
|
||||
# is used for stripping the path prefix to the C/iOS API header files included by
|
||||
# other C/iOS API header files.
|
||||
# In case of C header files includes start with a keyword of "#include'.
|
||||
# Imports in iOS header files start with a keyword of '#import'.
|
||||
def strip_api_include_path_prefix(name, hdr_labels, prefix = ""):
|
||||
"""Create modified header files with the import path stripped out.
|
||||
|
||||
Args:
|
||||
name: The name to be used as a prefix to the generated genrules.
|
||||
hdr_labels: List of header labels to strip out the include path. Each
|
||||
label must end with a colon followed by the header file name.
|
||||
prefix: Optional prefix path to prepend to the header inclusion path.
|
||||
"""
|
||||
for hdr_label in hdr_labels:
|
||||
hdr_filename = hdr_label.split(":")[-1]
|
||||
|
||||
# The last path component of iOS header files is sources/some_file.h
|
||||
# Hence it wiill contain a '/'. So the string can be split at '/' to get
|
||||
# the header file name.
|
||||
if "/" in hdr_filename:
|
||||
hdr_filename = hdr_filename.split("/")[-1]
|
||||
|
||||
hdr_basename = hdr_filename.split(".")[0]
|
||||
native.genrule(
|
||||
name = "{}_{}".format(name, hdr_basename),
|
||||
srcs = [hdr_label],
|
||||
outs = [hdr_filename],
|
||||
cmd = """
|
||||
sed 's|#\\([a-z]*\\) ".*/\\([^/]\\{{1,\\}}\\.h\\)"|#\\1 "{}\\2"|'\
|
||||
"$(location {})"\
|
||||
> "$@"
|
||||
""".format(prefix, hdr_label),
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user