fix(autogen): opening log file before created generated directory

This commit is contained in:
maelstrom 2025-07-24 19:59:36 +02:00
parent 243af95a3b
commit 143d3769c7

View file

@ -43,6 +43,8 @@ int processHeader(fs::path srcRoot, fs::path srcPath, fs::path outPath) {
return 1; return 1;
} }
fs::create_directories(outPath.parent_path()); // Make sure generated dir exists before we try writing to it
// We write to a special log file instead of stdout/stderr to // We write to a special log file instead of stdout/stderr to
// 1. avoid confusion // 1. avoid confusion
// 2. prevent MSBuild from reading the word "error" and detecting there's a problem with the program (there isn't) // 2. prevent MSBuild from reading the word "error" and detecting there's a problem with the program (there isn't)
@ -74,8 +76,6 @@ int processHeader(fs::path srcRoot, fs::path srcPath, fs::path outPath) {
data::analyzeClasses(cursor, srcRootStr, &dataAnlyState); data::analyzeClasses(cursor, srcRootStr, &dataAnlyState);
enum_::analyzeClasses(cursor, srcRootStr, &enumAnlyState); enum_::analyzeClasses(cursor, srcRootStr, &enumAnlyState);
fs::create_directories(outPath.parent_path()); // Make sure generated dir exists before we try writing to it
printf("[AUTOGEN] Generating file %s...\n", relpathStr.c_str()); printf("[AUTOGEN] Generating file %s...\n", relpathStr.c_str());
std::ofstream outStream(outPathStr); std::ofstream outStream(outPathStr);