Move */logging.cc into :platform_base since it already exposes the header loggging.h
authorA. Unique TensorFlower <gardener@tensorflow.org>
Thu, 26 Apr 2018 19:10:34 +0000 (12:10 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Thu, 26 Apr 2018 19:13:16 +0000 (12:13 -0700)
This also brings env_time.h and env_time.cc, because on the 'default' platform logging needs env_time.

Add helpers tf_platform_srcs and tf_platform_hdrs to deal with files
that are not necessarily available in all platforms.

PiperOrigin-RevId: 194434322

tensorflow/core/BUILD
tensorflow/core/platform/default/build_config.bzl

index c1cc861..32ef0a9 100644 (file)
@@ -100,6 +100,8 @@ load("//tensorflow:tensorflow.bzl", "tf_cuda_only_cc_test")
 # For platform specific build config
 load(
     "//tensorflow/core:platform/default/build_config.bzl",
+    "tf_platform_hdrs",
+    "tf_platform_srcs",
     "tf_proto_library",
     "tf_proto_library_cc",
     "tf_additional_all_protos",
@@ -119,8 +121,6 @@ load(
     "tf_additional_libdevice_srcs",
     "tf_additional_test_deps",
     "tf_additional_test_srcs",
-    "tf_env_time_hdrs",
-    "tf_env_time_srcs",
     "tf_kernel_tests_linkstatic",
     "tf_additional_cloud_op_deps",
     "tf_additional_cloud_kernel_deps",
@@ -287,6 +287,7 @@ cc_library(
 )
 
 PLATFORM_BASE_HDRS = [
+    "platform/env_time.h",
     "platform/logging.h",
     "platform/macros.h",
     "platform/types.h",
@@ -302,7 +303,6 @@ PLATFORM_OTHER_HDRS = [
     "platform/cpu_feature_guard.h",
     "platform/dynamic_annotations.h",
     "platform/env.h",
-    "platform/env_time.h",
     "platform/file_system.h",
     "platform/file_system_helper.h",
     "platform/fingerprint.h",
@@ -324,11 +324,17 @@ PLATFORM_OTHER_HDRS = [
 # Smaller platform libraries that don't depend on "lib" or "lib_internal".
 cc_library(
     name = "platform_base",
-    srcs = glob([
-        "platform/*/integral_types.h",
-        "platform/*/logging.h",
-    ]),
+    srcs = tf_platform_hdrs([
+        "integral_types.h",
+        "logging.h",
+    ]) + tf_platform_srcs([
+        "logging.cc",
+        "env_time.cc",
+    ]) + [
+        "platform/env_time.cc",
+    ],
     hdrs = PLATFORM_BASE_HDRS,
+    copts = tf_copts(),
     deps = [
         ":lib_platform",
         "//tensorflow/core/platform/default/build_config:base",
@@ -339,7 +345,7 @@ cc_library(
 # don't have to depend on lib/platformlib.
 cc_library(
     name = "lib_proto_parsing",
-    srcs = glob(tf_additional_proto_srcs()) + tf_env_time_srcs(),
+    srcs = glob(tf_additional_proto_srcs()),
     hdrs = [
         "lib/core/errors.h",
         "lib/core/status.h",
@@ -354,9 +360,10 @@ cc_library(
         "platform/types.h",
         "platform/windows/cpu_info.h",
         "lib/bfloat16/bfloat16.h",
-    ] + tf_additional_proto_hdrs() + glob(tf_env_time_hdrs()),
+    ] + tf_additional_proto_hdrs(),
     copts = tf_copts(),
     deps = tf_lib_proto_parsing_deps() + [
+        ":platform_base",
         "@double_conversion//:double-conversion",
     ],
 )
@@ -1759,6 +1766,7 @@ cc_library(
             "platform/**/env_time.cc",
             "platform/**/cuda_libdevice_path.cc",
             "platform/**/device_tracer.cc",
+            "platform/**/logging.cc",
             "platform/abi.cc",
             "platform/variant_coding.cc",
             "platform/**/variant_cord_coding.cc",
@@ -1772,6 +1780,7 @@ cc_library(
             "platform/**/stream_executor.h",
             "platform/**/env_time.cc",
             "platform/**/device_tracer.cc",
+            "platform/**/logging.cc",
             "platform/abi.cc",
             "platform/variant_coding.cc",
             "platform/**/variant_cord_coding.cc",
@@ -2805,7 +2814,10 @@ cc_library(
     srcs = ["platform/test_main.cc"],
     copts = tf_copts(),
     deps = [
-        ":core_stringpiece",
+        # TODO(ahentz): we don't want to depend on "lib" here. It used to be
+        # that "core_stringpiece" was enough but that recently changed and
+        # we now need at least "str_util".
+        ":lib",
         ":lib_platform",
         ":stacktrace_handler",
         ":test_lite",
index ca0587e..107c381 100644 (file)
@@ -433,6 +433,23 @@ def tf_proto_library(name, srcs = [], has_services = None,
       use_grpc_plugin = has_services,
   )
 
+# A list of all files under platform matching the pattern in 'files'. In
+# contrast with 'tf_platform_srcs' below, which seletive collects files that
+# must be compiled in the 'default' platform, this is a list of all headers
+# mentioned in the platform/* files.
+def tf_platform_hdrs(files):
+  return native.glob(["platform/*/" + f for f in files])
+
+def tf_platform_srcs(files):
+  base_set = ["platform/default/" + f for f in files]
+  windows_set = base_set + ["platform/windows/" + f for f in files]
+  posix_set = base_set + ["platform/posix/" + f for f in files]
+  return select({
+    "//tensorflow:windows" : native.glob(windows_set),
+    "//tensorflow:windows_msvc" : native.glob(windows_set),
+    "//conditions:default" : native.glob(posix_set),
+  })
+
 def tf_additional_lib_hdrs(exclude = []):
   windows_hdrs = native.glob([
       "platform/default/*.h",
@@ -488,7 +505,6 @@ def tf_additional_proto_hdrs():
 
 def tf_additional_proto_srcs():
   return [
-      "platform/default/logging.cc",
       "platform/default/protobuf.cc",
   ]
 
@@ -511,25 +527,6 @@ def tf_protos_grappler():
       extra_deps=tf_protos_grappler_impl(),
       otherwise=["//tensorflow/core/grappler/costs:op_performance_data_cc"])
 
-def tf_env_time_hdrs():
-  return [
-      "platform/env_time.h",
-  ]
-
-def tf_env_time_srcs():
-  win_env_time = native.glob([
-    "platform/windows/env_time.cc",
-    "platform/env_time.cc",
-  ], exclude = [])
-  return select({
-    "//tensorflow:windows" : win_env_time,
-    "//tensorflow:windows_msvc" : win_env_time,
-    "//conditions:default" : native.glob([
-        "platform/posix/env_time.cc",
-        "platform/env_time.cc",
-      ], exclude = []),
-  })
-
 def tf_additional_cupti_wrapper_deps():
   return ["//tensorflow/core/platform/default/gpu:cupti_wrapper"]