12 int fail(
const std::string& message)
14 std::cerr << message <<
'\n';
23 const std::filesystem::path header = std::filesystem::canonical(options.
header, code);
25 return fail(
"cannot read header " + options.
header.string());
28 return fail(
"--build needs --translation-unit with a compile database, or --compile-arg");
32 if (resource_dir.empty()) {
33 return fail(
"no Clang resource directory: pass --resource-dir, or put clang on PATH");
36 const std::filesystem::path sidecar =
sidecar_path(header);
45 if (!std::filesystem::exists(sidecar)) {
46 input.
scan.
stubs.push_back(sidecar.filename().string());
50 std::vector<std::filesystem::path> dependencies;
52 if (!
scan_for_build(input, [&collector](clang::ast_matchers::MatchFinder& finder) { collector.
attach(finder); },
53 dependencies, error)) {
58 for (
const auto& message : collector.
errors()) {
59 if (message.starts_with(header.string())) {
60 std::cerr << message <<
'\n';
68 const auto found = collector.
requests().find(header);
69 if (found == collector.
requests().end()) {
70 return fail(header.string() +
": contains MF_DESCRIBE text but produced no request");
74 bool inserted =
false;
79 std::cout <<
"Inserted #include \"" << sidecar.filename().string() <<
"\" into " << header.string() <<
'\n';
83 return fail(*problem);
97 std::cout <<
"Described " << found->second.records.size() <<
" type(s) in " << header.filename().string() <<
'\n';