From daa61db5975af2b503e271f1e67733b0ed6a11ea Mon Sep 17 00:00:00 2001 From: Christian Sigg <csigg@google.com> Date: Tue, 19 Jan 2021 13:49:48 -0800 Subject: [PATCH] [NFC] Expose a number of BUILD differences between Google and OSS through copybara:comment directives. PiperOrigin-RevId: 352646325 Change-Id: I1d8923a574cdccb58dbc4d38d7d0aadb3171f5e7 --- tensorflow/BUILD | 8 ++++---- tensorflow/core/BUILD | 7 +++++-- tensorflow/java/src/gen/gen_ops.bzl | 4 ++++ tensorflow/lite/testing/BUILD | 14 +++++++++++--- tensorflow/python/BUILD | 3 ++- .../python/tools/api/generator/api_gen.bzl | 5 +++++ tensorflow/tensorflow.bzl | 18 +++++++++++++++++- 7 files changed, 48 insertions(+), 11 deletions(-) diff --git a/tensorflow/BUILD b/tensorflow/BUILD index 7eaf0ac79b8..4edc7ed88f4 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -833,12 +833,12 @@ tf_cc_shared_object( per_os_targets = True, soversion = VERSION, visibility = ["//visibility:public"], - # add win_def_file for tensorflow + # copybara:comment_begin(OSS Windows only: DEF file for exported symbols) win_def_file = select({ - # We need this DEF file to properly export symbols on Windows "//tensorflow:windows": ":tensorflow_filtered_def_file", "//conditions:default": None, }), + # copybara:comment_end deps = [ "//tensorflow/c:c_api", "//tensorflow/c:c_api_experimental", @@ -866,12 +866,12 @@ tf_cc_shared_object( per_os_targets = True, soversion = VERSION, visibility = ["//visibility:public"], - # add win_def_file for tensorflow_cc + # copybara:comment_begin(OSS Windows only: DEF file for exported symbols) win_def_file = select({ - # We need this DEF file to properly export symbols on Windows "//tensorflow:windows": ":tensorflow_filtered_def_file", "//conditions:default": None, }), + # copybara:comment_end deps = [ "//tensorflow:tf_exported_symbols.lds", "//tensorflow:tf_version_script.lds", diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 3b88bde7c42..0400b12caea 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -525,9 +525,12 @@ cc_library( ], visibility = ["//visibility:public"], deps = + # copybara:uncomment_begin + # if_mobile(["@nsync//:nsync_cpp"]) + + # copybara:uncomment_end_uncomment_begin + # ["@nsync//:nsync_cpp"] + + # copybara:comment_end [ - "@nsync//:nsync_cpp", - ] + [ "//third_party/eigen3", "//tensorflow/core/platform:dynamic_annotations", "//tensorflow/core/platform:platform_port", diff --git a/tensorflow/java/src/gen/gen_ops.bzl b/tensorflow/java/src/gen/gen_ops.bzl index 857df5ea61c..e80d5885a3c 100644 --- a/tensorflow/java/src/gen/gen_ops.bzl +++ b/tensorflow/java/src/gen/gen_ops.bzl @@ -54,6 +54,10 @@ def tf_java_op_gen_srcjar( srcs = srcs, outs = [gen_srcjar], tools = [ + # copybara:uncomment_begin(using system-provided in OSS build) + # "//third_party/java/jdk/jar:jar", + # "//third_party/java/jdk:jdk", + # copybara:uncomment_end gen_tool, ] + tf_binary_additional_srcs(), toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime"], diff --git a/tensorflow/lite/testing/BUILD b/tensorflow/lite/testing/BUILD index 00764f4cc86..e17f18f26c2 100644 --- a/tensorflow/lite/testing/BUILD +++ b/tensorflow/lite/testing/BUILD @@ -42,9 +42,17 @@ exports_files([ ), }, conversion_mode = conversion_mode, - data = [ - ":zip_%s" % test_name, - ], + # copybara:uncomment_begin(no special handling for Android in OSS) + # data = select({ + # "//tensorflow:android": [], + # "//conditions:default": [ + # ":zip_%s" % test_name, + # "//third_party/unzip", + # ], + # }), + # copybara:uncomment_end_and_comment_begin + data = [":zip_%s" % test_name], + # copybara:comment_end shard_count = 20, test_args = args + select({ "//tensorflow:android": [], diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD index d36a9d17088..a59ce121f5c 100644 --- a/tensorflow/python/BUILD +++ b/tensorflow/python/BUILD @@ -5196,11 +5196,12 @@ py_library( pywrap_tensorflow_macro( name = "pywrap_tensorflow_internal", srcs = ["pywrap_tensorflow_internal.cc"], - # add win_def_file for pywrap_tensorflow + # copybara:comment_begin(OSS Windows only: DEF file for exported symbols) win_def_file = select({ "//tensorflow:windows": ":pywrap_tensorflow_filtered_def_file", "//conditions:default": None, }), + # copybara:comment_end deps = [ ":bfloat16_lib", ":cost_analyzer_lib", diff --git a/tensorflow/python/tools/api/generator/api_gen.bzl b/tensorflow/python/tools/api/generator/api_gen.bzl index 45355c90aaa..51c767fd92f 100644 --- a/tensorflow/python/tools/api/generator/api_gen.bzl +++ b/tensorflow/python/tools/api/generator/api_gen.bzl @@ -124,7 +124,12 @@ def gen_api_init_files( " --compat_init_template=$(location %s)" % compat_init_template ) + # copybara:uncomment_begin(configurable API loading) + # native.vardef("TF_API_INIT_LOADING", "default") + # loading_flag = " --loading=$(TF_API_INIT_LOADING)" + # copybara:uncomment_end_and_comment_begin loading_flag = " --loading=default" + # copybara:comment_end native.genrule( name = name, diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 9c66b265355..47776d5acce 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -77,8 +77,20 @@ def if_nvcc(a): "//conditions:default": [], }) +# In Google builds, this corresponds to whether `--config=cuda` has been +# specified. In OSS, this corresponds to whether the environment contains +# TF_NEED_CUDA=1, which is in turn triggered by --config=using_cuda through +# .bazelrc, which is again triggered by --config=cuda. +# +# In other words, --config=cuda is sufficient for this function to return +# x both for Google and OSS builds. But for OSS builds it is not necessary. +# We are working on a plan to clean up this complicated setup. def if_cuda_is_configured_compat(x): + # copybara:uncomment_begin(--config=cuda is necessary and sufficient) + # return if_cuda(x) + # copybara:uncomment_end_and_comment_begin return if_cuda_is_configured(x) + # copybara:comment_end def if_xla_available(if_true, if_false = []): return select({ @@ -1686,7 +1698,7 @@ def cc_header_only_library(name, deps = [], includes = [], extra_deps = [], comp def tf_custom_op_library_additional_deps(): return [ - "@com_google_protobuf//:protobuf_headers", + "@com_google_protobuf//:protobuf_headers", # copybara:comment clean_dep("//third_party/eigen3"), clean_dep("//tensorflow/core:framework_headers_lib"), ] + if_windows([clean_dep("//tensorflow/python:pywrap_tensorflow_import_lib")]) @@ -1696,10 +1708,14 @@ def tf_custom_op_library_additional_deps(): # exporting symbols from _pywrap_tensorflow.dll on Windows. def tf_custom_op_library_additional_deps_impl(): return [ + # copybara:comment_begin "@com_google_protobuf//:protobuf", "@nsync//:nsync_cpp", + # copybara:comment_end + # for //third_party/eigen3 clean_dep("//third_party/eigen3"), + # for //tensorflow/core:framework_headers_lib clean_dep("//tensorflow/core:framework"), clean_dep("//tensorflow/core:reader_base"),