提交 5b3e560d 编写于 作者: M Mark McDonald 提交者: TensorFlower Gardener

Android: Adds import of model assets into build.gradle via bazel

This should be enough to get the Android examples working directly through Android Studio, that is: check out the GitHub repo, set up bazel location, load build.gradle in AS and run.
Change: 149609160
上级 e8c6631e
......@@ -69,9 +69,7 @@ android_binary(
# (and corresponding Activities in source) to reduce APK size.
assets = [
"//tensorflow/examples/android/assets:asset_files",
"@inception5h//:model_files",
"@mobile_multibox//:model_files",
"@stylize//:model_files",
":external_assets",
],
assets_dir = "",
custom_package = "org.tensorflow.demo",
......@@ -88,6 +86,15 @@ android_binary(
],
)
filegroup(
name = "external_assets",
srcs = [
"@inception5h//:model_files",
"@mobile_multibox//:model_files",
"@stylize//:model_files",
],
)
filegroup(
name = "all_files",
srcs = glob(
......
......@@ -41,6 +41,9 @@ if (buildWithMake) {
// automatically.
def makeNdkRoot = System.getenv('NDK_ROOT')
// Location of model files required as assets
def externalModelData = '../../../bazel-tensorflow/external'
// If building with Bazel, this is the location of the bazel binary.
// NOTE: Bazel does not yet support building for Android on Windows,
// so in this case the Makefile build must be used as described above.
......@@ -124,6 +127,11 @@ task buildNativeMake(type: Exec) {
//, '-T' // Uncomment to skip protobuf and speed up subsequent builds.
}
task buildExternalAssets(type: Exec) {
commandLine bazelLocation, 'build', '//tensorflow/examples/android:external_assets'
outputs.files(externalModelData)
}
task copyNativeLibs(type: Copy) {
from demoLibPath
from inferenceLibPath
......@@ -133,7 +141,22 @@ task copyNativeLibs(type: Copy) {
fileMode 0644
}
assemble.dependsOn copyNativeLibs
task copyExternalAssets(type: Copy) {
from file(externalModelData).listFiles()
include '*.pb'
include '*.txt'
include 'thumbnails/*.jpg'
into 'assets'
fileMode 0644
dependsOn buildExternalAssets
}
def copyTasks = [copyNativeLibs]
if (!buildWithMake) {
// copyExternalAssets uses bazel, so only run it when requested.
copyTasks.add(copyExternalAssets)
}
assemble.dependsOn copyTasks
afterEvaluate {
assembleDebug.dependsOn copyNativeLibs
assembleDebug.dependsOn copyTasks
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册