| @@ -74,7 +74,7 @@ void dds::update_deps_info(database& db, const deps_info& deps) { | |||
| } | |||
| } | |||
| 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()}; | |||
| auto cmd_ = db.command_of(output_path); | |||
| if (!cmd_) { | |||
| @@ -41,6 +41,6 @@ struct deps_rebuild_info { | |||
| 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 | |||
| @@ -162,7 +162,7 @@ void database::forget_inputs_of(path_ref file) { | |||
| 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& st = _stmt_cache(R"( | |||
| WITH file AS ( | |||
| @@ -191,7 +191,7 @@ std::optional<std::vector<input_file_info>> database::inputs_of(path_ref file_) | |||
| 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& st = _stmt_cache(R"( | |||
| WITH file AS ( | |||
| @@ -26,9 +26,9 @@ struct input_file_info { | |||
| }; | |||
| 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); | |||
| database(const database&) = delete; | |||
| @@ -49,8 +49,8 @@ public: | |||
| void store_file_command(path_ref file, const command_info& cmd); | |||
| 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 | |||