aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-09-07 11:22:43 +0100
committergingerBill <bill@gingerbill.org>2022-09-07 11:22:43 +0100
commitaf76d267717bc3b504a53ac7445e2c82b228600a (patch)
treef23060cee7644b5c1c72a494901ed477c620c706
parentd2097e9fdddb19ad71ef56219c22fd0eecb0c65e (diff)
Simplify win32 resource file linking
-rw-r--r--build.bat8
-rw-r--r--src/main.cpp53
2 files changed, 25 insertions, 36 deletions
diff --git a/build.bat b/build.bat
index 06bc6c823..e08bfc04b 100644
--- a/build.bat
+++ b/build.bat
@@ -72,10 +72,12 @@ del *.ilk > NUL 2> NUL
cl %compiler_settings% "src\main.cpp" "src\libtommath.cpp" /link %linker_settings% -OUT:%exe_name%
if %errorlevel% neq 0 goto end_of_build
-call build_vendor.bat
-if %errorlevel% neq 0 goto end_of_build
+rem call build_vendor.bat
+rem if %errorlevel% neq 0 goto end_of_build
-if %release_mode% EQU 0 odin run examples/demo
+odin run examples/demo -vet -strict-style
+rem odin check examples/all
+rem odin run examples/bug
del *.obj > NUL 2> NUL
diff --git a/src/main.cpp b/src/main.cpp
index 103b0a81b..a1daa51d1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -288,11 +288,15 @@ i32 linker_stage(lbGenerator *gen) {
char const *subsystem_str = build_context.use_subsystem_windows ? "WINDOWS" : "CONSOLE";
if (!build_context.use_lld) { // msvc
+ String res_path = {};
+ defer (gb_free(heap_allocator(), res_path.text));
if (build_context.has_resource) {
+ String temp_res_path = path_to_string(heap_allocator(), build_context.build_paths[BuildPath_RES]);
+ res_path = concatenate3_strings(heap_allocator(), str_lit("\""), temp_res_path, str_lit("\""));
+ gb_free(heap_allocator(), temp_res_path.text);
+
String rc_path = path_to_string(heap_allocator(), build_context.build_paths[BuildPath_RC]);
- String res_path = path_to_string(heap_allocator(), build_context.build_paths[BuildPath_RES]);
defer (gb_free(heap_allocator(), rc_path.text));
- defer (gb_free(heap_allocator(), res_path.text));
result = system_exec_command_line_app("msvc-link",
"\"%.*src.exe\" /nologo /fo \"%.*s\" \"%.*s\"",
@@ -304,42 +308,25 @@ i32 linker_stage(lbGenerator *gen) {
if (result) {
return result;
}
-
- result = system_exec_command_line_app("msvc-link",
- "\"%.*slink.exe\" %s \"%.*s\" -OUT:\"%.*s\" %s "
- "/nologo /incremental:no /opt:ref /subsystem:%s "
- " %.*s "
- " %.*s "
- " %s "
- "",
- LIT(vs_exe_path), object_files, LIT(res_path), LIT(output_filename),
- link_settings,
- subsystem_str,
- LIT(build_context.link_flags),
- LIT(build_context.extra_linker_flags),
- lib_str
- );
- } else {
- result = system_exec_command_line_app("msvc-link",
- "\"%.*slink.exe\" %s -OUT:\"%.*s\" %s "
- "/nologo /incremental:no /opt:ref /subsystem:%s "
- " %.*s "
- " %.*s "
- " %s "
- "",
- LIT(vs_exe_path), object_files, LIT(output_filename),
- link_settings,
- subsystem_str,
- LIT(build_context.link_flags),
- LIT(build_context.extra_linker_flags),
- lib_str
- );
}
+ result = system_exec_command_line_app("msvc-link",
+ "\"%.*slink.exe\" %s %.*s -OUT:\"%.*s\" %s "
+ "/nologo /incremental:no /opt:ref /subsystem:%s "
+ " %.*s "
+ " %.*s "
+ " %s "
+ "",
+ LIT(vs_exe_path), object_files, LIT(res_path), LIT(output_filename),
+ link_settings,
+ subsystem_str,
+ LIT(build_context.link_flags),
+ LIT(build_context.extra_linker_flags),
+ lib_str
+ );
if (result) {
return result;
}
-
} else { // lld
result = system_exec_command_line_app("msvc-lld-link",
"\"%.*s\\bin\\lld-link\" %s -OUT:\"%.*s\" %s "