Fix: GPU: Build issue caused by missing directories

When running `make` it can happen that the target directory
was not created before the invocation of `glsl_preprocess`.

This patch copies #141404 and creates the output directory
before creating the output files.
This commit is contained in:
Clément Foucault
2025-07-16 14:51:33 +02:00
parent 8602f893ed
commit ec9bef6425

View File

@@ -6,6 +6,7 @@
* \ingroup glsl_preprocess
*/
#include <filesystem>
#include <fstream>
#include <iostream>
#include <regex>
@@ -32,6 +33,19 @@ int main(int argc, char **argv)
exit(1);
}
/* We make the required directories here rather than having the build system
* do the work for us, as having cmake do it leads to several thousand cmake
* instances being launched, leading to significant overhead, see pr #141404
* for details. */
std::filesystem::path parent_dir = std::filesystem::path(output_file_name).parent_path();
std::error_code ec;
if (!std::filesystem::create_directories(parent_dir, ec)) {
if (ec) {
std::cerr << "Unable to create " << parent_dir << " : " << ec.message() << std::endl;
exit(1);
}
}
/* Open the output file for writing */
std::ofstream output_file(output_file_name, std::ofstream::out | std::ofstream::binary);
if (!output_file) {