MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ write_depfile()

bool MayaFlux::Reflect::Tool::write_depfile ( const std::filesystem::path & path,
const std::string & target,
const std::vector< std::filesystem::path > & dependencies,
std::string & error )
nodiscard

Writes a depfile of the form target: dependency... that CMake's DEPFILE reads.

Paths use forward slashes. Spaces, hashes and dollar signs are escaped.

Returns
false with error set when the file cannot be written.

Definition at line 72 of file Build.cpp.

74{
75 std::string text = escaped(std::filesystem::path(target).generic_string()) + ":";
76 for (const auto& dependency : dependencies) {
77 text += " \\\n " + escaped(dependency.generic_string());
78 }
79 text += '\n';
80
81 std::error_code code;
82 if (path.has_parent_path()) {
83 std::filesystem::create_directories(path.parent_path(), code);
84 if (code) {
85 error = "cannot create " + path.parent_path().string();
86 return false;
87 }
88 }
89 return write_if_changed(path, text, error);
90}
bool write_if_changed(const std::filesystem::path &path, const std::string &content, std::string &error)
Replaces path with content only when the content differs.
Definition Sidecar.cpp:137

References write_if_changed().

Referenced by run_creator_build(), run_function_build(), and run_reflect_build().

Here is the call graph for this function:
Here is the caller graph for this function: