instead of searching for manifest tool manually punt the job to CreateProcess

This commit is contained in:
Nikita Smith
2024-11-18 15:28:02 -08:00
parent 938be0aa84
commit e44dd3aa07
3 changed files with 10 additions and 27 deletions
-1
View File
@@ -324,7 +324,6 @@ lnk_merge_manifest_files(String8 mt_path, String8 out_name, String8List manifest
// launch mt.exe with our command line
OS_ProcessLaunchParams launch_opts = {0};
launch_opts.cmd_line = cmd_line;
launch_opts.path = str8_chop_last_slash(mt_path);
launch_opts.inherit_env = 1;
launch_opts.consoleless = 1;
OS_Handle mt_handle = os_process_launch(&launch_opts);
+2 -25
View File
@@ -136,7 +136,7 @@ read_only struct
{ LNK_CmdSwitch_Rad_LargePages, "RAD_LARGE_PAGES", "[:NO]", "Disabled by default on Windows." },
{ LNK_CmdSwitch_Rad_LinkVer, "RAD_LINK_VER", ":##,##", "" },
{ LNK_CmdSwitch_Rad_Log, "RAD_LOG", ":{ALL,INPUT_OBJ,INPUT_LIB,IO,LINK_STATS,TIMERS}", "" },
{ LNK_CmdSwitch_Rad_MtPath, "RAD_MT_PATH", ":EXEPATH", "Path to manifest tool." },
{ LNK_CmdSwitch_Rad_MtPath, "RAD_MT_PATH", ":EXEPATH", "Exe path to manifest tool, default: " LNK_MANIFEST_MERGE_TOOL_NAME },
{ LNK_CmdSwitch_Rad_OsVer, "RAD_OS_VER", ":##,##", "" },
{ LNK_CmdSwitch_Rad_PageSize, "RAD_PAGE_SIZE", ":#", "Must be power of two." },
{ LNK_CmdSwitch_Rad_PathStyle, "RAD_PATH_STYLE", ":{WindowsAbsolute|UnixAbsolute}", "" },
@@ -491,28 +491,6 @@ lnk_get_min_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType ma
return ver;
}
internal String8
lnk_get_mt_path(Arena *arena)
{
#if OS_WINDOWS
#undef OS_WINDOWS
#pragma comment(lib, "shlwapi.lib")
#include <shlwapi.h>
local_persist wchar_t raw_mt_path[MAX_PATH*2] = L"mt.exe";
PathFindOnPathW(&raw_mt_path[0], 0);
String16 mt_path_16 = str16_cstring_capped(&raw_mt_path[0], raw_mt_path + sizeof(raw_mt_path));
String8 mt_path = str8_from_16(arena, mt_path_16);
mt_path = path_convert_slashes(arena, mt_path, PathStyle_WindowsAbsolute);
#undef OS_WINDOWS
#define OS_WINDOWS 1
#else
String8 mt_path = str8_lit("llvm-mt.exe");
#endif
return mt_path;
}
internal B32
lnk_do_debug_info(LNK_Config *config)
{
@@ -936,8 +914,7 @@ lnk_config_from_cmd_line(Arena *arena, String8List raw_cmd_line)
#endif
if (!lnk_cmd_line_has_switch(cmd_line, LNK_CmdSwitch_Rad_MtPath)) {
String8 mt_path = lnk_get_mt_path(scratch.arena);
lnk_cmd_line_push_option_if_not_presentf(scratch.arena, &cmd_line, LNK_CmdSwitch_Rad_MtPath, "%S", mt_path);
lnk_cmd_line_push_option_if_not_presentf(scratch.arena, &cmd_line, LNK_CmdSwitch_Rad_MtPath, "%s", LNK_MANIFEST_MERGE_TOOL_NAME);
}
LNK_Config *config = push_array(arena, LNK_Config, 1);
+8 -1
View File
@@ -235,6 +235,14 @@ typedef enum
LNK_TypeNameHashMode_Full,
} LNK_TypeNameHashMode;
#if OS_WINDOWS
# define LNK_MANIFEST_MERGE_TOOL_NAME "mt.exe"
#elif OS_LINUX || OS_MAC
# define LNK_MANIFEST_MERGE_TOOL_NAME "llvm-mt"
#else
# error
#endif
typedef struct LNK_Config
{
LNK_ConfigFlags flags;
@@ -473,7 +481,6 @@ internal void lnk_error_cmd_switch_invalid_param(LNK_ErrorCode code, LNK_CmdSwit
internal U64 lnk_get_base_addr(LNK_Config *config);
internal Version lnk_get_default_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType machine);
internal Version lnk_get_min_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType machine);
internal String8 lnk_get_mt_path(Arena *arena);
internal B32 lnk_do_debug_info(LNK_Config *config);