From 9dbe56d193fe768d3eae5b8ecfbf9f9aaeb72a59 Mon Sep 17 00:00:00 2001 From: jacob Date: Mon, 2 Mar 2026 16:59:30 -0800 Subject: [PATCH] better feedback for missing tools on meta build. pull IsWindowArranged dynamically. --- src/base/base_string.c | 5 +++++ src/base/base_win32/base_win32.c | 30 ++++++++++++++++---------- src/base/base_win32/base_win32.h | 22 +++++++++++++++++++ src/meta/meta.c | 29 +++++++++++++++++++------ src/window/window_win32/window_win32.c | 2 +- 5 files changed, 70 insertions(+), 18 deletions(-) diff --git a/src/base/base_string.c b/src/base/base_string.c index 3b127edc..7ad045f4 100644 --- a/src/base/base_string.c +++ b/src/base/base_string.c @@ -295,6 +295,11 @@ StringArray SplitString(Arena *arena, String str, String delim) *PushStructNoZero(arena, String) = piece; ++pieces.count; } + else if (pieces.count == 0) + { + *PushStructNoZero(arena, String) = str; + ++pieces.count; + } return pieces; } diff --git a/src/base/base_win32/base_win32.c b/src/base/base_win32/base_win32.c index 0a19f95e..1b0bd529 100644 --- a/src/base/base_win32/base_win32.c +++ b/src/base/base_win32/base_win32.c @@ -435,6 +435,20 @@ i32 W32_Main(void) W32.timer_start_qpc = qpc.QuadPart; } + // Load module funcs + { + W32.api.module.ntdll = GetModuleHandleW(L"ntdll.dll"); + W32.api.module.user32 = GetModuleHandleW(L"user32.dll"); + if (W32.api.module.ntdll) + { + W32.api.func.wine_get_version = (W32_WineVersionFunc *)GetProcAddress(W32.api.module.ntdll, "wine_get_version"); + } + if (W32.api.module.user32) + { + W32.api.func.IsWindowArranged = (W32_IsWindowArrangedFunc *)GetProcAddress(W32.api.module.user32, "IsWindowArranged"); + } + } + // Setup events W32.panic_event = CreateEventW(0, 1, 0, 0); W32.exit_event = CreateEventW(0, 1, 0, 0); @@ -468,20 +482,14 @@ i32 W32_Main(void) W32.raw_command_line = args_list; } - // Detect wine + // Get wine version { - HMODULE ntdll = GetModuleHandleW(L"ntdll.dll"); - if (ntdll) + if (W32.api.func.wine_get_version) { - typedef char *W32_WineVersionFunc(void); - W32_WineVersionFunc *wine_version_func = (W32_WineVersionFunc *)GetProcAddress(ntdll, "wine_get_version"); - if (wine_version_func) + char *wine_version_cstr = W32.api.func.wine_get_version(); + if (wine_version_cstr) { - char *wine_version_cstr = wine_version_func(); - if (wine_version_cstr) - { - W32.wine_version = PushString(perm, StringFromCstrNoLimit(wine_version_cstr)); - } + W32.wine_version = PushString(perm, StringFromCstrNoLimit(wine_version_cstr)); } } } diff --git a/src/base/base_win32/base_win32.h b/src/base/base_win32/base_win32.h index c5fe0e49..a7042056 100644 --- a/src/base/base_win32/base_win32.h +++ b/src/base/base_win32/base_win32.h @@ -58,11 +58,33 @@ Struct(W32_FindEmbeddedDataCtx) String embedded_strings[64]; }; +//////////////////////////////////////////////////////////// +//~ API types + +typedef char *W32_WineVersionFunc(void); +typedef BOOL W32_IsWindowArrangedFunc(HWND hwnd); + +Struct(W32_Api) +{ + struct + { + HMODULE ntdll; + HMODULE user32; + } module; + + struct + { + W32_WineVersionFunc *wine_get_version; + W32_IsWindowArrangedFunc *IsWindowArranged; + } func; +}; + //////////////////////////////////////////////////////////// //~ State types Struct(W32_Ctx) { + W32_Api api; SYSTEM_INFO info; u32 main_thread_id; String wine_version; diff --git a/src/meta/meta.c b/src/meta/meta.c index cca8fead..2cbae886 100644 --- a/src/meta/meta.c +++ b/src/meta/meta.c @@ -185,13 +185,12 @@ M_EmbedObj M_Embed(String store_name, String dir_path) // Write name BB_WriteAlignBytes(&bbw, 64); - u64 name_start = BB_GetNumBytesWritten(&bbw) + 1; - BB_WriteString(&bbw, en->entry_name); + u64 name_start = BB_GetNumBytesWritten(&bbw); + BB_WriteBytes(&bbw, en->entry_name); u64 name_len = BB_GetNumBytesWritten(&bbw) - name_start; // Write data BB_WriteAlignBytes(&bbw, 64); - // FIXME: Why no +1 here? u64 data_start = BB_GetNumBytesWritten(&bbw); BB_WriteBytes(&bbw, file_data); u64 data_len = BB_GetNumBytesWritten(&bbw) - data_start; @@ -235,8 +234,12 @@ M_EmbedObj M_Embed(String store_name, String dir_path) String cmd = StringF(perm, "rc.exe -nologo -fo %F %F", FmtString(result.obj_file), FmtString(F_GetFull(perm, rc_out_file))); OS_CommandResult cmd_result = OS_RunCommand(perm, cmd); String cmd_output = TrimWhitespace(cmd_result.output); - result.output = cmd_output; result.return_code = cmd_result.code; + result.output = cmd_output; + if (MatchString(result.output, Lit("The system cannot find the file specified."))) + { + result.output = StringF(perm, "%F not found", FmtString(SplitString(perm, cmd, Lit(" ")).strings[0])); + } } M_SetBuildStatus(result.return_code); @@ -997,6 +1000,10 @@ void M_BuildEntryPoint(WaveLaneCtx *lane) String cmd_output = TrimWhitespace(cmd_result.output); M.c_obj.output = cmd_output; M.c_obj.return_code = cmd_result.code; + if (MatchString(cmd_output, Lit("The system cannot find the file specified."))) + { + M.c_obj.output = StringF(perm, "%F not found", FmtString(SplitString(perm, cmd, Lit(" ")).strings[0])); + } // Ignore MSVC file-name echo if (MatchString(TrimWhitespace(M.c_obj.output), F_GetFileName(c_out_file))) @@ -1023,7 +1030,7 @@ void M_BuildEntryPoint(WaveLaneCtx *lane) e->kind == ShaderEntryKind_PS ? Lit("ps_6_6") : Lit("cs_6_6") ); - String compile_cmd = StringF( + String cmd = StringF( perm, "dxc.exe -T %F -E %F -Fo %F %F %F %F %F", FmtString(target), @@ -1035,10 +1042,14 @@ void M_BuildEntryPoint(WaveLaneCtx *lane) FmtString(StringFromList(perm, cp.warnings_dxc, Lit(" "))) ); - OS_CommandResult cmd_result = OS_RunCommand(perm, compile_cmd); + OS_CommandResult cmd_result = OS_RunCommand(perm, cmd); gpu_obj->name = shader_name; gpu_obj->output = cmd_result.output; gpu_obj->return_code = cmd_result.code; + if (MatchString(gpu_obj->output, Lit("The system cannot find the file specified."))) + { + gpu_obj->output = StringF(perm, "%F not found", FmtString(SplitString(perm, cmd, Lit(" ")).strings[0])); + } M_SetBuildStatus(gpu_obj->return_code); @@ -1128,6 +1139,11 @@ void M_BuildEntryPoint(WaveLaneCtx *lane) OS_CommandResult result = OS_RunCommand(perm, cmd); M.link.output = TrimWhitespace(result.output); M.link.return_code = result.code; + if (MatchString(M.link.output, Lit("The system cannot find the file specified."))) + { + M.link.output = StringF(perm, "%F not found", FmtString(SplitString(perm, cmd, Lit(" ")).strings[0])); + } + i64 link_elapsed_ns = TimeNs() - start_ns; // M_EchoLine(StringF(perm, ">>>>> Linked in %Fs", FmtFloat(SecondsFromNs(link_elapsed_ns)))); @@ -1195,6 +1211,7 @@ void M_BuildEntryPoint(WaveLaneCtx *lane) } } } + String embed_obj_output = Zi; { StringList embed_obj_outputs = Zi; diff --git a/src/window/window_win32/window_win32.c b/src/window/window_win32/window_win32.c index b25c2537..c9e8d952 100644 --- a/src/window/window_win32/window_win32.c +++ b/src/window/window_win32/window_win32.c @@ -573,7 +573,7 @@ WND_Frame WND_BeginFrame(G_Format backbuffer_format, WND_BackbufferSizeMode back restore.is_fullscreen = window->is_fullscreen; restore.fullscreen_restore_rect = window->fullscreen_restore_rect; restore.has_focus = result.has_focus; - if (IsWindowArranged(hwnd)) + if (W32.api.func.IsWindowArranged && W32.api.func.IsWindowArranged(hwnd)) { restore.is_snapped = 1; restore.snapped_screen_rect = screen_rect;