diff options
author | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-24 00:15:42 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-24 00:15:47 -0700 |
commit | 2e64db221901835c2ad22071c8053d42fd427528 (patch) | |
tree | 366f2ba0277efa6638838a229b61211e0d90b4a6 | |
parent | fe4ae644e55ac776b310160f363bcf71a221ee04 (diff) | |
parent | ded4efd3cf8c4f0a1a8e04c72c99c0b60fdb57bd (diff) |
Merge pull request #22060 from perfinion:systemlibs
PiperOrigin-RevId: 214220618
-rw-r--r-- | configure.py | 12 | ||||
-rw-r--r-- | tensorflow/BUILD | 8 | ||||
-rwxr-xr-x | tensorflow/workspace.bzl | 16 | ||||
-rw-r--r-- | third_party/repo.bzl | 15 | ||||
-rw-r--r-- | third_party/systemlibs/absl_py.BUILD | 1 | ||||
-rw-r--r-- | third_party/systemlibs/absl_py.absl.flags.BUILD | 11 | ||||
-rw-r--r-- | third_party/systemlibs/absl_py.absl.testing.BUILD | 7 | ||||
-rw-r--r-- | third_party/systemlibs/boringssl.BUILD | 21 | ||||
-rw-r--r-- | third_party/systemlibs/double_conversion.BUILD | 12 | ||||
-rw-r--r-- | third_party/systemlibs/gast.BUILD | 12 | ||||
-rw-r--r-- | third_party/systemlibs/google_cloud_cpp.BUILD | 6 | ||||
-rw-r--r-- | third_party/systemlibs/google_cloud_cpp.google.cloud.bigtable.BUILD | 7 | ||||
-rw-r--r-- | third_party/systemlibs/googleapis.BUILD | 12 | ||||
-rw-r--r-- | third_party/systemlibs/jsoncpp.BUILD | 2 | ||||
-rw-r--r-- | third_party/systemlibs/syslibs_configure.bzl | 6 | ||||
-rw-r--r-- | tools/bazel.rc | 5 |
16 files changed, 150 insertions, 3 deletions
diff --git a/configure.py b/configure.py index e9d162fbd2..f0b9fada5e 100644 --- a/configure.py +++ b/configure.py @@ -1401,10 +1401,20 @@ def set_grpc_build_flags(): def set_system_libs_flag(environ_cp): syslibs = environ_cp.get('TF_SYSTEM_LIBS', '') - syslibs = ','.join(sorted(syslibs.split(','))) if syslibs and syslibs != '': + if ',' in syslibs: + syslibs = ','.join(sorted(syslibs.split(','))) + else: + syslibs = ','.join(sorted(syslibs.split())) write_action_env_to_bazelrc('TF_SYSTEM_LIBS', syslibs) + if 'PREFIX' in environ_cp: + write_to_bazelrc('build --define=PREFIX=%s' % environ_cp['PREFIX']) + if 'LIBDIR' in environ_cp: + write_to_bazelrc('build --define=LIBDIR=%s' % environ_cp['LIBDIR']) + if 'INCLUDEDIR' in environ_cp: + write_to_bazelrc('build --define=INCLUDEDIR=%s' % environ_cp['INCLUDEDIR']) + def set_windows_build_flags(environ_cp): """Set Windows specific build options.""" diff --git a/tensorflow/BUILD b/tensorflow/BUILD index a6f782ba3d..3610eea42a 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -630,6 +630,14 @@ genrule( continue fi + if [[ $${d} == external* ]]; then + extname="$${d#*external/}" + extname="$${extname%%/*}" + if [[ $${TF_SYSTEM_LIBS:-} == *$${extname}* ]]; then + continue + fi + fi + mkdir -p "$@/$${d}" cp "$${f}" "$@/$${d}/" done diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index d0531f8193..d47d15315d 100755 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -179,6 +179,10 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): ], sha256 = "fdd3b3aecce60987e5525e55bf3a21d68a8695320bd5b980775af6507eec3944", strip_prefix = "google-cloud-cpp-14760a86c4ffab9943b476305c4fe927ad95db1c", + system_build_file = clean_dep("//third_party/systemlibs:google_cloud_cpp.BUILD"), + system_link_files = { + "//third_party/systemlibs:google_cloud_cpp.google.cloud.bigtable.BUILD": "google/cloud/bigtable/BUILD", + }, ) tf_http_archive( @@ -190,6 +194,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): sha256 = "824870d87a176f26bcef663e92051f532fac756d1a06b404055dc078425f4378", strip_prefix = "googleapis-f81082ea1e2f85c43649bee26e0d9871d4b41cdb", build_file = clean_dep("//third_party:googleapis.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:googleapis.BUILD"), ) tf_http_archive( @@ -319,6 +324,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): sha256 = "7068908321ecd2774f145193c4b34a11305bd104b4551b09273dfd1d6a374930", strip_prefix = "gast-0.2.0", build_file = clean_dep("//third_party:gast.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:gast.BUILD"), ) tf_http_archive( @@ -341,6 +347,11 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): ], sha256 = "95160f778a62c7a60ddeadc7bf2d83f85a23a27359814aca12cf949e896fa82c", strip_prefix = "abseil-py-pypi-v0.2.2", + system_build_file = clean_dep("//third_party/systemlibs:absl_py.BUILD"), + system_link_files = { + "//third_party/systemlibs:absl_py.absl.flags.BUILD": "absl/flags/BUILD", + "//third_party/systemlibs:absl_py.absl.testing.BUILD": "absl/testing/BUILD", + }, ) tf_http_archive( @@ -531,6 +542,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): ], sha256 = "1188e29000013ed6517168600fc35a010d58c5d321846d6a6dfee74e4c788b45", strip_prefix = "boringssl-7f634429a04abc48e2eb041c81c5235816c96514", + system_build_file = clean_dep("//third_party/systemlibs:boringssl.BUILD"), ) tf_http_archive( @@ -738,14 +750,16 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): build_file = clean_dep("//third_party:arm_neon_2_x86_sse.BUILD"), ) - native.new_http_archive( + tf_http_archive( name = "double_conversion", urls = [ + "https://mirror.bazel.build/github.com/google/double-conversion/archive/3992066a95b823efc8ccc1baf82a1cfc73f6e9b8.zip", "https://github.com/google/double-conversion/archive/3992066a95b823efc8ccc1baf82a1cfc73f6e9b8.zip", ], sha256 = "2f7fbffac0d98d201ad0586f686034371a6d152ca67508ab611adc2386ad30de", strip_prefix = "double-conversion-3992066a95b823efc8ccc1baf82a1cfc73f6e9b8", build_file = clean_dep("//third_party:double_conversion.BUILD"), + system_build_file = clean_dep("//third_party/systemlibs:double_conversion.BUILD"), ) tf_http_archive( diff --git a/third_party/repo.bzl b/third_party/repo.bzl index 7d1aa5dce9..6e30618d39 100644 --- a/third_party/repo.bzl +++ b/third_party/repo.bzl @@ -119,6 +119,10 @@ def _tf_http_archive(ctx): "%prefix%": ".." if _repos_are_siblings() else "external", }, False) + if use_syslib: + for internal_src, external_dest in ctx.attr.system_link_files.items(): + ctx.symlink(Label(internal_src), ctx.path(external_dest)) + tf_http_archive = repository_rule( implementation = _tf_http_archive, attrs = { @@ -130,6 +134,7 @@ tf_http_archive = repository_rule( "patch_file": attr.label(), "build_file": attr.label(), "system_build_file": attr.label(), + "system_link_files": attr.string_dict(), }, environ = [ "TF_SYSTEM_LIBS", @@ -180,7 +185,16 @@ def _third_party_http_archive(ctx): _apply_patch(ctx, ctx.attr.patch_file) ctx.symlink(Label(ctx.attr.build_file), buildfile_path) + link_dict = dict() + if use_syslib: + link_dict.update(ctx.attr.system_link_files) + for internal_src, external_dest in ctx.attr.link_files.items(): + # if syslib and link exists in both, use the system one + if external_dest not in link_dict.values(): + link_dict[internal_src] = external_dest + + for internal_src, external_dest in link_dict.items(): ctx.symlink(Label(internal_src), ctx.path(external_dest)) # Downloads and creates Bazel repos for dependencies. @@ -201,6 +215,7 @@ third_party_http_archive = repository_rule( "system_build_file": attr.string(mandatory = False), "patch_file": attr.label(), "link_files": attr.string_dict(), + "system_link_files": attr.string_dict(), }, environ = [ "TF_SYSTEM_LIBS", diff --git a/third_party/systemlibs/absl_py.BUILD b/third_party/systemlibs/absl_py.BUILD new file mode 100644 index 0000000000..fe756e1be2 --- /dev/null +++ b/third_party/systemlibs/absl_py.BUILD @@ -0,0 +1 @@ +licenses(["notice"]) # Apache 2.0 diff --git a/third_party/systemlibs/absl_py.absl.flags.BUILD b/third_party/systemlibs/absl_py.absl.flags.BUILD new file mode 100644 index 0000000000..95ec92b887 --- /dev/null +++ b/third_party/systemlibs/absl_py.absl.flags.BUILD @@ -0,0 +1,11 @@ +licenses(["notice"]) # Apache 2.0 + +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "LICENSE", +) + +py_library( + name = "flags", +) diff --git a/third_party/systemlibs/absl_py.absl.testing.BUILD b/third_party/systemlibs/absl_py.absl.testing.BUILD new file mode 100644 index 0000000000..c1b794c1e9 --- /dev/null +++ b/third_party/systemlibs/absl_py.absl.testing.BUILD @@ -0,0 +1,7 @@ +licenses(["notice"]) # Apache 2.0 + +py_library( + name = "parameterized", + testonly = 1, + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/boringssl.BUILD b/third_party/systemlibs/boringssl.BUILD new file mode 100644 index 0000000000..bc4c533403 --- /dev/null +++ b/third_party/systemlibs/boringssl.BUILD @@ -0,0 +1,21 @@ +licenses(["notice"]) + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +cc_library( + name = "crypto", + linkopts = ["-lcrypto"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "ssl", + linkopts = ["-lssl"], + visibility = ["//visibility:public"], + deps = [ + ":crypto", + ], +) diff --git a/third_party/systemlibs/double_conversion.BUILD b/third_party/systemlibs/double_conversion.BUILD new file mode 100644 index 0000000000..568460181a --- /dev/null +++ b/third_party/systemlibs/double_conversion.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +cc_library( + name = "double-conversion", + linkopts = ["-ldouble-conversion"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/gast.BUILD b/third_party/systemlibs/gast.BUILD new file mode 100644 index 0000000000..c6e1d0c4e0 --- /dev/null +++ b/third_party/systemlibs/gast.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # BSD 3-clause + +filegroup( + name = "PKG-INFO", + visibility = ["//visibility:public"], +) + +py_library( + name = "gast", + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/google_cloud_cpp.BUILD b/third_party/systemlibs/google_cloud_cpp.BUILD new file mode 100644 index 0000000000..cbe6e10ba5 --- /dev/null +++ b/third_party/systemlibs/google_cloud_cpp.BUILD @@ -0,0 +1,6 @@ +licenses(["notice"]) # Apache 2.0 + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/google_cloud_cpp.google.cloud.bigtable.BUILD b/third_party/systemlibs/google_cloud_cpp.google.cloud.bigtable.BUILD new file mode 100644 index 0000000000..b59d565390 --- /dev/null +++ b/third_party/systemlibs/google_cloud_cpp.google.cloud.bigtable.BUILD @@ -0,0 +1,7 @@ +licenses(["notice"]) # Apache 2.0 + +cc_library( + name = "bigtable_client", + linkopts = ["-lbigtable_client"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/googleapis.BUILD b/third_party/systemlibs/googleapis.BUILD new file mode 100644 index 0000000000..7687745df9 --- /dev/null +++ b/third_party/systemlibs/googleapis.BUILD @@ -0,0 +1,12 @@ +licenses(["notice"]) # Apache 2.0 + +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], +) + +cc_library( + name = "bigtable_protos", + linkopts = ["-lbigtable_protos"], + visibility = ["//visibility:public"], +) diff --git a/third_party/systemlibs/jsoncpp.BUILD b/third_party/systemlibs/jsoncpp.BUILD index cf91917cfb..526fd0c418 100644 --- a/third_party/systemlibs/jsoncpp.BUILD +++ b/third_party/systemlibs/jsoncpp.BUILD @@ -23,7 +23,7 @@ genrule( cmd = """ for i in $(OUTS); do i=$${i##*/} - ln -vsf /usr/include/jsoncpp/json/$$i $(@D)/include/json/$$i + ln -sf $(INCLUDEDIR)/jsoncpp/json/$$i $(@D)/include/json/$$i done """, ) diff --git a/third_party/systemlibs/syslibs_configure.bzl b/third_party/systemlibs/syslibs_configure.bzl index 8b09c9ac1f..8b0ab39eaf 100644 --- a/third_party/systemlibs/syslibs_configure.bzl +++ b/third_party/systemlibs/syslibs_configure.bzl @@ -10,11 +10,17 @@ _TF_SYSTEM_LIBS = "TF_SYSTEM_LIBS" VALID_LIBS = [ + "absl_py", "astor_archive", + "boringssl", + "com_github_googleapis_googleapis", + "com_github_googlecloudplatform_google_cloud_cpp", "com_googlesource_code_re2", "curl", "cython", + "double_conversion", "flatbuffers", + "gast_archive", "gif_archive", "grpc", "jemalloc", diff --git a/tools/bazel.rc b/tools/bazel.rc index 601e07ffdd..ccf62629d1 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -67,3 +67,8 @@ build -c opt # Modular TF build options build:dynamic_kernels --define=dynamic_loaded_kernels=true + +# Default paths for TF_SYSTEM_LIBS +build --define=PREFIX=/usr +build --define=LIBDIR=$(PREFIX)/lib +build --define=INCLUDEDIR=$(PREFIX)/include |