• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Packaging for TensorFlow artifacts other than the Python API (pip whl).
2# This includes the C API, Java API, and protocol buffer files.
3
4load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
5load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda")
6load("@local_config_syslibs//:build_defs.bzl", "if_not_system_lib")
7load("//tensorflow:tensorflow.bzl", "VERSION", "VERSION_MAJOR", "if_macos")
8load("//tensorflow/core/platform:build_config_root.bzl", "tf_additional_license_deps")
9load("//third_party/mkl:build_defs.bzl", "if_enable_mkl", "if_mkl")
10
11package(default_visibility = ["//visibility:private"])
12
13genrule(
14    name = "libtensorflow_proto",
15    srcs = ["//tensorflow/core:protos_all_proto_srcs"],
16    outs = ["libtensorflow_proto.zip"],
17    cmd = "zip $@ $(SRCS)",
18)
19
20pkg_tar(
21    name = "libtensorflow",
22    extension = "tar.gz",
23    # Mark as "manual" till
24    # https://github.com/bazelbuild/bazel/issues/2352
25    # and https://github.com/bazelbuild/bazel/issues/1580
26    # are resolved, otherwise these rules break when built
27    # with Python 3.
28    tags = ["manual"],
29    deps = [
30        ":cheaders",
31        ":clib",
32        ":clicenses",
33        ":eager_cheaders",
34    ],
35)
36
37pkg_tar(
38    name = "libtensorflow_jni",
39    srcs = [
40        ":THIRD_PARTY_TF_JNI_LICENSES",
41        "//:LICENSE",
42        "//tensorflow/java:libtensorflow_jni",
43    ],
44    extension = "tar.gz",
45    # Mark as "manual" till
46    # https://github.com/bazelbuild/bazel/issues/2352
47    # and https://github.com/bazelbuild/bazel/issues/1580
48    # are resolved, otherwise these rules break when built
49    # with Python 3.
50    tags = ["manual"],
51    deps = [":common_deps"],
52)
53
54# Shared objects that all TensorFlow libraries depend on.
55pkg_tar(
56    name = "common_deps",
57    srcs = ["//tensorflow:tensorflow_framework"],
58    symlinks = if_macos(
59        {
60            "libtensorflow_framework.dylib": "libtensorflow_framework.%s.dylib" % VERSION_MAJOR,
61            "libtensorflow_framework.%s.dylib" % VERSION_MAJOR: "libtensorflow_framework.%s.dylib" % VERSION,
62        },
63        {
64            "libtensorflow_framework.so": "libtensorflow_framework.so.%s" % VERSION_MAJOR,
65            "libtensorflow_framework.so.%s" % VERSION_MAJOR: "libtensorflow_framework.so.%s" % VERSION,
66        },
67    ),
68    tags = ["manual"],
69)
70
71pkg_tar(
72    name = "cheaders",
73    srcs = [
74        "//tensorflow/c:headers",
75    ],
76    package_dir = "include/",
77    strip_prefix = "/",
78    # Mark as "manual" till
79    # https://github.com/bazelbuild/bazel/issues/2352
80    # and https://github.com/bazelbuild/bazel/issues/1580
81    # are resolved, otherwise these rules break when built
82    # with Python 3.
83    tags = ["manual"],
84)
85
86pkg_tar(
87    name = "eager_cheaders",
88    srcs = [
89        "//tensorflow/c/eager:headers",
90    ],
91    package_dir = "include/tensorflow/c/eager",
92    # Mark as "manual" till
93    # https://github.com/bazelbuild/bazel/issues/2352
94    # and https://github.com/bazelbuild/bazel/issues/1580
95    # are resolved, otherwise these rules break when built
96    # with Python 3.
97    tags = ["manual"],
98)
99
100pkg_tar(
101    name = "clib",
102    srcs = ["//tensorflow"],
103    package_dir = "lib",
104    symlinks = if_macos(
105        {
106            "lib/libtensorflow.dylib": "libtensorflow.%s.dylib" % VERSION_MAJOR,
107            "lib/libtensorflow.%s.dylib" % VERSION_MAJOR: "libtensorflow.%s.dylib" % VERSION,
108        },
109        {
110            "lib/libtensorflow.so": "libtensorflow.so.%s" % VERSION_MAJOR,
111            "lib/libtensorflow.so.%s" % VERSION_MAJOR: "libtensorflow.so.%s" % VERSION,
112        },
113    ),
114    # Mark as "manual" till
115    # https://github.com/bazelbuild/bazel/issues/2352
116    # and https://github.com/bazelbuild/bazel/issues/1580
117    # are resolved, otherwise these rules break when built
118    # with Python 3.
119    tags = ["manual"],
120    deps = [":common_deps"],
121)
122
123pkg_tar(
124    name = "clicenses",
125    srcs = [
126        ":THIRD_PARTY_TF_C_LICENSES",
127        "//:LICENSE",
128    ],
129    # Mark as "manual" till
130    # https://github.com/bazelbuild/bazel/issues/2352
131    # and https://github.com/bazelbuild/bazel/issues/1580
132    # are resolved, otherwise these rules break when built
133    # with Python 3.
134    tags = ["manual"],
135)
136
137genrule(
138    name = "clicenses_generate",
139    srcs = [
140        "//third_party/eigen3:LICENSE",
141        "//third_party/fft2d:LICENSE",
142        "//third_party/icu/data:LICENSE",
143        "@boringssl//:LICENSE",
144        "@com_google_protobuf//:LICENSE",
145        "@com_googlesource_code_re2//:LICENSE",
146        "@curl//:COPYING",
147        "@double_conversion//:LICENSE",
148        "@eigen_archive//:COPYING.MPL2",
149        "@farmhash_archive//:COPYING",
150        "@fft2d//:readme2d.txt",
151        "@gemmlowp//:LICENSE",
152        "@gif//:COPYING",
153        "@highwayhash//:LICENSE",
154        "@icu//:icu4c/LICENSE",
155        "@libjpeg_turbo//:LICENSE.md",
156        "@llvm-project//llvm:LICENSE.TXT",
157        "@llvm-project//mlir:LICENSE.TXT",
158        "@lmdb//:LICENSE",
159        "@local_config_tensorrt//:LICENSE",
160        "@nasm//:LICENSE",
161        "@nsync//:LICENSE",
162        "@png//:LICENSE",
163        "@snappy//:COPYING",
164        "@zlib//:zlib.h",
165    ] + select({
166        "//tensorflow:android": [],
167        "//tensorflow:ios": [],
168        "//tensorflow:linux_s390x": [],
169        "//tensorflow:windows": [],
170        "//conditions:default": [],
171    }) + select({
172        "//tensorflow:android": [],
173        "//tensorflow:ios": [],
174        "//tensorflow:linux_s390x": [],
175        "//tensorflow:windows": [],
176        "//tensorflow:no_gcp_support": [],
177        "//conditions:default": [
178            "@com_github_googlecloudplatform_google_cloud_cpp//:LICENSE",
179        ],
180    }) + select({
181        "//tensorflow/core/kernels:xsmm": [
182            "@libxsmm_archive//:LICENSE.md",
183        ],
184        "//conditions:default": [],
185    }) + select({
186        "//tensorflow:with_numa_support": [
187            "@hwloc//:COPYING",
188        ],
189        "//conditions:default": [],
190    }) + if_cuda([
191        "@cub_archive//:LICENSE.TXT",
192        "@local_config_nccl//:LICENSE",
193    ]) + if_mkl([
194        "//third_party/mkl_dnn:LICENSE",
195    ]) + if_enable_mkl(["//third_party/mkl:LICENSE"]) + if_not_system_lib(
196        "com_github_grpc_grpc",
197        [
198            "@com_github_grpc_grpc//:LICENSE",
199            "@com_github_grpc_grpc//third_party/address_sorting:LICENSE",
200        ],
201    ) + tf_additional_license_deps(),
202    outs = ["THIRD_PARTY_TF_C_LICENSES"],
203    cmd = "$(location :concat_licenses.sh) $(SRCS) >$@",
204    tools = [":concat_licenses.sh"],
205)
206
207genrule(
208    name = "jnilicenses_generate",
209    srcs = [
210        "//third_party/eigen3:LICENSE",
211        "//third_party/fft2d:LICENSE",
212        "//third_party/icu/data:LICENSE",
213        "@boringssl//:LICENSE",
214        "@com_google_protobuf//:LICENSE",
215        "@com_googlesource_code_re2//:LICENSE",
216        "@curl//:COPYING",
217        "@double_conversion//:LICENSE",
218        "@eigen_archive//:COPYING.MPL2",
219        "@farmhash_archive//:COPYING",
220        "@fft2d//:readme2d.txt",
221        "@gemmlowp//:LICENSE",
222        "@gif//:COPYING",
223        "@com_github_grpc_grpc//:LICENSE",
224        "@com_github_grpc_grpc//third_party/address_sorting:LICENSE",
225        "@highwayhash//:LICENSE",
226        "@icu//:icu4j/main/shared/licenses/LICENSE",
227        "@libjpeg_turbo//:LICENSE.md",
228        "@llvm-project//llvm:LICENSE.TXT",
229        "@llvm-project//mlir:LICENSE.TXT",
230        "@lmdb//:LICENSE",
231        "@local_config_tensorrt//:LICENSE",
232        "@nasm//:LICENSE",
233        "@nsync//:LICENSE",
234        "@png//:LICENSE",
235        "@snappy//:COPYING",
236        "@zlib//:zlib.h",
237    ] + select({
238        "//tensorflow:android": [],
239        "//tensorflow:ios": [],
240        "//tensorflow:linux_s390x": [],
241        "//tensorflow:windows": [],
242        "//conditions:default": [],
243    }) + select({
244        "//tensorflow:android": [],
245        "//tensorflow:ios": [],
246        "//tensorflow:linux_s390x": [],
247        "//tensorflow:windows": [],
248        "//tensorflow:no_gcp_support": [],
249        "//conditions:default": [
250            "@com_github_googlecloudplatform_google_cloud_cpp//:LICENSE",
251        ],
252    }) + select({
253        "//tensorflow/core/kernels:xsmm": [
254            "@libxsmm_archive//:LICENSE.md",
255        ],
256        "//conditions:default": [],
257    }) + select({
258        "//tensorflow:with_numa_support": [
259            "@hwloc//:COPYING",
260        ],
261        "//conditions:default": [],
262    }) + if_cuda([
263        "@cub_archive//:LICENSE.TXT",
264        "@local_config_nccl//:LICENSE",
265    ]) + if_mkl([
266        "//third_party/mkl_dnn:LICENSE",
267    ]) + if_enable_mkl(["//third_party/mkl:LICENSE"]) + tf_additional_license_deps(),
268    outs = ["THIRD_PARTY_TF_JNI_LICENSES"],
269    cmd = "$(location :concat_licenses.sh) $(SRCS) >$@",
270    tools = [":concat_licenses.sh"],
271)
272
273sh_test(
274    name = "libtensorflow_test",
275    size = "small",
276    srcs = ["libtensorflow_test.sh"],
277    data = [
278        "libtensorflow_test.c",
279        ":libtensorflow.tar.gz",
280    ],
281    # Mark as "manual" till
282    # https://github.com/bazelbuild/bazel/issues/2352
283    # and https://github.com/bazelbuild/bazel/issues/1580
284    # are resolved, otherwise these rules break when built
285    # with Python 3.
286    # Till then, this test is explicitly executed when building
287    # the release by tensorflow/tools/ci_build/builds/libtensorflow.sh
288    tags = ["manual"],
289)
290
291sh_test(
292    name = "libtensorflow_java_test",
293    size = "small",
294    srcs = ["libtensorflow_java_test.sh"],
295    data = [
296        ":LibTensorFlowTest.java",
297        ":libtensorflow_jni.tar.gz",
298        "//tensorflow/java:libtensorflow.jar",
299    ],
300    # Mark as "manual" till
301    # https://github.com/bazelbuild/bazel/issues/2352
302    # and https://github.com/bazelbuild/bazel/issues/1580
303    # are resolved, otherwise these rules break when built
304    # with Python 3.
305    # Till then, this test is explicitly executed when building
306    # the release by tensorflow/tools/ci_build/builds/libtensorflow.sh
307    tags = ["manual"],
308)
309