diff options
author | Andrew Harp <andrewharp@google.com> | 2016-07-19 11:17:31 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-07-19 15:04:11 -0700 |
commit | 4e9a42b7d3764928bdb6625c26f2dbd8f0415834 (patch) | |
tree | 60916f03f0f74d59703dadb2a49d251d40167439 /tensorflow/tools/proto_text | |
parent | 3d3bbc69bb653f770976878127f107a4d40b1db3 (diff) |
Create new dep tree for gen_proto_text_functions tool to simplify/speed up mobile build.
Change: 127859525
Diffstat (limited to 'tensorflow/tools/proto_text')
-rw-r--r-- | tensorflow/tools/proto_text/BUILD | 4 | ||||
-rw-r--r-- | tensorflow/tools/proto_text/gen_proto_text_functions.cc | 3 | ||||
-rw-r--r-- | tensorflow/tools/proto_text/gen_proto_text_functions_lib.cc | 40 |
3 files changed, 35 insertions, 12 deletions
diff --git a/tensorflow/tools/proto_text/BUILD b/tensorflow/tools/proto_text/BUILD index 980a6d651e..af80d3a441 100644 --- a/tensorflow/tools/proto_text/BUILD +++ b/tensorflow/tools/proto_text/BUILD @@ -34,7 +34,7 @@ cc_binary( visibility = ["//tensorflow:internal"], deps = [ ":gen_proto_text_functions_lib", - "//tensorflow/core:lib", + "//tensorflow/core:lib_proto_parsing", ], ) @@ -50,7 +50,7 @@ cc_library( "//conditions:default": ["-lrt"], }), deps = [ - "//tensorflow/core:lib", + "//tensorflow/core:lib_proto_parsing", ], ) diff --git a/tensorflow/tools/proto_text/gen_proto_text_functions.cc b/tensorflow/tools/proto_text/gen_proto_text_functions.cc index cc664bb90b..17ab542a59 100644 --- a/tensorflow/tools/proto_text/gen_proto_text_functions.cc +++ b/tensorflow/tools/proto_text/gen_proto_text_functions.cc @@ -16,7 +16,6 @@ limitations under the License. #include <stdio.h> #include <set> -#include "tensorflow/core/platform/init_main.h" #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/protobuf.h" #include "tensorflow/core/platform/types.h" @@ -69,8 +68,6 @@ bool IsPlaceholderFile(const char* s) { // // This is meant to be invoked by a genrule. See BUILD for more information. int MainImpl(int argc, char** argv) { - tensorflow::port::InitMain(argv[0], &argc, &argv); - if (argc < 4) { LOG(ERROR) << "Pass output path, relative path, and at least proto file"; return -1; diff --git a/tensorflow/tools/proto_text/gen_proto_text_functions_lib.cc b/tensorflow/tools/proto_text/gen_proto_text_functions_lib.cc index 877269410f..ac5df77460 100644 --- a/tensorflow/tools/proto_text/gen_proto_text_functions_lib.cc +++ b/tensorflow/tools/proto_text/gen_proto_text_functions_lib.cc @@ -19,8 +19,7 @@ limitations under the License. #include <set> #include <unordered_set> -#include "tensorflow/core/lib/strings/str_util.h" -#include "tensorflow/core/lib/strings/strcat.h" +#include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/macros.h" #include "tensorflow/core/platform/types.h" @@ -30,13 +29,24 @@ using ::tensorflow::protobuf::FieldDescriptor; using ::tensorflow::protobuf::FieldOptions; using ::tensorflow::protobuf::FileDescriptor; using ::tensorflow::protobuf::OneofDescriptor; -using ::tensorflow::strings::StrAppend; -using ::tensorflow::strings::StrCat; namespace tensorflow { namespace { +template <typename... Args> +string StrCat(const Args&... args) { + std::ostringstream s; + std::vector<int>{((s << args), 0)...}; + return s.str(); +} + +template <typename... Args> +string StrAppend(string* to_append, const Args&... args) { + *to_append += StrCat(args...); + return *to_append; +} + // Class used to generate the code for proto text functions. One of these should // be created for each FileDescriptor whose code should be generated. // @@ -142,8 +152,17 @@ class Generator { // Returns the prefix needed to reference objects defined in <fd>. E.g. // "::tensorflow::test". string GetPackageReferencePrefix(const FileDescriptor* fd) { - return StrCat("::", str_util::Join(str_util::Split(fd->package(), '.'), "::"), - "::"); + string result = "::"; + const string& package = fd->package(); + for (int i = 0; i < package.size(); ++i) { + if (package[i] == '.') { + result += "::"; + } else { + result += package[i]; + } + } + result += "::"; + return result; } // Returns the name of the class generated by proto to represent <d>. @@ -646,7 +665,14 @@ void Generator::AppendMessageFunctions(const Descriptor& md) { void Generator::AddNamespaceToCurrentSection(const string& package, bool open) { Print(); - const std::vector<string> parts = str_util::Split(package, '.'); + std::vector<string> parts = {""}; + for (int i = 0; i < package.size(); ++i) { + if (package[i] == '.') { + parts.resize(parts.size() + 1); + } else { + parts.back() += package[i]; + } + } if (open) { for (const auto& p : parts) { Print("namespace ", p, " {"); |