强迫症格式化

This commit is contained in:
liuyulvv 2022-08-05 13:03:08 +08:00
parent 7248ac6750
commit a6eaad2587
17 changed files with 520 additions and 546 deletions

View File

@ -18,9 +18,9 @@ load("//mediapipe/framework/port:build_config.bzl", "mediapipe_proto_library")
load(
"//mediapipe/framework/tool:mediapipe_graph.bzl",
"mediapipe_binary_graph",
)
load("//mediapipe/framework:mediapipe_cc_test.bzl", "mediapipe_cc_test")
load("//mediapipe/framework:encode_binary_proto.bzl", "encode_binary_proto")
) # @unused
load("//mediapipe/framework:mediapipe_cc_test.bzl", "mediapipe_cc_test") # @unused
load("//mediapipe/framework:encode_binary_proto.bzl", "encode_binary_proto") # @unused
licenses(["notice"])

View File

@ -1,6 +1,5 @@
"""Build defs for Objectron."""
def generate_manifest_values(application_id, app_name):
manifest_values = {
"applicationId": application_id,

View File

@ -12,7 +12,6 @@ DirectDescriptorInfo = provider(
fields = ["descriptors"],
)
def calculate_transitive_descriptor_set(actions, deps, output):
"""Calculates the transitive dependencies of the deps.
@ -28,11 +27,9 @@ def calculate_transitive_descriptor_set(actions, deps, output):
# Join all proto descriptors in a single file.
transitive_descriptor_sets = depset(
transitive = [
dep[ProtoInfo].transitive_descriptor_sets
if ProtoInfo in dep
else dep[TransitiveDescriptorInfo].descriptors
dep[ProtoInfo].transitive_descriptor_sets if ProtoInfo in dep else dep[TransitiveDescriptorInfo].descriptors
for dep in deps
]
],
)
args = actions.args()
args.use_param_file(param_file_arg = "--arg-file=%s")
@ -51,14 +48,13 @@ def calculate_transitive_descriptor_set(actions, deps, output):
inputs = transitive_descriptor_sets,
progress_message = "Joining descriptors.",
command = (
'if [[ "$1" =~ ^--arg-file=.* ]]; then xargs "$1" cat; '
+ 'else cat "$@"; fi >{output}'.format(output=output.path)
'if [[ "$1" =~ ^--arg-file=.* ]]; then xargs "$1" cat; ' +
'else cat "$@"; fi >{output}'.format(output = output.path)
),
arguments = [args],
)
return output
def _transitive_descriptor_set_impl(ctx):
"""Combine descriptors for all transitive proto dependencies into one file.
@ -70,7 +66,7 @@ def _transitive_descriptor_set_impl(ctx):
just one so that this limitation won't impact you.
"""
output = ctx.actions.declare_file(
ctx.attr.name + "-transitive-descriptor-set.proto.bin"
ctx.attr.name + "-transitive-descriptor-set.proto.bin",
)
calculate_transitive_descriptor_set(ctx.actions, ctx.attr.deps, output)
return DefaultInfo(
@ -78,7 +74,6 @@ def _transitive_descriptor_set_impl(ctx):
runfiles = ctx.runfiles(files = [output]),
)
# transitive_descriptor_set outputs a single file containing a binary
# FileDescriptorSet with all transitive dependencies of the given proto
# dependencies.
@ -99,7 +94,6 @@ transitive_descriptor_set = rule(
implementation = _transitive_descriptor_set_impl,
)
def calculate_direct_descriptor_set(actions, deps, output):
"""Calculates the direct dependencies of the deps.
@ -124,19 +118,17 @@ def calculate_direct_descriptor_set(actions, deps, output):
outputs = [output],
inputs = descriptor_set,
progress_message = "Joining direct descriptors.",
command=("cat %s > %s")
% (
command = ("cat %s > %s") %
(
" ".join([d.path for d in descriptor_set.to_list()]),
output.path,
),
)
return output
def _direct_descriptor_set_impl(ctx):
calculate_direct_descriptor_set(ctx.actions, ctx.attr.deps, ctx.outputs.out)
# direct_descriptor_set outputs a single file containing a binary
# FileDescriptorSet with all direct, non transitive dependencies of
# the given proto dependencies.

View File

@ -22,7 +22,6 @@ Args:
is_executable: A boolean indicating whether the output file should be executable
"""
def expand_template_impl(ctx):
ctx.actions.expand_template(
template = ctx.file.template,
@ -34,7 +33,6 @@ def expand_template_impl(ctx):
is_executable = ctx.attr.is_executable,
)
expand_template = rule(
implementation = expand_template_impl,
attrs = {

View File

@ -39,7 +39,6 @@ Args:
PROTOC = "@com_google_protobuf//:protoc"
def _canonicalize_proto_path_oss(all_protos, genfile_path):
"""For the protos from external repository, canonicalize the proto path and the file name.
@ -50,9 +49,7 @@ def _canonicalize_proto_path_oss(all_protos, genfile_path):
proto_file_names = []
for s in all_protos.to_list():
if s.path.startswith(genfile_path):
repo_name, _, file_name = s.path[
len(genfile_path + "/external/") :
].partition("/")
repo_name, _, file_name = s.path[len(genfile_path + "/external/"):].partition("/")
# handle virtual imports
if file_name.startswith("_virtual_imports"):
@ -64,7 +61,6 @@ def _canonicalize_proto_path_oss(all_protos, genfile_path):
proto_file_names.append(s.path)
return ([" --proto_path=" + path for path in proto_paths], proto_file_names)
def _get_proto_provider(dep):
"""Get the provider for protocol buffers from a dependnecy.
@ -81,13 +77,13 @@ def _get_proto_provider(dep):
else:
fail("cannot happen, rule definition requires .proto or ProtoInfo")
def _encode_binary_proto_impl(ctx):
"""Implementation of the encode_binary_proto rule."""
all_protos = depset(
direct = [],
transitive = [
_get_proto_provider(dep).transitive_sources for dep in ctx.attr.deps
_get_proto_provider(dep).transitive_sources
for dep in ctx.attr.deps
],
)
@ -98,7 +94,8 @@ def _encode_binary_proto_impl(ctx):
)
path_list, file_list = _canonicalize_proto_path_oss(
all_protos, ctx.genfiles_dir.path
all_protos,
ctx.genfiles_dir.path,
)
# Note: the combination of absolute_paths and proto_path, as well as the exact
@ -114,10 +111,10 @@ def _encode_binary_proto_impl(ctx):
"--proto_path=" + ctx.genfiles_dir.path,
"--proto_path=" + ctx.bin_dir.path,
"--proto_path=.",
]
+ path_list
+ file_list
+ ["<", textpb.path, ">", binarypb.path],
] +
path_list +
file_list +
["<", textpb.path, ">", binarypb.path],
),
mnemonic = "EncodeProto",
)
@ -127,10 +124,9 @@ def _encode_binary_proto_impl(ctx):
DefaultInfo(
files = output_depset,
data_runfiles = ctx.runfiles(transitive_files = output_depset),
)
),
]
_encode_binary_proto = rule(
implementation = _encode_binary_proto_impl,
attrs = {
@ -153,7 +149,6 @@ _encode_binary_proto = rule(
},
)
def encode_binary_proto(name, input, message_type, deps, **kwargs):
if type(input) == type("string"):
input_label = input
@ -169,10 +164,13 @@ def encode_binary_proto(name, input, message_type, deps, **kwargs):
fail("input should be a string or a dict, got %s" % input)
_encode_binary_proto(
name=name, input=input_label, message_type=message_type, deps=deps, **kwargs
name = name,
input = input_label,
message_type = message_type,
deps = deps,
**kwargs
)
def _generate_proto_descriptor_set_impl(ctx):
"""Implementation of the generate_proto_descriptor_set rule."""
all_protos = depset(
@ -180,7 +178,7 @@ def _generate_proto_descriptor_set_impl(ctx):
_get_proto_provider(dep).transitive_sources
for dep in ctx.attr.deps
if ProtoInfo in dep or hasattr(dep, "proto")
]
],
)
descriptor = ctx.outputs.output
@ -197,12 +195,11 @@ def _generate_proto_descriptor_set_impl(ctx):
"--proto_path=" + ctx.genfiles_dir.path,
"--proto_path=" + ctx.bin_dir.path,
"--proto_path=.",
]
+ [s.path for s in all_protos.to_list()],
] +
[s.path for s in all_protos.to_list()],
mnemonic = "GenerateProtoDescriptor",
)
generate_proto_descriptor_set = rule(
implementation = _generate_proto_descriptor_set_impl,
attrs = {

View File

@ -2,7 +2,6 @@
DEFAULT_ADDITIONAL_TEST_DEPS = []
def mediapipe_cc_test(
name,
srcs = [],
@ -23,8 +22,7 @@ def mediapipe_cc_test(
requires_full_emulation = True,
# wasm_web_test arguments
browsers = None,
**kwargs
):
**kwargs):
native.cc_library(
name = name + "_lib",
testonly = 1,

View File

@ -45,7 +45,6 @@ Args
load("//mediapipe/framework/tool:build_defs.bzl", "clean_dep")
def _mediapipe_register_type_generate_cc_impl(ctx):
"""Generate a cc file that registers types with mediapipe."""
file_data_template = """
@ -62,19 +61,19 @@ def _mediapipe_register_type_generate_cc_impl(ctx):
if " " in registration_type:
fail(
(
'registration type "{}" should be fully qualified '
+ "and must not include spaces"
).format(registration_type)
'registration type "{}" should be fully qualified ' +
"and must not include spaces"
).format(registration_type),
)
registration_lines.append(
"#define TEMP_MP_TYPE {}".format(registration_type),
)
registration_lines.append(
(
"MEDIAPIPE_REGISTER_TYPE(\n"
+ " TEMP_MP_TYPE,\n"
+ ' "{}",\n'.format(registration_type)
+ " nullptr, nullptr);\n"
"MEDIAPIPE_REGISTER_TYPE(\n" +
" TEMP_MP_TYPE,\n" +
' "{}",\n'.format(registration_type) +
" nullptr, nullptr);\n"
),
)
registration_lines.append("#undef TEMP_MP_TYPE")
@ -86,7 +85,6 @@ def _mediapipe_register_type_generate_cc_impl(ctx):
ctx.actions.write(ctx.outputs.output, file_data)
mediapipe_register_type_generate_cc = rule(
implementation = _mediapipe_register_type_generate_cc_impl,
attrs = {
@ -101,10 +99,12 @@ mediapipe_register_type_generate_cc = rule(
},
)
def mediapipe_register_type(
base_name, types, deps=[], include_headers=[], visibility=["//visibility:public"]
):
base_name,
types,
deps = [],
include_headers = [],
visibility = ["//visibility:public"]):
mediapipe_register_type_generate_cc(
name = base_name + "_registration_cc",
types = types,
@ -116,10 +116,10 @@ def mediapipe_register_type(
name = base_name + "_registration",
srcs = [base_name + "_registration.cc"],
deps = depset(
deps
+ [
deps +
[
clean_dep("//mediapipe/framework:type_map"),
]
],
),
visibility = visibility,
alwayslink = 1,

View File

@ -28,7 +28,6 @@ def _config_setting_always_true(name, visibility):
],
)
def _config_setting_always_false(name, visibility):
"""Returns a config_setting with the given name that's always false.
@ -54,7 +53,6 @@ def _config_setting_always_false(name, visibility):
],
)
def _config_setting_negation(name, negate, visibility = None):
_config_setting_always_true(
name = name + "_true",
@ -70,12 +68,11 @@ def _config_setting_negation(name, negate, visibility=None):
{
"//conditions:default": ":%s_true" % name,
negate: ":%s_false" % name,
}
},
),
visibility = visibility,
)
more_selects = struct(
config_setting_negation = _config_setting_negation,
)

View File

@ -6,17 +6,14 @@
load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library")
load("//mediapipe/framework/tool:mediapipe_graph.bzl", "mediapipe_options_library")
def provided_args(**kwargs):
"""Returns the keyword arguments omitting None arguments."""
return {k: v for k, v in kwargs.items() if v != None}
def replace_suffix(string, old, new):
"""Returns a string with an old suffix replaced by a new suffix."""
return string.endswith(old) and string[:-len(old)] + new or string
def replace_deps(deps, old, new, drop_google_protobuf = True):
"""Returns deps with an old suffix replaced by a new suffix.
@ -34,7 +31,6 @@ def replace_deps(deps, old, new, drop_google_protobuf=True):
deps = [replace_suffix(dep, old, new) for dep in deps]
return deps
# TODO: load this macro from a common helper file.
def mediapipe_proto_library(
name,
@ -53,8 +49,7 @@ def mediapipe_proto_library(
def_java_proto = True,
def_jspb_proto = True,
def_options_lib = True,
portable_deps=None,
):
portable_deps = None):
"""Defines the proto_library targets needed for all mediapipe platforms.
Args:
@ -82,7 +77,7 @@ def mediapipe_proto_library(
def_java_proto,
def_jspb_proto,
portable_deps,
]
] # @unused
# The proto_library targets for the compiled ".proto" source files.
proto_deps = [":" + name]
@ -151,7 +146,6 @@ def mediapipe_proto_library(
)
)
def mediapipe_py_proto_library(
name,
srcs,
@ -159,8 +153,7 @@ def mediapipe_py_proto_library(
py_proto_deps = [],
proto_deps = None,
api_version = None,
testonly=0,
):
testonly = 0):
"""Generate py_proto_library for mediapipe open source version.
Args:
@ -172,7 +165,7 @@ def mediapipe_py_proto_library(
proto_deps: a list of dependency labels for bazel use.
testonly: test only proto or not.
"""
_ignore = [api_version, proto_deps]
_ignore = [api_version, proto_deps] # @unused
py_proto_library(
**provided_args(
name = name,
@ -185,10 +178,13 @@ def mediapipe_py_proto_library(
)
)
def mediapipe_cc_proto_library(
name, srcs, visibility=None, deps=[], cc_deps=[], testonly=0
):
name,
srcs,
visibility = None,
deps = [],
cc_deps = [],
testonly = 0):
"""Generate cc_proto_library for mediapipe open source version.
Args:
@ -196,9 +192,10 @@ def mediapipe_cc_proto_library(
srcs: the .proto files of the cc_proto_library for Bazel use.
visibility: visibility of this target.
deps: a list of dependency labels for Bazel use; must be cc_proto_library.
cc_deps:
testonly: test only proto or not.
"""
_ignore = [deps]
_ignore = [deps] # @unused
cc_proto_library(
**provided_args(
name = name,

View File

@ -5,7 +5,6 @@
def clean_dep(dep):
return str(Label(dep))
# Sanitize a list of dependencies so that they work correctly from targets that
# include MediaPipe as an external dependency.
def clean_deps(dep_list):

View File

@ -17,8 +17,8 @@ Example:
load(
"//mediapipe/framework:encode_binary_proto.bzl",
"encode_binary_proto",
"generate_proto_descriptor_set",
"encode_binary_proto", # @unused
"generate_proto_descriptor_set", # @unused
)
load("//mediapipe/framework:transitive_protos.bzl", "transitive_protos")
load("//mediapipe/framework/deps:expand_template.bzl", "expand_template")
@ -33,11 +33,23 @@ load(
"cc_library_with_tflite",
)
def mediapipe_binary_graph(
name, graph=None, output_name=None, deps=[], testonly=False, **kwargs
):
"""Converts a graph from text format to binary format."""
name,
graph = None,
output_name = None,
deps = [],
testonly = False,
**kwargs): # @unused
"""Converts a graph from text format to binary format.
Args:
name:
graph:
output_name:
deps:
testonly:
**kwargs:
"""
if not graph:
fail("No input graph file specified.")
@ -69,18 +81,17 @@ def mediapipe_binary_graph(
srcs = [graph],
outs = [output_name],
cmd = (
"$(location "
+ name
+ "_text_to_binary_graph"
+ ") "
+ ("--proto_source=$(location %s) " % graph)
+ ('--proto_output="$@" ')
"$(location " +
name +
"_text_to_binary_graph" +
") " +
("--proto_source=$(location %s) " % graph) +
('--proto_output="$@" ')
),
tools = [name + "_text_to_binary_graph"],
testonly = testonly,
)
def data_as_c_string(name, srcs, outs = None, testonly = None):
"""Encodes the data from a file as a C string literal.
@ -108,7 +119,6 @@ def data_as_c_string(name, srcs, outs=None, testonly=None):
testonly = testonly,
)
def mediapipe_simple_subgraph(
name,
register_as,
@ -117,8 +127,7 @@ def mediapipe_simple_subgraph(
tflite_deps = None,
visibility = None,
testonly = None,
**kwargs
):
**kwargs):
"""Defines a registered subgraph for inclusion in other graphs.
Args:
@ -153,10 +162,10 @@ def mediapipe_simple_subgraph(
out = name + "_linked.cc",
substitutions = {
"{{SUBGRAPH_CLASS_NAME}}": register_as,
"{{SUBGRAPH_INC_FILE_PATH}}": native.package_name()
+ "/"
+ graph_base_name
+ ".inc",
"{{SUBGRAPH_INC_FILE_PATH}}": native.package_name() +
"/" +
graph_base_name +
".inc",
},
testonly = testonly,
)
@ -170,8 +179,8 @@ def mediapipe_simple_subgraph(
deps = [
clean_dep("//mediapipe/framework:calculator_framework"),
clean_dep("//mediapipe/framework:subgraph"),
]
+ deps,
] +
deps,
alwayslink = 1,
visibility = visibility,
testonly = testonly,
@ -188,15 +197,14 @@ def mediapipe_simple_subgraph(
deps = [
clean_dep("//mediapipe/framework:calculator_framework"),
clean_dep("//mediapipe/framework:subgraph"),
]
+ deps,
] +
deps,
alwayslink = 1,
visibility = visibility,
testonly = testonly,
**kwargs
)
def mediapipe_reexport_library(name, actual, **kwargs):
"""Defines a cc_library that exports the headers of other libraries.
@ -216,10 +224,13 @@ def mediapipe_reexport_library(name, actual, **kwargs):
"""
native.cc_library(name = name, textual_hdrs = actual, deps = actual, **kwargs)
def mediapipe_options_library(
name, proto_lib, deps=[], visibility=None, testonly=None, **kwargs
):
name,
proto_lib,
deps = [],
visibility = None,
testonly = None,
**kwargs):
"""Registers options protobuf metadata for defining options packets.
Args:
@ -251,16 +262,16 @@ def mediapipe_options_library(
srcs = [proto_lib + "_direct-direct-descriptor-set.proto.bin"],
outs = [name + "_type_name.h"],
cmd = (
"$(location "
+ "//mediapipe/framework/tool:message_type_util"
+ ") "
+ (
"--input_path=$(location %s) "
% (proto_lib + "_direct-direct-descriptor-set.proto.bin")
)
+ (
"--root_type_macro_output_path=$(location %s) "
% (name + "_type_name.h")
"$(location " +
"//mediapipe/framework/tool:message_type_util" +
") " +
(
"--input_path=$(location %s) " %
(proto_lib + "_direct-direct-descriptor-set.proto.bin")
) +
(
"--root_type_macro_output_path=$(location %s) " %
(name + "_type_name.h")
)
),
tools = ["//mediapipe/framework/tool:message_type_util"],
@ -272,17 +283,17 @@ def mediapipe_options_library(
template = clean_dep("//mediapipe/framework/tool:options_lib_template.cc"),
out = name + ".cc",
substitutions = {
"{{MESSAGE_NAME_HEADER}}": native.package_name()
+ "/"
+ name
+ "_type_name.h",
"{{MESSAGE_PROTO_HEADER}}": native.package_name()
+ "/"
+ proto_lib.replace("_proto", ".pb.h"),
"{{DESCRIPTOR_INC_FILE_PATH}}": native.package_name()
+ "/"
+ proto_lib
+ "_descriptors.inc",
"{{MESSAGE_NAME_HEADER}}": native.package_name() +
"/" +
name +
"_type_name.h",
"{{MESSAGE_PROTO_HEADER}}": native.package_name() +
"/" +
proto_lib.replace("_proto", ".pb.h"),
"{{DESCRIPTOR_INC_FILE_PATH}}": native.package_name() +
"/" +
proto_lib +
"_descriptors.inc",
},
testonly = testonly,
)
@ -298,8 +309,8 @@ def mediapipe_options_library(
clean_dep("//mediapipe/framework/port:advanced_proto"),
clean_dep("//mediapipe/framework/tool:options_registry"),
proto_lib.replace("_proto", "_cc_proto"),
]
+ deps,
] +
deps,
alwayslink = 1,
visibility = visibility,
testonly = testonly,

View File

@ -16,7 +16,6 @@
ProtoLibsInfo = provider(fields = ["targets", "out"])
def _get_proto_rules(deps, proto_rules = None):
useful_deps = [dep for dep in deps if hasattr(dep, "proto_rules")]
if proto_rules == None:
@ -26,7 +25,6 @@ def _get_proto_rules(deps, proto_rules=None):
)
return proto_rules
def _proto_rules_aspect_impl(target, ctx):
# Make sure the rule has a srcs attribute.
proto_rules = depset()
@ -46,13 +44,11 @@ def _proto_rules_aspect_impl(target, ctx):
proto_rules = proto_rules,
)
proto_rules_aspect = aspect(
implementation = _proto_rules_aspect_impl,
attr_aspects = ["deps"],
)
def _transitive_protos_impl(ctx):
"""Implementation of transitive_protos rule.
@ -68,7 +64,6 @@ def _transitive_protos_impl(ctx):
cc_infos = depset(transitive = cc_info_sets).to_list()
return [cc_common.merge_cc_infos(cc_infos = cc_infos)]
transitive_protos = rule(
implementation = _transitive_protos_impl,
attrs = {

View File

@ -16,7 +16,7 @@ load("@bazel_skylib//lib:selects.bzl", "selects")
load("//mediapipe/gpu:metal.bzl", "metal_library")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_cc_proto_library", "mediapipe_proto_library")
load("//mediapipe/framework:mediapipe_cc_test.bzl", "mediapipe_cc_test")
load("//mediapipe/framework:mediapipe_cc_test.bzl", "mediapipe_cc_test") # @unused
load("//mediapipe/framework:more_selects.bzl", "more_selects")
licenses(["notice"])

View File

@ -1,4 +1,4 @@
"""Experimental Skylark rules for Apple's Metal.
"""Experimental Starlark rules for Apple's Metal.
This creates a .metallib file containing compiled Metal shaders.
Note that the default behavior in Xcode is to put all metal shaders into a
@ -36,19 +36,21 @@ load(
"resources",
)
def _metal_compiler_args(
ctx, src, obj, minimum_os_version, copts, diagnostics, deps_dump
):
ctx,
src,
obj,
minimum_os_version,
copts,
diagnostics,
deps_dump):
"""Returns arguments for metal compiler."""
apple_fragment = ctx.fragments.apple
platform = apple_fragment.single_arch_platform
if not minimum_os_version:
minimum_os_version = ctx.attr._xcode_config[
apple_common.XcodeVersionConfig
].minimum_os_for_platform_type(
minimum_os_version = ctx.attr._xcode_config[apple_common.XcodeVersionConfig].minimum_os_for_platform_type(
platform.platform_type,
)
@ -76,21 +78,19 @@ def _metal_compiler_args(
]
return args
def _metal_compiler_inputs(srcs, hdrs, deps = []):
"""Determines the list of inputs required for a compile action."""
cc_infos = [dep[CcInfo] for dep in deps if CcInfo in dep]
dep_headers = depset(
transitive=[cc_info.compilation_context.headers for cc_info in cc_infos]
transitive = [cc_info.compilation_context.headers for cc_info in cc_infos],
)
return depset(srcs + hdrs, transitive = [dep_headers])
def _metal_library_impl(ctx):
"""Implementation for metal_library Skylark rule."""
"""Implementation for metal_library Starlark rule."""
# A unique path for rule's outputs.
objs_outputs_path = "{}.objs/".format(ctx.label.name)
@ -117,7 +117,9 @@ def _metal_library_impl(ctx):
ctx,
xcode_path_resolve_level = apple_support.xcode_path_resolve_level.args,
inputs = _metal_compiler_inputs(
ctx.files.srcs, ctx.files.hdrs, ctx.attr.deps
ctx.files.srcs,
ctx.files.hdrs,
ctx.attr.deps,
),
outputs = [obj, diagnostics, deps_dump],
mnemonic = "MetalCompile",
@ -148,7 +150,9 @@ def _metal_library_impl(ctx):
objc_provider = apple_common.new_objc_provider(
providers = [
x[apple_common.Objc] for x in ctx.attr.deps if apple_common.Objc in x
x[apple_common.Objc]
for x in ctx.attr.deps
if apple_common.Objc in x
],
)
@ -172,14 +176,13 @@ def _metal_library_impl(ctx):
resources.bucketize_typed([output_lib], "unprocessed"),
]
METAL_LIBRARY_ATTRS = dicts.add(
apple_support.action_required_attrs(),
{
"srcs": attr.label_list(allow_files = [".metal"], allow_empty = False),
"hdrs": attr.label_list(allow_files = [".h"]),
"deps": attr.label_list(
providers=[["objc", CcInfo], [apple_common.Objc, CcInfo]]
providers = [["objc", CcInfo], [apple_common.Objc, CcInfo]],
),
"copts": attr.string_list(),
"minimum_os_version": attr.string(),
@ -192,15 +195,3 @@ metal_library = rule(
fragments = ["apple", "objc", "swift"],
output_to_genfiles = True,
)
"""
Builds a Metal library.
Args:
srcs: Metal shader sources.
hdrs: Header files used by the shader sources.
deps: objc_library targets whose headers should be visible to the shaders.
The header files declared in this rule are also visible to any objc_library
rules that have it as a dependency, so that constants and typedefs can be
shared between Metal and Objective-C code.
"""

View File

@ -12,6 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load(
"//mediapipe/framework/tool:mediapipe_graph.bzl",
"mediapipe_binary_graph",
)
licenses(["notice"])
package(default_visibility = ["//visibility:public"])
@ -74,11 +79,6 @@ cc_library(
],
)
load(
"//mediapipe/framework/tool:mediapipe_graph.bzl",
"mediapipe_binary_graph",
)
mediapipe_binary_graph(
name = "mobile_cpu_binary_graph",
graph = "object_detection_mobile_cpu.pbtxt",

View File

@ -12,33 +12,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Generates MediaPipe AAR including different variants of .so in jni folder.
Usage:
Creates a new mediapipe_aar() target in a BUILD file. For example,
putting the following code into mediapipe/examples/android/aar_demo/BUILD.
```
load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")
mediapipe_aar(
name = "demo",
calculators = ["//mediapipe/calculators/core:pass_through_calculator"],
)
```
Then, runs the following Bazel command to generate the aar.
```
$ bazel build --strip=always -s -c opt \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
--fat_apk_cpu=arm64-v8a,armeabi-v7a \
mediapipe/examples/android/aar_demo:demo.aar
```
Finally, imports the aar into Android Studio.
"""Generates MediaPipe AAR including different variants of .so in jni folder.\r
\r
Usage:\r
\r
Creates a new mediapipe_aar() target in a BUILD file. For example,\r
putting the following code into mediapipe/examples/android/aar_demo/BUILD.\r
\r
```\r
load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")\r
\r
mediapipe_aar(\r
name = "demo",\r
calculators = ["//mediapipe/calculators/core:pass_through_calculator"],\r
)\r
```\r
\r
Then, runs the following Bazel command to generate the aar.\r
\r
```\r
$ bazel build --strip=always -s -c opt \\\r
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \\\r
--fat_apk_cpu=arm64-v8a,armeabi-v7a \\\r
mediapipe/examples/android/aar_demo:demo.aar\r
```\r
\r
Finally, imports the aar into Android Studio.\r
\r
"""
load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android_library")
@ -178,7 +178,7 @@ EOF
_aar_with_jni(name, name + "_android_lib")
def _mediapipe_proto(name):
def _mediapipe_proto(name): #@unused
"""Generates MediaPipe java proto libraries.
Args:

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
@ -128,8 +130,6 @@ cc_library(
alwayslink = 1,
)
load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")
mediapipe_aar(
name = "solution_core",
srcs = glob(["**/*.java"]),