bazel android ok
This commit is contained in:
parent
e3a64c13c4
commit
723fc6e46e
|
@ -1,10 +1,5 @@
|
|||
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_framework")
|
||||
|
||||
load("@build_bazel_rules_android//android:rules.bzl", "android_library")
|
||||
|
||||
|
||||
|
||||
|
||||
GL_BASE_LINK_OPTS = select({
|
||||
"//conditions:default": [],
|
||||
"//mediapipe:android": [
|
||||
|
@ -108,8 +103,8 @@ cc_library(
|
|||
"OlaRenderIMP.h",
|
||||
],
|
||||
# Use -Dverbose=-1 to turn off zlib's trace logging. (#3280)
|
||||
linkstatic = True,
|
||||
linkopts = GL_BASE_LINK_OPTS_OSS,
|
||||
# linkstatic = True,
|
||||
# linkopts = GL_BASE_LINK_OPTS_OSS,
|
||||
includes = ["."],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
@ -170,14 +165,3 @@ ios_framework(
|
|||
"//mediapipe/render/module/render_queue:OlaRenderLibrary",
|
||||
],
|
||||
)
|
||||
|
||||
####### android ########
|
||||
android_library(
|
||||
name = "ola_render",
|
||||
srcs = [
|
||||
"src/com/ola/render/RenderJni.java"
|
||||
],
|
||||
deps = [
|
||||
"//mediapipe/render/module/render_queue:olarender",
|
||||
],
|
||||
)
|
|
@ -21,7 +21,7 @@
|
|||
#define USE_NEED_RECREATE 0
|
||||
|
||||
#include <stdio.h>
|
||||
// #include "macros.h"
|
||||
#include "macros.h"
|
||||
|
||||
#if USE_OLARENDER
|
||||
#include <target/TargetView.h>
|
||||
|
@ -30,12 +30,10 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
// #if PLATFORM == PLATFORM_IOS
|
||||
#ifdef __APPLE__
|
||||
#if PLATFORM == PLATFORM_IOS
|
||||
#import <OpenGLES/ES3/gl.h>
|
||||
#import <OpenGLES/ES3/glext.h>
|
||||
// #elif PLATFORM == PLATFORM_ANDROID
|
||||
#else
|
||||
#elif PLATFORM == PLATFORM_ANDROID
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
|
||||
|
|
107
mediapipe/render/module/render_queue/ola_aar.bzl
Normal file
107
mediapipe/render/module/render_queue/ola_aar.bzl
Normal file
|
@ -0,0 +1,107 @@
|
|||
#Package: com.ola.render
|
||||
#Description:
|
||||
#Author: 王强
|
||||
|
||||
|
||||
load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android_library")
|
||||
|
||||
|
||||
def ola_aar(name,
|
||||
srcs = [],
|
||||
assets = [],
|
||||
proguard_specs = [],
|
||||
assets_dir = "" ):
|
||||
|
||||
_ola_jni(
|
||||
name = name + "_jni",
|
||||
)
|
||||
|
||||
native.genrule(
|
||||
name = name + "_aar_manifest_generator",
|
||||
outs = ["AndroidManifest.xml"],
|
||||
cmd = """
|
||||
cat > $(OUTS) <<EOF
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.ola.render">
|
||||
<uses-sdk
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="27" />
|
||||
</manifest>
|
||||
EOF
|
||||
""",
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = name + "_android_lib",
|
||||
srcs = srcs,
|
||||
manifest = "AndroidManifest.xml",
|
||||
proguard_specs = proguard_specs,
|
||||
assets = assets,
|
||||
assets_dir = assets_dir,
|
||||
deps = [
|
||||
":" + name + "_jni_cc_lib",]
|
||||
)
|
||||
|
||||
_ola_aar_with_jni(name, name + "_android_lib")
|
||||
|
||||
|
||||
|
||||
def _ola_jni(name):
|
||||
native.cc_binary(
|
||||
name = "libora_render_jni.so",
|
||||
linkshared = 1,
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
"//mediapipe/render/module/render_queue:olarender",
|
||||
],
|
||||
)
|
||||
|
||||
native.cc_library(
|
||||
name = name + "_cc_lib",
|
||||
srcs = [":libora_render_jni.so"],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
def _ola_aar_with_jni(name, android_library):
|
||||
# Generates dummy AndroidManifest.xml for dummy apk usage
|
||||
# (dummy apk is generated by <name>_dummy_app target below)
|
||||
native.genrule(
|
||||
name = name + "_binary_manifest_generator",
|
||||
outs = [name + "_generated_AndroidManifest.xml"],
|
||||
cmd = """
|
||||
cat > $(OUTS) <<EOF
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="dummy.package.for.so">
|
||||
<uses-sdk android:minSdkVersion="21"/>
|
||||
</manifest>
|
||||
EOF
|
||||
""",
|
||||
)
|
||||
|
||||
# Generates dummy apk including .so files.
|
||||
# We extract out .so files and throw away the apk.
|
||||
android_binary(
|
||||
name = name + "_dummy_app",
|
||||
manifest = name + "_generated_AndroidManifest.xml",
|
||||
custom_package = "dummy.package.for.so",
|
||||
multidex = "native",
|
||||
deps = [android_library],
|
||||
)
|
||||
|
||||
native.genrule(
|
||||
name = name,
|
||||
srcs = [android_library + ".aar", name + "_dummy_app_unsigned.apk"],
|
||||
outs = [name + ".aar"],
|
||||
tags = ["manual"],
|
||||
cmd = """
|
||||
cp $(location {}.aar) $(location :{}.aar)
|
||||
chmod +w $(location :{}.aar)
|
||||
origdir=$$PWD
|
||||
cd $$(mktemp -d)
|
||||
unzip $$origdir/$(location :{}_dummy_app_unsigned.apk) "lib/*"
|
||||
cp -r lib jni
|
||||
zip -r $$origdir/$(location :{}.aar) jni/*/*.so
|
||||
""".format(android_library, name, name, name, name),
|
||||
)
|
|
@ -0,0 +1,19 @@
|
|||
load("//mediapipe/render/module/render_queue:ola_aar.bzl", "ola_aar")
|
||||
|
||||
|
||||
android_library(
|
||||
name = "RenderJni",
|
||||
srcs = ["RenderJni.java"],
|
||||
deps = [],
|
||||
)
|
||||
|
||||
ola_aar(
|
||||
name = "ola_render",
|
||||
srcs = [
|
||||
"RenderJni.java"
|
||||
],
|
||||
proguard_specs = ["proguard.pgcfg"],
|
||||
# deps = [
|
||||
# "//mediapipe/render/module/render_queue:olarender",
|
||||
# ],
|
||||
)
|
|
@ -0,0 +1,29 @@
|
|||
# Additional flags to pass to Proguard when processing a binary that uses
|
||||
# MediaPipe.
|
||||
|
||||
# Keep public members of our public interfaces. This also prevents the
|
||||
# obfuscation of the corresponding methods in classes implementing them,
|
||||
# such as implementations of PacketCallback#process.
|
||||
-keep public interface com.google.mediapipe.framework.* {
|
||||
public *;
|
||||
}
|
||||
|
||||
# This method is invoked by native code.
|
||||
-keep public class com.google.mediapipe.framework.Packet {
|
||||
public static *** create(***);
|
||||
public long getNativeHandle();
|
||||
public void release();
|
||||
}
|
||||
|
||||
# This method is invoked by native code.
|
||||
-keep public class com.google.mediapipe.framework.PacketCreator {
|
||||
*** releaseWithSyncToken(...);
|
||||
}
|
||||
|
||||
# This method is invoked by native code.
|
||||
-keep public class com.google.mediapipe.framework.MediaPipeException {
|
||||
<init>(int, byte[]);
|
||||
}
|
||||
|
||||
# Required to use PacketCreator#createProto
|
||||
-keep class com.google.mediapipe.framework.ProtoUtil$SerializedMessage { *; }
|
Loading…
Reference in New Issue
Block a user