mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-05 09:00:08 +01:00
util/u_process: implement util_get_process_name for Windows
There's not yet any users of this function on Windows, but it prints a warning during builds, and seems easy enough to implement. So let's add a trivial implementation. Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7548>
This commit is contained in:
parent
d442a99238
commit
1a5400a9e9
2 changed files with 25 additions and 4 deletions
|
|
@ -52,10 +52,14 @@ expect_equal_str(const char *expected, const char *actual, const char *test)
|
|||
static void
|
||||
test_util_get_process_name (void)
|
||||
{
|
||||
#if !DETECT_OS_WINDOWS
|
||||
const char* name = util_get_process_name();
|
||||
expect_equal_str("process_test", name, "util_get_process_name");
|
||||
#endif
|
||||
#if DETECT_OS_WINDOWS
|
||||
const char *expected = "process_test.exe";
|
||||
#else
|
||||
const char *expected = "process_test";
|
||||
#endif
|
||||
|
||||
const char *name = util_get_process_name();
|
||||
expect_equal_str(expected, name, "util_get_process_name");
|
||||
}
|
||||
|
||||
/* This test gets the real path from Meson (BUILD_FULL_PATH env var),
|
||||
|
|
|
|||
|
|
@ -135,6 +135,23 @@ __getProgramName()
|
|||
}
|
||||
|
||||
# define GET_PROGRAM_NAME() __getProgramName()
|
||||
#elif defined(WIN32)
|
||||
static const char *
|
||||
__getProgramName()
|
||||
{
|
||||
static const char *progname;
|
||||
if (progname == NULL) {
|
||||
static char buf[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, buf, sizeof(buf));
|
||||
progname = strrchr(buf, '\\');
|
||||
if (progname)
|
||||
progname++;
|
||||
else
|
||||
progname = buf;
|
||||
}
|
||||
return progname;
|
||||
}
|
||||
# define GET_PROGRAM_NAME() __getProgramName()
|
||||
#endif
|
||||
|
||||
#if !defined(GET_PROGRAM_NAME)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue