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

@@ -696,13 +696,33 @@ std::string GenerateCPP(const Parser &parser,
return std::string();
}
static std::string GeneratedFileName(const std::string &path,
const std::string &file_name) {
return path + file_name + "_generated.h";
}
bool GenerateCPP(const Parser &parser,
const std::string &path,
const std::string &file_name,
const GeneratorOptions &opts) {
auto code = GenerateCPP(parser, file_name, opts);
return !code.length() ||
SaveFile((path + file_name + "_generated.h").c_str(), code, false);
SaveFile(GeneratedFileName(path, file_name).c_str(), code, false);
}
std::string CPPMakeRule(const Parser &parser,
const std::string &path,
const std::string &file_name,
const GeneratorOptions & /*opts*/) {
std::string filebase = flatbuffers::StripPath(
flatbuffers::StripExtension(file_name));
std::string make_rule = GeneratedFileName(path, filebase) + ": ";
auto included_files = parser.GetIncludedFilesRecursive(file_name);
for (auto it = included_files.begin();
it != included_files.end(); ++it) {
make_rule += " " + *it;
}
return make_rule;
}
} // namespace flatbuffers