From cbbd4718a01ee014fe0fc77945738cf35dd6b738 Mon Sep 17 00:00:00 2001 From: Jiuqiang Tang Date: Wed, 12 Oct 2022 03:44:52 -0700 Subject: [PATCH] Update mediapipe_aar.bzl to put more mediapipe framework java proto classes into AARs. PiperOrigin-RevId: 480583365 --- .../com/google/mediapipe/mediapipe_aar.bzl | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/mediapipe/java/com/google/mediapipe/mediapipe_aar.bzl b/mediapipe/java/com/google/mediapipe/mediapipe_aar.bzl index 7f2cb146c..9b01e2f0b 100644 --- a/mediapipe/java/com/google/mediapipe/mediapipe_aar.bzl +++ b/mediapipe/java/com/google/mediapipe/mediapipe_aar.bzl @@ -164,7 +164,10 @@ EOF assets_dir = assets_dir, ) - _aar_with_jni(name, name + "_android_lib") + mediapipe_build_aar_with_jni( + name = name, + android_library = name + "_android_lib", + ) def _mediapipe_jni(name, gen_libmediapipe, calculators = []): """Generates MediaPipe jni library. @@ -203,7 +206,14 @@ def _mediapipe_jni(name, gen_libmediapipe, calculators = []): alwayslink = 1, ) -def _aar_with_jni(name, android_library): +def mediapipe_build_aar_with_jni(name, android_library): + """Builds MediaPipe AAR with jni. + + Args: + name: The bazel target name. + android_library: the android library that contains jni. + """ + # Generates dummy AndroidManifest.xml for dummy apk usage # (dummy apk is generated by _dummy_app target below) native.genrule( @@ -214,7 +224,7 @@ cat > $(OUTS) < - + EOF """, @@ -241,6 +251,7 @@ chmod +w $(location :{}.aar) origdir=$$PWD cd $$(mktemp -d) unzip $$origdir/$(location :{}_dummy_app_unsigned.apk) "lib/*" +find lib -name *_dummy_app.so -delete cp -r lib jni zip -r $$origdir/$(location :{}.aar) jni/*/*.so """.format(android_library, name, name, name, name), @@ -287,6 +298,36 @@ def mediapipe_java_proto_srcs(name = ""): src_out = "com/google/mediapipe/proto/CalculatorProto.java", )) + proto_src_list.append(mediapipe_java_proto_src_extractor( + target = "//mediapipe/framework:calculator_options_java_proto_lite", + src_out = "com/google/mediapipe/proto/CalculatorOptionsProto.java", + )) + + proto_src_list.append(mediapipe_java_proto_src_extractor( + target = "//mediapipe/framework:stream_handler_java_proto_lite", + src_out = "com/google/mediapipe/proto/StreamHandlerProto.java", + )) + + proto_src_list.append(mediapipe_java_proto_src_extractor( + target = "//mediapipe/framework:packet_factory_java_proto_lite", + src_out = "com/google/mediapipe/proto/PacketFactoryProto.java", + )) + + proto_src_list.append(mediapipe_java_proto_src_extractor( + target = "//mediapipe/framework:packet_generator_java_proto_lite", + src_out = "com/google/mediapipe/proto/PacketGeneratorProto.java", + )) + + proto_src_list.append(mediapipe_java_proto_src_extractor( + target = "//mediapipe/framework:status_handler_java_proto_lite", + src_out = "com/google/mediapipe/proto/StatusHandlerProto.java", + )) + + proto_src_list.append(mediapipe_java_proto_src_extractor( + target = "//mediapipe/framework:mediapipe_options_java_proto_lite", + src_out = "com/google/mediapipe/proto/MediaPipeOptionsProto.java", + )) + proto_src_list.append(mediapipe_java_proto_src_extractor( target = "//mediapipe/framework/formats:landmark_java_proto_lite", src_out = "com/google/mediapipe/formats/proto/LandmarkProto.java",