From e30f97697141255f52a62d191cb5ff81167fa1cf Mon Sep 17 00:00:00 2001 From: Jason Zaman Date: Wed, 30 May 2018 17:39:53 +0800 Subject: [PATCH] workspace: use TF_SYSTEM_LIBS to link to system libraries Signed-off-by: Jason Zaman --- tensorflow/workspace.bzl | 17 ++++++++ third_party/systemlibs/BUILD | 0 third_party/systemlibs/curl.BUILD | 12 ++++++ third_party/systemlibs/flatbuffers.BUILD | 38 +++++++++++++++++ third_party/systemlibs/gif.BUILD | 12 ++++++ third_party/systemlibs/grpc.BUILD | 54 ++++++++++++++++++++++++ third_party/systemlibs/jemalloc.BUILD | 30 +++++++++++++ third_party/systemlibs/jpeg.BUILD | 12 ++++++ third_party/systemlibs/lmdb.BUILD | 12 ++++++ third_party/systemlibs/nasm.BUILD | 12 ++++++ third_party/systemlibs/pcre.BUILD | 12 ++++++ third_party/systemlibs/png.BUILD | 12 ++++++ third_party/systemlibs/re2.BUILD | 12 ++++++ third_party/systemlibs/six.BUILD | 11 +++++ third_party/systemlibs/snappy.BUILD | 12 ++++++ third_party/systemlibs/sqlite.BUILD | 15 +++++++ third_party/systemlibs/swig.BUILD | 23 ++++++++++ third_party/systemlibs/termcolor.BUILD | 12 ++++++ third_party/systemlibs/zlib.BUILD | 12 ++++++ 19 files changed, 320 insertions(+) create mode 100644 third_party/systemlibs/BUILD create mode 100644 third_party/systemlibs/curl.BUILD create mode 100644 third_party/systemlibs/flatbuffers.BUILD create mode 100644 third_party/systemlibs/gif.BUILD create mode 100644 third_party/systemlibs/grpc.BUILD create mode 100644 third_party/systemlibs/jemalloc.BUILD create mode 100644 third_party/systemlibs/jpeg.BUILD create mode 100644 third_party/systemlibs/lmdb.BUILD create mode 100644 third_party/systemlibs/nasm.BUILD create mode 100644 third_party/systemlibs/pcre.BUILD create mode 100644 third_party/systemlibs/png.BUILD create mode 100644 third_party/systemlibs/re2.BUILD create mode 100644 third_party/systemlibs/six.BUILD create mode 100644 third_party/systemlibs/snappy.BUILD create mode 100644 third_party/systemlibs/sqlite.BUILD create mode 100644 third_party/systemlibs/swig.BUILD create mode 100644 third_party/systemlibs/termcolor.BUILD create mode 100644 third_party/systemlibs/zlib.BUILD diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index cd4f17a5ff3..4b8652b93c9 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -161,6 +161,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): ], sha256 = "2f945446b71336e7f5a2bcace1abcf0b23fbba368266c6a1be33de3de3b3c912", strip_prefix = "re2-2018-04-01", + system_build_file = clean_dep("//third_party/systemlibs:re2.BUILD"), ) tf_http_archive( @@ -226,6 +227,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "63ec86477ad3f0f6292325fd89e1d93aea2e2fd490070863f17d48f7cd387011", strip_prefix = "nasm-2.13.03", build_file = clean_dep("//third_party:nasm.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:nasm.BUILD"), ) tf_http_archive( @@ -237,6 +239,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "1a17020f859cb12711175a67eab5c71fc1904e04b587046218e36106e07eabde", strip_prefix = "libjpeg-turbo-1.5.3", build_file = clean_dep("//third_party/jpeg:jpeg.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:jpeg.BUILD"), ) tf_http_archive( @@ -249,6 +252,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): strip_prefix = "libpng-1.6.34", build_file = clean_dep("//third_party:png.BUILD"), patch_file = clean_dep("//third_party:png_fix_rpi.patch"), + system_build_file = clean_dep("//third_party/systemlibs:png.BUILD"), ) tf_http_archive( @@ -260,6 +264,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "ad68c1216c3a474cf360c7581a4001e952515b3649342100f2d7ca7c8e313da6", strip_prefix = "sqlite-amalgamation-3240000", build_file = clean_dep("//third_party:sqlite.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:sqlite.BUILD"), ) tf_http_archive( @@ -271,6 +276,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "34a7377ba834397db019e8eb122e551a49c98f49df75ec3fcc92b9a794a4f6d1", strip_prefix = "giflib-5.1.4", build_file = clean_dep("//third_party:gif.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:gif.BUILD"), ) tf_http_archive( @@ -282,6 +288,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", strip_prefix = "six-1.10.0", build_file = clean_dep("//third_party:six.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:six.BUILD"), ) tf_http_archive( @@ -315,6 +322,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b", strip_prefix = "termcolor-1.1.0", build_file = clean_dep("//third_party:termcolor.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:termcolor.BUILD"), ) tf_http_archive( @@ -421,6 +429,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): ], strip_prefix = "pcre-8.42", build_file = clean_dep("//third_party:pcre.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:pcre.BUILD"), ) tf_http_archive( @@ -433,6 +442,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): ], strip_prefix = "swig-3.0.8", build_file = clean_dep("//third_party:swig.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:swig.BUILD"), ) tf_http_archive( @@ -444,6 +454,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): ], strip_prefix = "curl-7.60.0", build_file = clean_dep("//third_party:curl.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:curl.BUILD"), ) tf_http_archive( @@ -454,6 +465,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): ], sha256 = "50db9cf2221354485eb7c3bd55a4c27190caef7048a2a1a15fbe60a498f98b44", strip_prefix = "grpc-1.13.0", + system_build_file = clean_dep("//third_party/systemlibs:grpc.BUILD"), ) tf_http_archive( @@ -489,6 +501,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "f3927859882eb608868c8c31586bb7eb84562a40a6bf5cc3e13b6b564641ea28", strip_prefix = "lmdb-LMDB_0.9.22/libraries/liblmdb", build_file = clean_dep("//third_party:lmdb.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:lmdb.BUILD"), ) tf_http_archive( @@ -521,6 +534,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", strip_prefix = "zlib-1.2.11", build_file = clean_dep("//third_party:zlib.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:zlib.BUILD"), ) tf_http_archive( @@ -542,6 +556,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "3dfa02e873ff51a11ee02b9ca391807f0c8ea0529a4924afa645fbf97163f9d4", strip_prefix = "snappy-1.1.7", build_file = clean_dep("//third_party:snappy.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:snappy.BUILD"), ) tf_http_archive( @@ -612,6 +627,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): sha256 = "3c8f25c02e806c3ce0ab5fb7da1817f89fc9732709024e2a81b6b82f7cc792a8", strip_prefix = "jemalloc-4.4.0", build_file = clean_dep("//third_party:jemalloc.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:jemalloc.BUILD"), ) java_import_external( @@ -722,6 +738,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): "https://github.com/google/flatbuffers/archive/v1.9.0.tar.gz", ], build_file = clean_dep("//third_party/flatbuffers:flatbuffers.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:flatbuffers.BUILD"), ) native.new_http_archive( diff --git a/third_party/systemlibs/BUILD b/third_party/systemlibs/BUILD new file mode 100644 index 00000000000..e69de29bb2d diff --git a/third_party/systemlibs/curl.BUILD b/third_party/systemlibs/curl.BUILD new file mode 100644 index 00000000000..c5f125caa9e --- /dev/null +++ b/third_party/systemlibs/curl.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # MIT/X derivative license + +filegroup( + name = "COPYING", + visibility = ["//visibility:public"], +) + +cc_library( + name = "curl", + linkopts = ["-lcurl"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/flatbuffers.BUILD b/third_party/systemlibs/flatbuffers.BUILD new file mode 100644 index 00000000000..14fceada826 --- /dev/null +++ b/third_party/systemlibs/flatbuffers.BUILD @@ -0,0 +1,38 @@ +licenses(["notice"]) # Apache 2.0 + +filegroup( + name = "LICENSE.txt", + visibility = ["//visibility:public"], +) + +# Public flatc library to compile flatbuffer files at runtime. +cc_library( + name = "flatbuffers", + linkopts = ["-lflatbuffers"], + visibility = ["//visibility:public"], +) + +# Public flatc compiler library. +cc_library( + name = "flatc_library", + linkopts = ["-lflatbuffers"], + visibility = ["//visibility:public"], +) + +genrule( + name = "lnflatc", + outs = ["flatc.bin"], + cmd = "ln -s $$(which flatc) $@", +) + +# Public flatc compiler. +sh_binary( + name = "flatc", + srcs = ["flatc.bin"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "runtime_cc", + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/gif.BUILD b/third_party/systemlibs/gif.BUILD new file mode 100644 index 00000000000..5eb2c918ba4 --- /dev/null +++ b/third_party/systemlibs/gif.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # MIT + +filegroup( + name = "COPYING", + visibility = ["//visibility:public"], +) + +cc_library( + name = "gif", + linkopts = ["-lgif"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/grpc.BUILD b/third_party/systemlibs/grpc.BUILD new file mode 100644 index 00000000000..fd90eb0dd3d --- /dev/null +++ b/third_party/systemlibs/grpc.BUILD @@ -0,0 +1,54 @@ +licenses(["notice"]) # Apache v2 + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +cc_library( + name = "grpc", + linkopts = ["-lgrpc"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "grpc++", + linkopts = ["-lgrpc++"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "grpc_unsecure", + linkopts = ["-lgrpc_unsecure"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "grpc++_unsecure", + linkopts = ["-lgrpc++_unsecure"], + visibility = ["//visibility:public"], +) + +genrule( + name = "ln_grpc_cpp_plugin", + outs = ["grpc_cpp_plugin.bin"], + cmd = "ln -s $$(which grpc_cpp_plugin) $@", +) + +sh_binary( + name = "grpc_cpp_plugin", + srcs = ["grpc_cpp_plugin.bin"], + visibility = ["//visibility:public"], +) + +genrule( + name = "ln_grpc_python_plugin", + outs = ["grpc_python_plugin.bin"], + cmd = "ln -s $$(which grpc_python_plugin) $@", +) + +sh_binary( + name = "grpc_python_plugin", + srcs = ["grpc_python_plugin.bin"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/jemalloc.BUILD b/third_party/systemlibs/jemalloc.BUILD new file mode 100644 index 00000000000..6a48d582ba4 --- /dev/null +++ b/third_party/systemlibs/jemalloc.BUILD @@ -0,0 +1,30 @@ +licenses(["notice"]) # BSD + +filegroup( + name = "COPYING", + visibility = ["//visibility:public"], +) + +cc_library( + name = "jemalloc_headers", + defines = [ + "jemalloc_posix_memalign=posix_memalign", + "jemalloc_malloc=malloc", + "jemalloc_realloc=realloc", + "jemalloc_free=free", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "jemalloc_impl", + linkopts = ["-ljemalloc"], + defines = [ + "jemalloc_posix_memalign=posix_memalign", + "jemalloc_malloc=malloc", + "jemalloc_realloc=realloc", + "jemalloc_free=free", + ], + visibility = ["//visibility:public"], + deps = [":jemalloc_headers"], +) diff --git a/third_party/systemlibs/jpeg.BUILD b/third_party/systemlibs/jpeg.BUILD new file mode 100644 index 00000000000..f4f52da9bda --- /dev/null +++ b/third_party/systemlibs/jpeg.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # custom notice-style license, see LICENSE.md + +filegroup( + name = "LICENSE.md", + visibility = ["//visibility:public"], +) + +cc_library( + name = "jpeg", + linkopts = ["-ljpeg"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/lmdb.BUILD b/third_party/systemlibs/lmdb.BUILD new file mode 100644 index 00000000000..6177b095ec7 --- /dev/null +++ b/third_party/systemlibs/lmdb.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # OpenLDAP Public License + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +cc_library( + name = "lmdb", + linkopts = ["-llmdb"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/nasm.BUILD b/third_party/systemlibs/nasm.BUILD new file mode 100644 index 00000000000..10ef8d88320 --- /dev/null +++ b/third_party/systemlibs/nasm.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # BSD 2-clause + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +sh_binary( + name = "nasm", + srcs = ["nasm"], + visibility = ["@jpeg//:__pkg__"], +) diff --git a/third_party/systemlibs/pcre.BUILD b/third_party/systemlibs/pcre.BUILD new file mode 100644 index 00000000000..df742388474 --- /dev/null +++ b/third_party/systemlibs/pcre.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # BSD + +filegroup( + name = "LICENCE", + visibility = ["//visibility:public"], +) + +cc_library( + name = "pcre", + linkopts = ["-lpcre"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/png.BUILD b/third_party/systemlibs/png.BUILD new file mode 100644 index 00000000000..fc6b6f2d8bb --- /dev/null +++ b/third_party/systemlibs/png.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # BSD/MIT-like license + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +cc_library( + name = "png", + linkopts = ["-lpng"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/re2.BUILD b/third_party/systemlibs/re2.BUILD new file mode 100644 index 00000000000..c18e252dbc8 --- /dev/null +++ b/third_party/systemlibs/re2.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # BSD/MIT-like license + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +cc_library( + name = "re2", + linkopts = ["-lre2"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/six.BUILD b/third_party/systemlibs/six.BUILD new file mode 100644 index 00000000000..ff9b1a540b2 --- /dev/null +++ b/third_party/systemlibs/six.BUILD @@ -0,0 +1,11 @@ +licenses(["notice"]) # MIT + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +py_library( + name = "six", + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/snappy.BUILD b/third_party/systemlibs/snappy.BUILD new file mode 100644 index 00000000000..fd2db9e2df6 --- /dev/null +++ b/third_party/systemlibs/snappy.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # BSD 3-Clause + +filegroup( + name = "COPYING", + visibility = ["//visibility:public"], +) + +cc_library( + name = "snappy", + linkopts = ["-lsnappy"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/sqlite.BUILD b/third_party/systemlibs/sqlite.BUILD new file mode 100644 index 00000000000..20ee1ebbefc --- /dev/null +++ b/third_party/systemlibs/sqlite.BUILD @@ -0,0 +1,15 @@ +licenses(["unencumbered"]) # Public Domain + +# Production build of SQLite library that's baked into TensorFlow. +cc_library( + name = "org_sqlite", + linkopts = ["-lsqlite3"], + visibility = ["//visibility:public"], +) + +# This is a Copybara sync helper for Google. +py_library( + name = "python", + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/swig.BUILD b/third_party/systemlibs/swig.BUILD new file mode 100644 index 00000000000..4c9b74dadbc --- /dev/null +++ b/third_party/systemlibs/swig.BUILD @@ -0,0 +1,23 @@ +licenses(["restricted"]) # GPLv3 + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +filegroup( + name = "templates", + visibility = ["//visibility:public"], +) + +genrule( + name = "lnswiglink", + outs = ["swiglink"], + cmd = "ln -s $$(which swig) $@", +) + +sh_binary( + name = "swig", + srcs = ["swiglink"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/termcolor.BUILD b/third_party/systemlibs/termcolor.BUILD new file mode 100644 index 00000000000..915eb621d5c --- /dev/null +++ b/third_party/systemlibs/termcolor.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # MIT + +filegroup( + name = "COPYING.txt", + visibility = ["//visibility:public"], +) + +py_library( + name = "termcolor", + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/zlib.BUILD b/third_party/systemlibs/zlib.BUILD new file mode 100644 index 00000000000..69462ae6cbc --- /dev/null +++ b/third_party/systemlibs/zlib.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # BSD/MIT-like license (for zlib) + +filegroup( + name = "zlib.h", + visibility = ["//visibility:public"], +) + +cc_library( + name = "zlib", + linkopts = ["-lz"], + visibility = ["//visibility:public"], +)