// tools/build_check.cpp - Fast native C++ build helper tool for Juliet project // Replaces all PowerShell scripts (build_helper.ps1, check_target.ps1, clean_unity.ps1, summary_helper.ps1) #ifndef NOMINMAX #define NOMINMAX #endif #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include #include #include #include // ============================================================================ // Minimal string / path helpers (no STL, no std::filesystem — pure speed) // ============================================================================ static constexpr int MaxPath = 1024; static constexpr int MaxFiles = 4096; static constexpr int MaxHashEntries = 512; struct FixedString { char Data[MaxPath]; int Length; FixedString() : Data{}, Length(0) {} void Set(const char* str) { assert(str != nullptr); Length = 0; while (str[Length] != '\0' && Length < MaxPath - 1) { Data[Length] = str[Length]; Length++; } Data[Length] = '\0'; } void Set(const char* str, int len) { assert(str != nullptr); assert(len >= 0 && len < MaxPath); for (int i = 0; i < len; i++) { Data[i] = str[i]; } Data[len] = '\0'; Length = len; } void Append(const char* str) { assert(str != nullptr); int i = 0; while (str[i] != '\0' && Length < MaxPath - 1) { Data[Length++] = str[i++]; } Data[Length] = '\0'; } void AppendChar(char c) { if (Length < MaxPath - 1) { Data[Length++] = c; Data[Length] = '\0'; } } [[nodiscard]] bool Equals(const char* other) const { assert(other != nullptr); return strcmp(Data, other) == 0; } [[nodiscard]] bool EqualsNoCase(const char* other) const { assert(other != nullptr); return _stricmp(Data, other) == 0; } }; [[nodiscard]] static bool StringContains(const char* haystack, const char* needle) { assert(haystack != nullptr); assert(needle != nullptr); return strstr(haystack, needle) != nullptr; } [[nodiscard]] static bool EndsWithNoCase(const char* str, const char* suffix) { assert(str != nullptr); assert(suffix != nullptr); int strLen = static_cast(strlen(str)); int sufLen = static_cast(strlen(suffix)); if (sufLen > strLen) { return false; } return _stricmp(str + strLen - sufLen, suffix) == 0; } // ============================================================================ // File I/O helpers using Win32 // ============================================================================ struct FileContent { char* Data; DWORD Size; }; [[nodiscard]] static FileContent ReadEntireFile(const char* path) { assert(path != nullptr); FileContent result = {nullptr, 0}; HANDLE file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (file == INVALID_HANDLE_VALUE) { return result; } DWORD size = GetFileSize(file, nullptr); if (size == INVALID_FILE_SIZE || size == 0) { CloseHandle(file); return result; } char* buffer = static_cast(HeapAlloc(GetProcessHeap(), 0, size + 1)); if (buffer == nullptr) { CloseHandle(file); return result; } DWORD bytesRead = 0; ReadFile(file, buffer, size, &bytesRead, nullptr); CloseHandle(file); buffer[bytesRead] = '\0'; result.Data = buffer; result.Size = bytesRead; return result; } static void FreeFileContent(FileContent& content) { if (content.Data != nullptr) { HeapFree(GetProcessHeap(), 0, content.Data); content.Data = nullptr; content.Size = 0; } } static bool WriteEntireFile(const char* path, const char* data, DWORD size) { assert(path != nullptr); assert(data != nullptr); HANDLE file = CreateFileA(path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (file == INVALID_HANDLE_VALUE) { return false; } DWORD written = 0; WriteFile(file, data, size, &written, nullptr); CloseHandle(file); return written == size; } [[nodiscard]] static bool FileExists(const char* path) { assert(path != nullptr); DWORD attribs = GetFileAttributesA(path); return (attribs != INVALID_FILE_ATTRIBUTES) && !(attribs & FILE_ATTRIBUTE_DIRECTORY); } [[nodiscard]] static bool DirectoryExists(const char* path) { assert(path != nullptr); DWORD attribs = GetFileAttributesA(path); return (attribs != INVALID_FILE_ATTRIBUTES) && (attribs & FILE_ATTRIBUTE_DIRECTORY); } static void EnsureDirectoryExists(const char* path) { assert(path != nullptr); CreateDirectoryA(path, nullptr); } [[nodiscard]] static int64_t GetFileModTimeInt64(const char* path) { assert(path != nullptr); WIN32_FILE_ATTRIBUTE_DATA data; if (GetFileAttributesExA(path, GetFileExInfoStandard, &data)) { ULARGE_INTEGER li; li.LowPart = data.ftLastWriteTime.dwLowDateTime; li.HighPart = data.ftLastWriteTime.dwHighDateTime; return static_cast(li.QuadPart); } return 0; } // ============================================================================ // FNV-1a hash // ============================================================================ [[nodiscard]] static uint64_t ComputeFnv1aHash(const char* data, DWORD size) { assert(data != nullptr); uint64_t hash = 14695981039346656037ULL; for (DWORD i = 0; i < size; i++) { hash ^= static_cast(static_cast(data[i])); hash *= 1099511628211ULL; } return hash; } // ============================================================================ // Hash cache for unity files // ============================================================================ struct HashEntry { FixedString Path; char HashStr[32]; }; struct HashCache { HashEntry* Entries; int Count; HashCache() { Entries = static_cast(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HashEntry) * MaxHashEntries)); assert(Entries != nullptr); Count = 0; } ~HashCache() { if (Entries != nullptr) { HeapFree(GetProcessHeap(), 0, Entries); Entries = nullptr; } } HashCache(const HashCache&) = delete; HashCache& operator=(const HashCache&) = delete; [[nodiscard]] const char* Find(const char* path) const { assert(path != nullptr); for (int i = 0; i < Count; i++) { if (Entries[i].Path.Equals(path)) { return Entries[i].HashStr; } } return nullptr; } void Add(const char* path, const char* hash) { assert(path != nullptr); assert(hash != nullptr); if (Count < MaxHashEntries && Entries != nullptr) { Entries[Count].Path.Set(path); strncpy_s(Entries[Count].HashStr, hash, sizeof(Entries[Count].HashStr) - 1); Count++; } } }; static void LoadHashCache(const char* cachePath, HashCache& cache) { assert(cachePath != nullptr); FileContent content = ReadEntireFile(cachePath); if (content.Data == nullptr) { return; } const char* pos = content.Data; while (*pos != '\0') { const char* lineStart = pos; while (*pos != '\0' && *pos != '\n' && *pos != '\r') { pos++; } int lineLen = static_cast(pos - lineStart); if (lineLen > 0) { const char* sep = nullptr; for (const char* c = lineStart; c < lineStart + lineLen; c++) { if (*c == '=') { sep = c; break; } } if (sep != nullptr) { FixedString key; key.Set(lineStart, static_cast(sep - lineStart)); int valLen = static_cast((lineStart + lineLen) - (sep + 1)); char val[32] = {}; if (valLen > 0 && valLen < 32) { memcpy(val, sep + 1, static_cast(valLen)); val[valLen] = '\0'; } cache.Add(key.Data, val); } } while (*pos == '\n' || *pos == '\r') { pos++; } } FreeFileContent(content); } static void SaveHashCache(const char* cachePath, const HashCache& cache) { assert(cachePath != nullptr); size_t bufSize = static_cast(MaxHashEntries) * (MaxPath + 32 + 2); char* buffer = static_cast(HeapAlloc(GetProcessHeap(), 0, bufSize)); if (buffer == nullptr) { return; } int offset = 0; for (int i = 0; i < cache.Count; i++) { int written = sprintf_s(buffer + offset, bufSize - static_cast(offset), "%s=%s\n", cache.Entries[i].Path.Data, cache.Entries[i].HashStr); if (written > 0) { offset += written; } } WriteEntireFile(cachePath, buffer, static_cast(offset)); HeapFree(GetProcessHeap(), 0, buffer); } // ============================================================================ // Clean #pragma message lines and compute hash for a unity file // ============================================================================ struct CleanResult { char HashStr[32]; bool WasCleaned; }; [[nodiscard]] static CleanResult CleanAndHashUnityFile(const char* filePath) { assert(filePath != nullptr); CleanResult result = {{}, false}; FileContent content = ReadEntireFile(filePath); if (content.Data == nullptr) { result.HashStr[0] = '\0'; return result; } bool hasPragma = StringContains(content.Data, "#pragma message"); if (hasPragma) { // Filter out #pragma message lines char* filtered = static_cast(HeapAlloc(GetProcessHeap(), 0, content.Size + 1)); assert(filtered != nullptr); DWORD filteredSize = 0; const char* pos = content.Data; while (*pos != '\0') { const char* lineStart = pos; while (*pos != '\0' && *pos != '\n') { pos++; } bool skipLine = false; for (const char* c = lineStart; c < pos; c++) { if (c + 15 <= content.Data + content.Size && memcmp(c, "#pragma message", 15) == 0) { skipLine = true; break; } } if (!skipLine) { DWORD lineLen = static_cast(pos - lineStart); memcpy(filtered + filteredSize, lineStart, lineLen); filteredSize += lineLen; if (*pos == '\n') { filtered[filteredSize++] = '\n'; } } if (*pos == '\n') { pos++; } } filtered[filteredSize] = '\0'; WriteEntireFile(filePath, filtered, filteredSize); uint64_t hashVal = ComputeFnv1aHash(filtered, filteredSize); sprintf_s(result.HashStr, "%llu", hashVal); result.WasCleaned = true; HeapFree(GetProcessHeap(), 0, filtered); } else { uint64_t hashVal = ComputeFnv1aHash(content.Data, content.Size); sprintf_s(result.HashStr, "%llu", hashVal); } FreeFileContent(content); return result; } // ============================================================================ // Recursive directory scan for newest source file time // ============================================================================ [[nodiscard]] static int64_t GetNewestSourceTimeRecursive(const char* dirPath) { assert(dirPath != nullptr); int64_t newest = 0; if (!DirectoryExists(dirPath)) { return newest; } FixedString searchPath; searchPath.Set(dirPath); searchPath.Append("\\*"); WIN32_FIND_DATAA findData; HANDLE hFind = FindFirstFileA(searchPath.Data, &findData); if (hFind == INVALID_HANDLE_VALUE) { return newest; } do { if (findData.cFileName[0] == '.' && (findData.cFileName[1] == '\0' || (findData.cFileName[1] == '.' && findData.cFileName[2] == '\0'))) { continue; } FixedString fullPath; fullPath.Set(dirPath); fullPath.AppendChar('\\'); fullPath.Append(findData.cFileName); if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { int64_t subNewest = GetNewestSourceTimeRecursive(fullPath.Data); if (subNewest > newest) { newest = subNewest; } } else { if (EndsWithNoCase(findData.cFileName, ".cpp") || EndsWithNoCase(findData.cFileName, ".h") || EndsWithNoCase(findData.cFileName, ".hpp") || EndsWithNoCase(findData.cFileName, ".inl") || EndsWithNoCase(findData.cFileName, ".c")) { ULARGE_INTEGER li; li.LowPart = findData.ftLastWriteTime.dwLowDateTime; li.HighPart = findData.ftLastWriteTime.dwHighDateTime; int64_t ft = static_cast(li.QuadPart); if (ft > newest) { newest = ft; } } } } while (FindNextFileA(hFind, &findData)); FindClose(hFind); return newest; } // ============================================================================ // Collect unity files recursively from Intermediate/ // ============================================================================ struct FilePathList { FixedString* Paths; int Count; FilePathList() { Paths = static_cast(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FixedString) * MaxFiles)); assert(Paths != nullptr); Count = 0; } ~FilePathList() { if (Paths != nullptr) { HeapFree(GetProcessHeap(), 0, Paths); Paths = nullptr; } } FilePathList(const FilePathList&) = delete; FilePathList& operator=(const FilePathList&) = delete; void Add(const char* path) { assert(path != nullptr); if (Count < MaxFiles && Paths != nullptr) { Paths[Count].Set(path); Count++; } } }; static void CollectUnityFiles(const char* dirPath, FilePathList& list) { assert(dirPath != nullptr); FixedString searchPath; searchPath.Set(dirPath); searchPath.Append("\\*"); WIN32_FIND_DATAA findData; HANDLE hFind = FindFirstFileA(searchPath.Data, &findData); if (hFind == INVALID_HANDLE_VALUE) { return; } do { if (findData.cFileName[0] == '.' && (findData.cFileName[1] == '\0' || (findData.cFileName[1] == '.' && findData.cFileName[2] == '\0'))) { continue; } FixedString fullPath; fullPath.Set(dirPath); fullPath.AppendChar('\\'); fullPath.Append(findData.cFileName); if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { CollectUnityFiles(fullPath.Data, list); } else { if (StringContains(findData.cFileName, "_Unity") && EndsWithNoCase(findData.cFileName, ".cpp")) { list.Add(fullPath.Data); } } } while (FindNextFileA(hFind, &findData)); FindClose(hFind); } // ============================================================================ // Commands // ============================================================================ static int CommandStartBuild() { EnsureDirectoryExists("Intermediate"); DeleteFileA("Intermediate\\step_start.tmp"); DeleteFileA("Intermediate\\step_timings.tmp"); FILETIME ft; GetSystemTimeAsFileTime(&ft); ULARGE_INTEGER li; li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; char buf[32]; sprintf_s(buf, "%llu", li.QuadPart); WriteEntireFile("Intermediate\\build_start.tmp", buf, static_cast(strlen(buf))); return 0; } static int CommandStartStep(int argc, char* argv[]) { assert(argv != nullptr); EnsureDirectoryExists("Intermediate"); const char* stepName = (argc > 2 && argv[2] != nullptr) ? argv[2] : "Unnamed Step"; FILETIME ft; GetSystemTimeAsFileTime(&ft); ULARGE_INTEGER li; li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; char buf[MaxPath + 64]; int len = sprintf_s(buf, "%s\n%llu\n", stepName, li.QuadPart); if (len > 0) { WriteEntireFile("Intermediate\\step_start.tmp", buf, static_cast(len)); } return 0; } static int CommandEndStep(int argc, char* argv[]) { assert(argv != nullptr); if (!FileExists("Intermediate\\step_start.tmp")) { return 0; } FileContent content = ReadEntireFile("Intermediate\\step_start.tmp"); if (content.Data == nullptr) { return 0; } char stepName[MaxPath] = "Unnamed Step"; uint64_t startTicks = 0; const char* line1End = strchr(content.Data, '\n'); if (line1End != nullptr) { int nameLen = static_cast(line1End - content.Data); if (nameLen > 0 && nameLen < MaxPath) { memcpy(stepName, content.Data, static_cast(nameLen)); stepName[nameLen] = '\0'; } sscanf_s(line1End + 1, "%llu", &startTicks); } FreeFileContent(content); DeleteFileA("Intermediate\\step_start.tmp"); if (argc > 2 && argv[2] != nullptr && argv[2][0] != '\0') { strncpy_s(stepName, argv[2], MaxPath - 1); } FILETIME ftNow; GetSystemTimeAsFileTime(&ftNow); ULARGE_INTEGER nowLi; nowLi.LowPart = ftNow.dwLowDateTime; nowLi.HighPart = ftNow.dwHighDateTime; double elapsedSeconds = static_cast(nowLi.QuadPart - startTicks) / 10000000.0; char appendBuf[MaxPath + 64]; int appendLen = sprintf_s(appendBuf, "%s|%.3fs\n", stepName, elapsedSeconds); if (appendLen > 0) { FileContent existing = ReadEntireFile("Intermediate\\step_timings.tmp"); DWORD newSize = static_cast(appendLen) + existing.Size; char* combined = static_cast(HeapAlloc(GetProcessHeap(), 0, newSize + 1)); if (combined != nullptr) { DWORD offset = 0; if (existing.Data != nullptr && existing.Size > 0) { memcpy(combined, existing.Data, existing.Size); offset = existing.Size; } memcpy(combined + offset, appendBuf, static_cast(appendLen)); combined[newSize] = '\0'; WriteEntireFile("Intermediate\\step_timings.tmp", combined, newSize); HeapFree(GetProcessHeap(), 0, combined); } FreeFileContent(existing); } return 0; } static int CommandFinishBuild() { // Compute elapsed time const char* elapsedStr = "0.000s"; char elapsedBuf[64] = {}; if (FileExists("Intermediate\\build_start.tmp")) { FileContent startContent = ReadEntireFile("Intermediate\\build_start.tmp"); if (startContent.Data != nullptr) { uint64_t startTicks = 0; sscanf_s(startContent.Data, "%llu", &startTicks); FreeFileContent(startContent); FILETIME ftNow; GetSystemTimeAsFileTime(&ftNow); ULARGE_INTEGER nowLi; nowLi.LowPart = ftNow.dwLowDateTime; nowLi.HighPart = ftNow.dwHighDateTime; double elapsedSeconds = static_cast(nowLi.QuadPart - startTicks) / 10000000.0; if (elapsedSeconds < 60.0) { sprintf_s(elapsedBuf, "%.3fs", elapsedSeconds); } else { int totalMs = static_cast(elapsedSeconds * 1000.0); int hours = totalMs / 3600000; int minutes = (totalMs % 3600000) / 60000; int seconds = (totalMs % 60000) / 1000; int ms = totalMs % 1000; sprintf_s(elapsedBuf, "%02d:%02d:%02d.%03d", hours, minutes, seconds, ms); } elapsedStr = elapsedBuf; } DeleteFileA("Intermediate\\build_start.tmp"); } if (FileExists("Intermediate\\step_timings.tmp")) { FileContent timingsContent = ReadEntireFile("Intermediate\\step_timings.tmp"); if (timingsContent.Data != nullptr && timingsContent.Size > 0) { printf("Step Timings:\n"); const char* pos = timingsContent.Data; while (*pos != '\0') { const char* lineStart = pos; while (*pos != '\0' && *pos != '\n' && *pos != '\r') { pos++; } int lineLen = static_cast(pos - lineStart); while (*pos == '\n' || *pos == '\r') { pos++; } if (lineLen > 0) { const char* pipePos = nullptr; for (const char* p = lineStart; p < lineStart + lineLen; p++) { if (*p == '|') { pipePos = p; break; } } if (pipePos != nullptr) { char stepName[MaxPath] = {}; int nameLen = static_cast(pipePos - lineStart); if (nameLen < MaxPath) { memcpy(stepName, lineStart, static_cast(nameLen)); stepName[nameLen] = '\0'; } char durationStr[64] = {}; int durLen = static_cast((lineStart + lineLen) - (pipePos + 1)); if (durLen < 64) { memcpy(durationStr, pipePos + 1, static_cast(durLen)); durationStr[durLen] = '\0'; } printf(" - %-42s : %s\n", stepName, durationStr); } } } printf("------------------------------------------------------------------------------\n"); FreeFileContent(timingsContent); } DeleteFileA("Intermediate\\step_timings.tmp"); } printf("Total Duration : %s\n", elapsedStr); printf("Output Binaries:\n"); if (FileExists("Intermediate\\built_outputs.tmp")) { FileContent outputsContent = ReadEntireFile("Intermediate\\built_outputs.tmp"); bool anyPrinted = false; if (outputsContent.Data != nullptr) { const char* pos = outputsContent.Data; while (*pos != '\0') { const char* lineStart = pos; while (*pos != '\0' && *pos != '\n' && *pos != '\r') { pos++; } int lineLen = static_cast(pos - lineStart); while (*pos == '\n' || *pos == '\r') { pos++; } if (lineLen > 0) { char filePath[MaxPath]; if (lineLen < MaxPath) { memcpy(filePath, lineStart, static_cast(lineLen)); filePath[lineLen] = '\0'; if (FileExists(filePath)) { WIN32_FILE_ATTRIBUTE_DATA fileData; if (GetFileAttributesExA(filePath, GetFileExInfoStandard, &fileData)) { ULARGE_INTEGER fileSize; fileSize.LowPart = fileData.nFileSizeLow; fileSize.HighPart = fileData.nFileSizeHigh; double sizeMB = static_cast(fileSize.QuadPart) / (1024.0 * 1024.0); printf(" - %s (%.2f MB)\n", filePath, sizeMB); anyPrinted = true; } } } } } FreeFileContent(outputsContent); } if (!anyPrinted) { printf(" - None built in this session (all requested targets up-to-date)\n"); } DeleteFileA("Intermediate\\built_outputs.tmp"); } else { printf(" - None built in this session (all requested targets up-to-date)\n"); } fflush(stdout); return 0; } static int CommandEvaluate(int argc, char* argv[]) { LARGE_INTEGER perfStart, perfEnd, perfFreq; QueryPerformanceCounter(&perfStart); QueryPerformanceFrequency(&perfFreq); const char* cfg = (argc > 2) ? argv[2] : "Debug"; bool targetJuliet = (argc > 3) && argv[3][0] == '1'; bool targetGame = (argc > 4) && argv[4][0] == '1'; bool targetRomeo = (argc > 5) && argv[5][0] == '1'; bool targetShader = (argc > 6) && argv[6][0] == '1'; EnsureDirectoryExists("Intermediate"); // 1. Process unity files: clean #pragma message, compute hashes, detect changes HashCache oldCache; LoadHashCache("Intermediate\\.unity_hashes_cache", oldCache); HashCache newCache; bool unityChanged = false; FilePathList unityFiles; CollectUnityFiles("Intermediate", unityFiles); if (unityFiles.Count == 0) { unityChanged = true; } else { for (int i = 0; i < unityFiles.Count; i++) { CleanResult cr = CleanAndHashUnityFile(unityFiles.Paths[i].Data); newCache.Add(unityFiles.Paths[i].Data, cr.HashStr); const char* oldHash = oldCache.Find(unityFiles.Paths[i].Data); if (oldHash == nullptr || strcmp(oldHash, cr.HashStr) != 0) { unityChanged = true; } } } SaveHashCache("Intermediate\\.unity_hashes_cache", newCache); // 2. Scan source directory modification times once int64_t julietTime = GetNewestSourceTimeRecursive("Juliet"); int64_t gameTime = GetNewestSourceTimeRecursive("Game"); int64_t imguiTime = GetNewestSourceTimeRecursive("External\\imgui"); int64_t appTime = GetNewestSourceTimeRecursive("JulietApp"); int64_t romeoTime = GetNewestSourceTimeRecursive("Romeo"); int64_t shaderTime = GetNewestSourceTimeRecursive("JulietShaderCompiler"); auto MaxTime = [](int64_t a, int64_t b) -> int64_t { return (a > b) ? a : b; }; int64_t julietCombined = MaxTime(julietTime, imguiTime); int64_t gameCombined = MaxTime(MaxTime(julietTime, gameTime), imguiTime); int64_t appCombined = MaxTime(MaxTime(MaxTime(julietTime, gameTime), appTime), imguiTime); int64_t romeoCombined = MaxTime(MaxTime(julietTime, romeoTime), imguiTime); int64_t shaderCombined = MaxTime(MaxTime(julietTime, shaderTime), imguiTime); // Build paths for target binaries char binDir[MaxPath]; char intDir[MaxPath]; sprintf_s(binDir, "bin\\x64-%s", cfg); sprintf_s(intDir, "Intermediate\\x64-%s", cfg); auto IsUpToDate = [](const char* targetPath, int64_t newestSourceTime) -> bool { assert(targetPath != nullptr); if (!FileExists(targetPath)) { return false; } return GetFileModTimeInt64(targetPath) >= newestSourceTime; }; char path[MaxPath]; sprintf_s(path, "%s\\Juliet_Unity1.obj", intDir); bool julietNeed = unityChanged || !IsUpToDate(path, julietCombined); sprintf_s(path, "%s\\ImGui_Unity1.obj", intDir); bool imguiNeed = unityChanged || !IsUpToDate(path, imguiTime); bool gameNeed = false; if (targetJuliet || targetGame) { sprintf_s(path, "%s\\Game.dll", binDir); gameNeed = julietNeed || unityChanged || !IsUpToDate(path, gameCombined); } bool julietAppNeed = false; if (targetJuliet) { sprintf_s(path, "%s\\JulietApp.exe", binDir); julietAppNeed = gameNeed || unityChanged || !IsUpToDate(path, appCombined); } bool romeoNeed = false; if (targetRomeo) { sprintf_s(path, "%s\\Romeo.exe", binDir); romeoNeed = julietNeed || unityChanged || !IsUpToDate(path, romeoCombined); } bool shaderNeed = false; if (targetShader && DirectoryExists("Intermediate\\JulietShaderCompiler")) { sprintf_s(path, "%s\\JulietShaderCompiler.exe", binDir); shaderNeed = julietNeed || unityChanged || !IsUpToDate(path, shaderCombined); } QueryPerformanceCounter(&perfEnd); double durationMs = static_cast(perfEnd.QuadPart - perfStart.QuadPart) * 1000.0 / static_cast(perfFreq.QuadPart); printf("[PERF] Fast Native C++ EvaluateConfig: %.1f ms\n", durationMs); // Write results char statusBuf[512]; int statusLen = sprintf_s(statusBuf, "FASTBUILD_UNITY_CHANGED=%d\n" "JULIET_NEED_COMPILE=%d\n" "IMGUI_NEED_COMPILE=%d\n" "GAME_NEED_COMPILE=%d\n" "JULIETAPP_NEED_COMPILE=%d\n" "ROMEO_NEED_COMPILE=%d\n" "SHADER_NEED_COMPILE=%d\n", unityChanged ? 1 : 0, julietNeed ? 1 : 0, imguiNeed ? 1 : 0, gameNeed ? 1 : 0, julietAppNeed ? 1 : 0, romeoNeed ? 1 : 0, shaderNeed ? 1 : 0); WriteEntireFile("Intermediate\\config_status.tmp", statusBuf, static_cast(statusLen)); fflush(stdout); return 0; } // ============================================================================ // Main entry point // ============================================================================ int main(int argc, char* argv[]) { if (argc < 2) { printf("Usage: build_check [args...]\n"); printf("Commands:\n"); printf(" start_build Record build start timestamp\n"); printf(" start_step Record start timestamp of a build step\n"); printf(" end_step [] Record duration of current step\n"); printf(" finish_build Print build summary (elapsed time, step timings, built binaries)\n"); printf(" evaluate Evaluate rebuild needs\n"); printf(" check_alive Returns 0 immediately to test execution\n"); return 1; } const char* cmd = argv[1]; if (strcmp(cmd, "check_alive") == 0) return 0; if (strcmp(cmd, "start_build") == 0) return CommandStartBuild(); if (strcmp(cmd, "start_step") == 0) return CommandStartStep(argc, argv); if (strcmp(cmd, "end_step") == 0) return CommandEndStep(argc, argv); if (strcmp(cmd, "finish_build")== 0) return CommandFinishBuild(); if (strcmp(cmd, "evaluate") == 0) return CommandEvaluate(argc, argv); printf("[ERROR] Unknown command: %s\n", cmd); return 1; }