better feedback for missing tools on meta build. pull IsWindowArranged dynamically.

This commit is contained in:
jacob 2026-03-02 16:59:30 -08:00
parent 983d9f0040
commit 9dbe56d193
5 changed files with 70 additions and 18 deletions

View File

@ -295,6 +295,11 @@ StringArray SplitString(Arena *arena, String str, String delim)
*PushStructNoZero(arena, String) = piece; *PushStructNoZero(arena, String) = piece;
++pieces.count; ++pieces.count;
} }
else if (pieces.count == 0)
{
*PushStructNoZero(arena, String) = str;
++pieces.count;
}
return pieces; return pieces;
} }

View File

@ -435,6 +435,20 @@ i32 W32_Main(void)
W32.timer_start_qpc = qpc.QuadPart; 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 // Setup events
W32.panic_event = CreateEventW(0, 1, 0, 0); W32.panic_event = CreateEventW(0, 1, 0, 0);
W32.exit_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; W32.raw_command_line = args_list;
} }
// Detect wine // Get wine version
{ {
HMODULE ntdll = GetModuleHandleW(L"ntdll.dll"); if (W32.api.func.wine_get_version)
if (ntdll)
{ {
typedef char *W32_WineVersionFunc(void); char *wine_version_cstr = W32.api.func.wine_get_version();
W32_WineVersionFunc *wine_version_func = (W32_WineVersionFunc *)GetProcAddress(ntdll, "wine_get_version"); if (wine_version_cstr)
if (wine_version_func)
{ {
char *wine_version_cstr = wine_version_func(); W32.wine_version = PushString(perm, StringFromCstrNoLimit(wine_version_cstr));
if (wine_version_cstr)
{
W32.wine_version = PushString(perm, StringFromCstrNoLimit(wine_version_cstr));
}
} }
} }
} }

View File

@ -58,11 +58,33 @@ Struct(W32_FindEmbeddedDataCtx)
String embedded_strings[64]; 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 //~ State types
Struct(W32_Ctx) Struct(W32_Ctx)
{ {
W32_Api api;
SYSTEM_INFO info; SYSTEM_INFO info;
u32 main_thread_id; u32 main_thread_id;
String wine_version; String wine_version;

View File

@ -185,13 +185,12 @@ M_EmbedObj M_Embed(String store_name, String dir_path)
// Write name // Write name
BB_WriteAlignBytes(&bbw, 64); BB_WriteAlignBytes(&bbw, 64);
u64 name_start = BB_GetNumBytesWritten(&bbw) + 1; u64 name_start = BB_GetNumBytesWritten(&bbw);
BB_WriteString(&bbw, en->entry_name); BB_WriteBytes(&bbw, en->entry_name);
u64 name_len = BB_GetNumBytesWritten(&bbw) - name_start; u64 name_len = BB_GetNumBytesWritten(&bbw) - name_start;
// Write data // Write data
BB_WriteAlignBytes(&bbw, 64); BB_WriteAlignBytes(&bbw, 64);
// FIXME: Why no +1 here?
u64 data_start = BB_GetNumBytesWritten(&bbw); u64 data_start = BB_GetNumBytesWritten(&bbw);
BB_WriteBytes(&bbw, file_data); BB_WriteBytes(&bbw, file_data);
u64 data_len = BB_GetNumBytesWritten(&bbw) - data_start; 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))); 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); OS_CommandResult cmd_result = OS_RunCommand(perm, cmd);
String cmd_output = TrimWhitespace(cmd_result.output); String cmd_output = TrimWhitespace(cmd_result.output);
result.output = cmd_output;
result.return_code = cmd_result.code; 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); M_SetBuildStatus(result.return_code);
@ -997,6 +1000,10 @@ void M_BuildEntryPoint(WaveLaneCtx *lane)
String cmd_output = TrimWhitespace(cmd_result.output); String cmd_output = TrimWhitespace(cmd_result.output);
M.c_obj.output = cmd_output; M.c_obj.output = cmd_output;
M.c_obj.return_code = cmd_result.code; 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 // Ignore MSVC file-name echo
if (MatchString(TrimWhitespace(M.c_obj.output), F_GetFileName(c_out_file))) 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") : e->kind == ShaderEntryKind_PS ? Lit("ps_6_6") :
Lit("cs_6_6") Lit("cs_6_6")
); );
String compile_cmd = StringF( String cmd = StringF(
perm, perm,
"dxc.exe -T %F -E %F -Fo %F %F %F %F %F", "dxc.exe -T %F -E %F -Fo %F %F %F %F %F",
FmtString(target), FmtString(target),
@ -1035,10 +1042,14 @@ void M_BuildEntryPoint(WaveLaneCtx *lane)
FmtString(StringFromList(perm, cp.warnings_dxc, Lit(" "))) 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->name = shader_name;
gpu_obj->output = cmd_result.output; gpu_obj->output = cmd_result.output;
gpu_obj->return_code = cmd_result.code; 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); M_SetBuildStatus(gpu_obj->return_code);
@ -1128,6 +1139,11 @@ void M_BuildEntryPoint(WaveLaneCtx *lane)
OS_CommandResult result = OS_RunCommand(perm, cmd); OS_CommandResult result = OS_RunCommand(perm, cmd);
M.link.output = TrimWhitespace(result.output); M.link.output = TrimWhitespace(result.output);
M.link.return_code = result.code; 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; i64 link_elapsed_ns = TimeNs() - start_ns;
// M_EchoLine(StringF(perm, ">>>>> Linked in %Fs", FmtFloat(SecondsFromNs(link_elapsed_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; String embed_obj_output = Zi;
{ {
StringList embed_obj_outputs = Zi; StringList embed_obj_outputs = Zi;

View File

@ -573,7 +573,7 @@ WND_Frame WND_BeginFrame(G_Format backbuffer_format, WND_BackbufferSizeMode back
restore.is_fullscreen = window->is_fullscreen; restore.is_fullscreen = window->is_fullscreen;
restore.fullscreen_restore_rect = window->fullscreen_restore_rect; restore.fullscreen_restore_rect = window->fullscreen_restore_rect;
restore.has_focus = result.has_focus; restore.has_focus = result.has_focus;
if (IsWindowArranged(hwnd)) if (W32.api.func.IsWindowArranged && W32.api.func.IsWindowArranged(hwnd))
{ {
restore.is_snapped = 1; restore.is_snapped = 1;
restore.snapped_screen_rect = screen_rect; restore.snapped_screen_rect = screen_rect;