| } | } | ||||
| } | } | ||||
| deps_rebuild_info dds::get_rebuild_info(database& db, path_ref output_path) { | |||||
| deps_rebuild_info dds::get_rebuild_info(const database& db, path_ref output_path) { | |||||
| std::unique_lock lk{db.mutex()}; | std::unique_lock lk{db.mutex()}; | ||||
| auto cmd_ = db.command_of(output_path); | auto cmd_ = db.command_of(output_path); | ||||
| if (!cmd_) { | if (!cmd_) { |
| std::string previous_command_output; | std::string previous_command_output; | ||||
| }; | }; | ||||
| deps_rebuild_info get_rebuild_info(database& db, path_ref output_path); | |||||
| deps_rebuild_info get_rebuild_info(const database& db, path_ref output_path); | |||||
| } // namespace dds | } // namespace dds |
| sqlite3::exec(st, std::forward_as_tuple(fs::weakly_canonical(file).string())); | sqlite3::exec(st, std::forward_as_tuple(fs::weakly_canonical(file).string())); | ||||
| } | } | ||||
| std::optional<std::vector<input_file_info>> database::inputs_of(path_ref file_) { | |||||
| std::optional<std::vector<input_file_info>> database::inputs_of(path_ref file_) const { | |||||
| auto file = fs::weakly_canonical(file_); | auto file = fs::weakly_canonical(file_); | ||||
| auto& st = _stmt_cache(R"( | auto& st = _stmt_cache(R"( | ||||
| WITH file AS ( | WITH file AS ( | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| std::optional<command_info> database::command_of(path_ref file_) { | |||||
| std::optional<command_info> database::command_of(path_ref file_) const { | |||||
| auto file = fs::weakly_canonical(file_); | auto file = fs::weakly_canonical(file_); | ||||
| auto& st = _stmt_cache(R"( | auto& st = _stmt_cache(R"( | ||||
| WITH file AS ( | WITH file AS ( |
| }; | }; | ||||
| class database { | class database { | ||||
| neo::sqlite3::database _db; | |||||
| neo::sqlite3::statement_cache _stmt_cache{_db}; | |||||
| mutable std::shared_mutex _mutex; | |||||
| neo::sqlite3::database _db; | |||||
| mutable neo::sqlite3::statement_cache _stmt_cache{_db}; | |||||
| mutable std::shared_mutex _mutex; | |||||
| explicit database(neo::sqlite3::database db); | explicit database(neo::sqlite3::database db); | ||||
| database(const database&) = delete; | database(const database&) = delete; | ||||
| void store_file_command(path_ref file, const command_info& cmd); | void store_file_command(path_ref file, const command_info& cmd); | ||||
| void forget_inputs_of(path_ref file); | void forget_inputs_of(path_ref file); | ||||
| std::optional<std::vector<input_file_info>> inputs_of(path_ref file); | |||||
| std::optional<command_info> command_of(path_ref file); | |||||
| std::optional<std::vector<input_file_info>> inputs_of(path_ref file) const; | |||||
| std::optional<command_info> command_of(path_ref file) const; | |||||
| }; | }; | ||||
| } // namespace dds | } // namespace dds |