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

@@ -268,5 +268,40 @@ void GenerateText(const Parser &parser, const void *flatbuffer,
text += NewLine(opts);
}
std::string TextFileName(const std::string &path,
const std::string &file_name) {
return path + file_name + ".json";
}
bool GenerateTextFile(const Parser &parser,
const std::string &path,
const std::string &file_name,
const GeneratorOptions &opts) {
if (!parser.builder_.GetSize() || !parser.root_struct_def) return true;
std::string text;
GenerateText(parser, parser.builder_.GetBufferPointer(), opts,
&text);
return flatbuffers::SaveFile(TextFileName(path, file_name).c_str(),
text,
false);
}
std::string TextMakeRule(const Parser &parser,
const std::string &path,
const std::string &file_name,
const GeneratorOptions & /*opts*/) {
if (!parser.builder_.GetSize() || !parser.root_struct_def) return "";
std::string filebase = flatbuffers::StripPath(
flatbuffers::StripExtension(file_name));
std::string make_rule = TextFileName(path, filebase) + ": " + file_name;
auto included_files = parser.GetIncludedFilesRecursive(
parser.root_struct_def->file);
for (auto it = included_files.begin();
it != included_files.end(); ++it) {
make_rule += " " + *it;
}
return make_rule;
}
} // namespace flatbuffers