[NFC] Expose a number of BUILD differences between Google and OSS through copybara:comment directives.

PiperOrigin-RevId: 352646325
Change-Id: I1d8923a574cdccb58dbc4d38d7d0aadb3171f5e7
This commit is contained in:
Christian Sigg 2021-01-19 13:49:48 -08:00 committed by TensorFlower Gardener
parent 91141fbf69
commit daa61db597
7 changed files with 48 additions and 11 deletions

View File

@ -833,12 +833,12 @@ tf_cc_shared_object(
per_os_targets = True, per_os_targets = True,
soversion = VERSION, soversion = VERSION,
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
# add win_def_file for tensorflow # copybara:comment_begin(OSS Windows only: DEF file for exported symbols)
win_def_file = select({ win_def_file = select({
# We need this DEF file to properly export symbols on Windows
"//tensorflow:windows": ":tensorflow_filtered_def_file", "//tensorflow:windows": ":tensorflow_filtered_def_file",
"//conditions:default": None, "//conditions:default": None,
}), }),
# copybara:comment_end
deps = [ deps = [
"//tensorflow/c:c_api", "//tensorflow/c:c_api",
"//tensorflow/c:c_api_experimental", "//tensorflow/c:c_api_experimental",
@ -866,12 +866,12 @@ tf_cc_shared_object(
per_os_targets = True, per_os_targets = True,
soversion = VERSION, soversion = VERSION,
visibility = ["//visibility:public"], 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({ win_def_file = select({
# We need this DEF file to properly export symbols on Windows
"//tensorflow:windows": ":tensorflow_filtered_def_file", "//tensorflow:windows": ":tensorflow_filtered_def_file",
"//conditions:default": None, "//conditions:default": None,
}), }),
# copybara:comment_end
deps = [ deps = [
"//tensorflow:tf_exported_symbols.lds", "//tensorflow:tf_exported_symbols.lds",
"//tensorflow:tf_version_script.lds", "//tensorflow:tf_version_script.lds",

View File

@ -525,9 +525,12 @@ cc_library(
], ],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = 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", "//third_party/eigen3",
"//tensorflow/core/platform:dynamic_annotations", "//tensorflow/core/platform:dynamic_annotations",
"//tensorflow/core/platform:platform_port", "//tensorflow/core/platform:platform_port",

View File

@ -54,6 +54,10 @@ def tf_java_op_gen_srcjar(
srcs = srcs, srcs = srcs,
outs = [gen_srcjar], outs = [gen_srcjar],
tools = [ 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, gen_tool,
] + tf_binary_additional_srcs(), ] + tf_binary_additional_srcs(),
toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime"], toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime"],

View File

@ -42,9 +42,17 @@ exports_files([
), ),
}, },
conversion_mode = conversion_mode, conversion_mode = conversion_mode,
data = [ # copybara:uncomment_begin(no special handling for Android in OSS)
":zip_%s" % test_name, # 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, shard_count = 20,
test_args = args + select({ test_args = args + select({
"//tensorflow:android": [], "//tensorflow:android": [],

View File

@ -5196,11 +5196,12 @@ py_library(
pywrap_tensorflow_macro( pywrap_tensorflow_macro(
name = "pywrap_tensorflow_internal", name = "pywrap_tensorflow_internal",
srcs = ["pywrap_tensorflow_internal.cc"], 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({ win_def_file = select({
"//tensorflow:windows": ":pywrap_tensorflow_filtered_def_file", "//tensorflow:windows": ":pywrap_tensorflow_filtered_def_file",
"//conditions:default": None, "//conditions:default": None,
}), }),
# copybara:comment_end
deps = [ deps = [
":bfloat16_lib", ":bfloat16_lib",
":cost_analyzer_lib", ":cost_analyzer_lib",

View File

@ -124,7 +124,12 @@ def gen_api_init_files(
" --compat_init_template=$(location %s)" % compat_init_template " --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" loading_flag = " --loading=default"
# copybara:comment_end
native.genrule( native.genrule(
name = name, name = name,

View File

@ -77,8 +77,20 @@ def if_nvcc(a):
"//conditions:default": [], "//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): 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) return if_cuda_is_configured(x)
# copybara:comment_end
def if_xla_available(if_true, if_false = []): def if_xla_available(if_true, if_false = []):
return select({ return select({
@ -1686,7 +1698,7 @@ def cc_header_only_library(name, deps = [], includes = [], extra_deps = [], comp
def tf_custom_op_library_additional_deps(): def tf_custom_op_library_additional_deps():
return [ return [
"@com_google_protobuf//:protobuf_headers", "@com_google_protobuf//:protobuf_headers", # copybara:comment
clean_dep("//third_party/eigen3"), clean_dep("//third_party/eigen3"),
clean_dep("//tensorflow/core:framework_headers_lib"), clean_dep("//tensorflow/core:framework_headers_lib"),
] + if_windows([clean_dep("//tensorflow/python:pywrap_tensorflow_import_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. # exporting symbols from _pywrap_tensorflow.dll on Windows.
def tf_custom_op_library_additional_deps_impl(): def tf_custom_op_library_additional_deps_impl():
return [ return [
# copybara:comment_begin
"@com_google_protobuf//:protobuf", "@com_google_protobuf//:protobuf",
"@nsync//:nsync_cpp", "@nsync//:nsync_cpp",
# copybara:comment_end
# for //third_party/eigen3 # for //third_party/eigen3
clean_dep("//third_party/eigen3"), clean_dep("//third_party/eigen3"),
# for //tensorflow/core:framework_headers_lib # for //tensorflow/core:framework_headers_lib
clean_dep("//tensorflow/core:framework"), clean_dep("//tensorflow/core:framework"),
clean_dep("//tensorflow/core:reader_base"), clean_dep("//tensorflow/core:reader_base"),