adnroid bazel

This commit is contained in:
WangQiang 2022-07-19 16:51:33 +08:00
parent 4274254831
commit e3a64c13c4
15 changed files with 147 additions and 17 deletions

View File

@ -417,7 +417,9 @@ libedgetpu_dependencies()
load("@coral_crosstool//:configure.bzl", "cc_crosstool") load("@coral_crosstool//:configure.bzl", "cc_crosstool")
cc_crosstool(name = "crosstool") cc_crosstool(name = "crosstool")
android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Library/Android/sdk") # android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Library/Android/sdk")
android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Library/Android/sdk/ndk/21.2.6472646") # android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Library/Android/sdk/ndk/21.2.6472646")
# android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Android/sdk") # android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Android/sdk")
# android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Android/sdk/ndk/android-ndk-r21") # android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Android/sdk/ndk/android-ndk-r21")
android_sdk_repository(name = "androidsdk")
android_ndk_repository(name = "androidndk", api_level=22)

View File

@ -417,7 +417,7 @@ libedgetpu_dependencies()
load("@coral_crosstool//:configure.bzl", "cc_crosstool") load("@coral_crosstool//:configure.bzl", "cc_crosstool")
cc_crosstool(name = "crosstool") cc_crosstool(name = "crosstool")
android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Library/Android/sdk") # android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Library/Android/sdk")
android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Library/Android/sdk/ndk/21.2.6472646") # android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Library/Android/sdk/ndk/21.2.6472646")
# android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Android/sdk") # android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Android/sdk")
# android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Android/sdk/ndk/android-ndk-r21") # android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Android/sdk/ndk/android-ndk-r21")

View File

@ -0,0 +1,2 @@
#Tue Jul 19 14:43:33 CST 2022
gradle.version=7.4

View File

@ -1,7 +1,96 @@
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_framework") 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": [
"-lGLESv3",
"-lEGL",
# Note: on Android, libGLESv3.so is normally a symlink to
# libGLESv2.so, so we don't need to link to it. In fact, we
# do not _want_ to link to it, or we would be unable to load
# on API level < 18, where the symlink is missing entirely.
# Note: if we ever find a strange version of Android where the
# GLESv3 library is not a symlink, we will have to load it at
# runtime. Weak GLESv3 symbols will still be resolved if we
# load it early enough.
],
"//mediapipe:ios": [
"-framework OpenGLES",
"-framework CoreVideo",
],
"//mediapipe:macos": [
"-framework OpenGL",
"-framework CoreVideo",
],
})
# This is @unused internally.
GL_BASE_LINK_OPTS_OSS = GL_BASE_LINK_OPTS + select({
"//conditions:default": [
# Use GLES/EGL on linux.
# Requires support from graphics card driver (nvidia,mesa,etc..)
# and libraries to be installed.
# Ex: libegl1-mesa-dev libgles2-mesa-dev, or libegl1-nvidia libgles2-nvidia, etc...
"-lGLESv2",
"-lEGL",
],
"//mediapipe:android": [],
"//mediapipe:ios": [],
})
cc_library( cc_library(
name = "ios_olarender", name = "gl_base",
defines = select({
"//mediapipe:apple": [
"GLES_SILENCE_DEPRECATION=1",
],
"//conditions:default": [],
}),
features = ["-layering_check"],
linkopts = GL_BASE_LINK_OPTS_OSS,
textual_hdrs = ["gl_base.h"],
visibility = ["//visibility:public"],
deps = [":gl_base_hdr"] + select({
"//mediapipe:android": [],
"//mediapipe:apple": [],
"//conditions:default": [
],
}),
)
cc_library(
name = "gl_base_hdr",
hdrs = ["gl_base.h"],
features = ["-layering_check"],
# Note: need the frameworks on Apple platforms to get the headers.
linkopts = select({
"//conditions:default": [],
"//mediapipe:ios": [
"-framework OpenGLES",
"-framework CoreVideo",
],
"//mediapipe:macos": [
"-framework OpenGL",
"-framework CoreVideo",
],
}),
visibility = ["//visibility:public"],
deps = select({
"//mediapipe:android": [],
"//mediapipe:apple": [],
"//conditions:default": [
],
}),
)
cc_library(
name = "olarender",
srcs = [ srcs = [
"util.cpp", "util.cpp",
"image_queue.cpp", "image_queue.cpp",
@ -20,10 +109,11 @@ cc_library(
], ],
# Use -Dverbose=-1 to turn off zlib's trace logging. (#3280) # Use -Dverbose=-1 to turn off zlib's trace logging. (#3280)
linkstatic = True, linkstatic = True,
linkopts = GL_BASE_LINK_OPTS_OSS,
includes = ["."], includes = ["."],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//mediapipe/modules/render_queue/math:math", "//mediapipe/render/module/render_queue/math:math",
], ],
copts = select({ copts = select({
"//mediapipe:apple": [ "//mediapipe:apple": [
@ -35,13 +125,11 @@ cc_library(
alwayslink = True, alwayslink = True,
) )
objc_library( objc_library(
name = "OlaRenderLibrary", name = "OlaRenderLibrary",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//mediapipe/modules/render_queue:ios_olarender", "//mediapipe/render/module/render_queue:olarender",
], ],
copts = select({ copts = select({
"//mediapipe:apple": [ "//mediapipe:apple": [
@ -54,8 +142,6 @@ objc_library(
"AVFoundation", "AVFoundation",
"CoreGraphics", "CoreGraphics",
"CoreMedia", "CoreMedia",
"OpenGLES",
"CoreVideo",
"IOSurface", "IOSurface",
"Foundation", "Foundation",
"UIKit", "UIKit",
@ -81,6 +167,17 @@ ios_framework(
families = ["iphone", "ipad"], families = ["iphone", "ipad"],
minimum_os_version = "10.0", minimum_os_version = "10.0",
deps = [ deps = [
"//mediapipe/modules/render_queue:OlaRenderLibrary", "//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",
], ],
) )

View File

@ -21,7 +21,7 @@
#define USE_NEED_RECREATE 0 #define USE_NEED_RECREATE 0
#include <stdio.h> #include <stdio.h>
#include "macros.h" // #include "macros.h"
#if USE_OLARENDER #if USE_OLARENDER
#include <target/TargetView.h> #include <target/TargetView.h>
@ -30,12 +30,12 @@
#endif #endif
#endif #endif
#if PLATFORM == PLATFORM_IOS // #if PLATFORM == PLATFORM_IOS
#ifdef __APPLE__
#import <OpenGLES/ES3/gl.h> #import <OpenGLES/ES3/gl.h>
#import <OpenGLES/ES3/glext.h> #import <OpenGLES/ES3/glext.h>
#elif PLATFORM == PLATFORM_ANDROID // #elif PLATFORM == PLATFORM_ANDROID
#else
#include <GLES3/gl3.h> #include <GLES3/gl3.h>
#include <GLES3/gl3ext.h> #include <GLES3/gl3ext.h>

View File

@ -0,0 +1,29 @@
/**
* @ProjectName: MyLrcRender
* @Package: com.ola.render
* @ClassName: RenderJni2
* @Description:
* @Author: 王强
* @CreateDate: 2022/7/19 14:41
*/
package com.ola.render;
public class RenderJni{
static {
System.loadLibrary("render");
}
public static native Long create();
public static native int render(
Long renderContext,
int textureId,
int width,
int height,
Long timestamp,
boolean export
);
public static native void release(Long render);
}