diff options
author | 2017-02-10 14:51:28 -0800 | |
---|---|---|
committer | 2017-02-10 15:03:59 -0800 | |
commit | 5e2bddb8f6dd2be1f1e3c3f9b4a8e1b1047b384d (patch) | |
tree | 27d0734b5866d2e1ad012dc240e9fa157fa20661 /tensorflow/tools/lib_package | |
parent | 10c35104f1fded22221baebd903774201befcb19 (diff) |
Java: Scripts to build release artifacts.
Change: 147202107
Diffstat (limited to 'tensorflow/tools/lib_package')
-rw-r--r-- | tensorflow/tools/lib_package/BUILD | 67 | ||||
-rw-r--r-- | tensorflow/tools/lib_package/LibTensorFlowTest.java | 24 | ||||
-rwxr-xr-x | tensorflow/tools/lib_package/libtensorflow_java_test.sh | 55 |
3 files changed, 143 insertions, 3 deletions
diff --git a/tensorflow/tools/lib_package/BUILD b/tensorflow/tools/lib_package/BUILD index 41e7221efe..11a0ab4d54 100644 --- a/tensorflow/tools/lib_package/BUILD +++ b/tensorflow/tools/lib_package/BUILD @@ -1,7 +1,6 @@ -# Packaging the TensorFlow C API into a small, standalone archive for use with -# language bindings and installations without Python. +# Packaging the TensorFlow C API and Java libraries into standalone archives +# for use with language bindings and installations without Python. # -# TODO(ashankar): Something similar for the JNI library for Java? # TODO(ashankar): Something similar for the C++ API (caveat: ABI compatibility) package(default_visibility = ["//visibility:private"]) @@ -25,6 +24,21 @@ pkg_tar( ) pkg_tar( + name = "libtensorflow_jni", + extension = "tar.gz", + files = [ + "include/tensorflow/jni/LICENSE", + "//tensorflow/java:libtensorflow_jni", + ], + # Mark as "manual" till + # https://github.com/bazelbuild/bazel/issues/2352 + # and https://github.com/bazelbuild/bazel/issues/1580 + # are resolved, otherwise these rules break when built + # with Python 3. + tags = ["manual"], +) + +pkg_tar( name = "cheaders", files = ["//tensorflow/c:headers"], package_dir = "include/tensorflow/c", @@ -88,6 +102,34 @@ genrule( tools = [":concat_licenses.sh"], ) +genrule( + name = "jnilicenses_generate", + srcs = [ + "//third_party/hadoop:LICENSE.txt", + "//third_party/eigen3:LICENSE", + "@boringssl//:LICENSE", + "@com_googlesource_code_re2//:LICENSE", + "@curl//:COPYING", + "@eigen_archive//:COPYING.MPL2", + "@farmhash_archive//:COPYING", + "@gemmlowp//:LICENSE", + "@gif_archive//:COPYING", + "@grpc//:LICENSE", + "@highwayhash//:LICENSE", + "@jemalloc//:COPYING", + "@jpeg//:LICENSE.md", + "@libxsmm_archive//:LICENSE", + "@local_config_sycl//sycl:LICENSE.text", + "@nanopb_git//:LICENSE.txt", + "@png_archive//:LICENSE", + "@protobuf//:LICENSE", + "@zlib_archive//:zlib.h", + ], + outs = ["include/tensorflow/jni/LICENSE"], + cmd = "$(location :concat_licenses.sh) $(SRCS) >$@", + tools = [":concat_licenses.sh"], +) + sh_test( name = "libtensorflow_test", size = "small", @@ -105,3 +147,22 @@ sh_test( # the release by tensorflow/tools/ci_build/builds/libtensorflow.sh tags = ["manual"], ) + +sh_test( + name = "libtensorflow_java_test", + size = "small", + srcs = ["libtensorflow_java_test.sh"], + data = [ + ":LibTensorFlowTest.java", + ":libtensorflow_jni.tar.gz", + "//tensorflow/java:libtensorflow.jar", + ], + # Mark as "manual" till + # https://github.com/bazelbuild/bazel/issues/2352 + # and https://github.com/bazelbuild/bazel/issues/1580 + # are resolved, otherwise these rules break when built + # with Python 3. + # Till then, this test is explicitly executed when building + # the release by tensorflow/tools/ci_build/builds/libtensorflow.sh + tags = ["manual"], +) diff --git a/tensorflow/tools/lib_package/LibTensorFlowTest.java b/tensorflow/tools/lib_package/LibTensorFlowTest.java new file mode 100644 index 0000000000..be30beecf8 --- /dev/null +++ b/tensorflow/tools/lib_package/LibTensorFlowTest.java @@ -0,0 +1,24 @@ +/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// Companion source file for libtensorflow_java_test.sh + +import org.tensorflow.TensorFlow; + +public class LibTensorFlowTest { + public static void main(String[] args) { + System.out.println(TensorFlow.version()); + } +} diff --git a/tensorflow/tools/lib_package/libtensorflow_java_test.sh b/tensorflow/tools/lib_package/libtensorflow_java_test.sh new file mode 100755 index 0000000000..463990b79c --- /dev/null +++ b/tensorflow/tools/lib_package/libtensorflow_java_test.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# Copyright 2016 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +set -ex + +# Sanity test for the binary artifacts for the TensorFlow Java API. +# - Unarchive +# - Compile a trivial Java file that excercises the Java API and underlying +# native library. +# - Run it + +# Tools needed: java, javac, tar +JAVA="${JAVA}" +JAVAC="${JAVAC}" +TAR="${TAR}" + +[ -z "${JAVA}" ] && JAVA="java" +[ -z "${JAVAC}" ] && JAVAC="javac" +[ -z "${TAR}"] && TAR="tar" + +# bazel tests run with ${PWD} set to the root of the bazel workspace +TARFILE="${PWD}/tensorflow/tools/lib_package/libtensorflow_jni.tar.gz" +JAVAFILE="${PWD}/tensorflow/tools/lib_package/LibTensorFlowTest.java" +JARFILE="${PWD}/tensorflow/java/libtensorflow.jar" + +cd ${TEST_TMPDIR} + +# Extract the archive into a subdirectory 'jni' +mkdir jni +${TAR} -xzf ${TARFILE} -Cjni + +# Compile and run the .java file +${JAVAC} -cp ${JARFILE} -d . ${JAVAFILE} +OUTPUT=$(${JAVA} \ + -cp "${JARFILE}:." \ + -Djava.library.path=jni \ + LibTensorFlowTest) +if [ -z "${OUTPUT}" ] +then + echo "Empty output, expecting version number" + exit 1 +fi |