| auto in_id = _record_file(input); | auto in_id = _record_file(input); | ||||
| auto out_id = _record_file(output); | auto out_id = _record_file(output); | ||||
| auto& st = _stmt_cache(R"( | auto& st = _stmt_cache(R"( | ||||
| INSERT OR IGNORE INTO dds_deps (input_file_id, output_file_id, input_mtime) | |||||
| INSERT OR REPLACE INTO dds_deps (input_file_id, output_file_id, input_mtime) | |||||
| VALUES (?, ?, ?) | VALUES (?, ?, ?) | ||||
| )"_sql); | )"_sql); | ||||
| sqlite3::exec(st, std::forward_as_tuple(in_id, out_id, input_mtime.time_since_epoch().count())); | sqlite3::exec(st, std::forward_as_tuple(in_id, out_id, input_mtime.time_since_epoch().count())); | ||||
| DELETE FROM dds_deps | DELETE FROM dds_deps | ||||
| WHERE output_file_id IN id_to_delete | WHERE output_file_id IN id_to_delete | ||||
| )"_sql); | )"_sql); | ||||
| sqlite3::exec(st, std::forward_as_tuple(fs::weakly_canonical(file).string())); | |||||
| sqlite3::exec(st, std::forward_as_tuple(fs::weakly_canonical(file).generic_string())); | |||||
| } | } | ||||
| std::optional<std::vector<input_file_info>> database::inputs_of(path_ref file_) const { | std::optional<std::vector<input_file_info>> database::inputs_of(path_ref file_) const { | ||||
| WHERE output_file_id IN file | WHERE output_file_id IN file | ||||
| )"_sql); | )"_sql); | ||||
| st.reset(); | st.reset(); | ||||
| st.bindings[1] = file.string(); | |||||
| st.bindings[1] = file.generic_string(); | |||||
| auto tup_iter = sqlite3::iter_tuples<std::string, std::int64_t>(st); | auto tup_iter = sqlite3::iter_tuples<std::string, std::int64_t>(st); | ||||
| std::vector<input_file_info> ret; | std::vector<input_file_info> ret; | ||||
| WHERE file_id IN file | WHERE file_id IN file | ||||
| )"_sql); | )"_sql); | ||||
| st.reset(); | st.reset(); | ||||
| st.bindings[1] = file.string(); | |||||
| st.bindings[1] = file.generic_string(); | |||||
| auto opt_res = sqlite3::unpack_single_opt<std::string, std::string>(st); | auto opt_res = sqlite3::unpack_single_opt<std::string, std::string>(st); | ||||
| if (!opt_res) { | if (!opt_res) { | ||||
| return std::nullopt; | return std::nullopt; |