13 int fail(
const std::string& message)
15 std::cerr << message <<
'\n';
24 const std::filesystem::path header = std::filesystem::canonical(options.
header, code);
26 return fail(
"cannot read header " + options.
header.string());
29 return fail(
"--build needs --translation-unit with a compile database, or --compile-arg");
33 if (resource_dir.empty()) {
34 return fail(
"no Clang resource directory: pass --resource-dir, or put clang on PATH");
46 if (!std::filesystem::exists(sidecar)) {
47 input.
scan.
stubs.push_back(sidecar.filename().string());
51 std::vector<std::filesystem::path> dependencies;
53 if (!
scan_for_build(input, [&collector](clang::ast_matchers::MatchFinder& finder) { collector.
attach(finder); },
54 dependencies, error)) {
59 for (
const auto& message : collector.
errors()) {
60 if (message.starts_with(header.string())) {
61 std::cerr << message <<
'\n';
69 const auto found = collector.
requests().find(header);
70 if (found == collector.
requests().end()) {
71 return fail(header.string() +
": contains MF_DESCRIBE_FUNCTION text but produced no request");
76 bool inserted =
false;
81 std::cout <<
"Inserted #include \"" << sidecar.filename().string() <<
"\" into " << header.string() <<
'\n';
85 return fail(*problem);
99 std::cout <<
"Described " << found->second.functions.size() <<
" function(s) in " << header.filename().string() <<
'\n';