Add options to print build rule dependencies

Tested: on Linux

Bug: 16465909
Change-Id: I2f1a6def13e47716110426b00990c2c625c03251
This commit is contained in:
Gabriel Martinez
2014-11-04 10:00:56 -08:00
parent cf7135ff58
commit df4909e5f6
7 changed files with 343 additions and 70 deletions

View File

@@ -80,6 +80,12 @@ inline int64_t StringToInt(const char *str, int base = 10) {
#endif
}
// Check if file "name" exists.
inline bool FileExists(const char *name) {
std::ifstream ifs(name);
return ifs.good();
}
// Load file "name" into "buf" returning true if successful
// false otherwise. If "binary" is false data is read
// using ifstream's text mode, otherwise data is read with
@@ -234,6 +240,33 @@ inline int FromUTF8(const char **in) {
return ucc;
}
// Wraps a string to a maximum length, inserting new lines where necessary. Any
// existing whitespace will be collapsed down to a single space. A prefix or
// suffix can be provided, which will be inserted before or after a wrapped
// line, respectively.
inline std::string WordWrap(const std::string in, size_t max_length,
const std::string wrapped_line_prefix,
const std::string wrapped_line_suffix) {
std::istringstream in_stream(in);
std::string wrapped, line, word;
in_stream >> word;
line = word;
while (in_stream >> word) {
if ((line.length() + 1 + word.length() + wrapped_line_suffix.length()) <
max_length) {
line += " " + word;
} else {
wrapped += line + wrapped_line_suffix + "\n";
line = wrapped_line_prefix + word;
}
}
wrapped += line;
return wrapped;
}
} // namespace flatbuffers
#endif // FLATBUFFERS_UTIL_H_