Browse Source

Simplify win32 resource file linking

gingerBill 2 years ago
parent
commit
af76d26771
2 changed files with 25 additions and 36 deletions
  1. 5 3
      build.bat
  2. 20 33
      src/main.cpp

+ 5 - 3
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%
 cl %compiler_settings% "src\main.cpp" "src\libtommath.cpp" /link %linker_settings% -OUT:%exe_name%
 if %errorlevel% neq 0 goto end_of_build
 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
 del *.obj > NUL 2> NUL
 
 

+ 20 - 33
src/main.cpp

@@ -288,11 +288,15 @@ i32 linker_stage(lbGenerator *gen) {
 
 
 			char const *subsystem_str = build_context.use_subsystem_windows ? "WINDOWS" : "CONSOLE";
 			char const *subsystem_str = build_context.use_subsystem_windows ? "WINDOWS" : "CONSOLE";
 			if (!build_context.use_lld) { // msvc
 			if (!build_context.use_lld) { // msvc
+				String res_path = {};
+				defer (gb_free(heap_allocator(), res_path.text));
 				if (build_context.has_resource) {
 				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 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(), rc_path.text));
-					defer (gb_free(heap_allocator(), res_path.text));
 
 
 					result = system_exec_command_line_app("msvc-link",
 					result = system_exec_command_line_app("msvc-link",
 						"\"%.*src.exe\" /nologo /fo \"%.*s\" \"%.*s\"",
 						"\"%.*src.exe\" /nologo /fo \"%.*s\" \"%.*s\"",
@@ -304,42 +308,25 @@ i32 linker_stage(lbGenerator *gen) {
 					if (result) {
 					if (result) {
 						return 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) {
 				if (result) {
 					return result;
 					return result;
 				}
 				}
-
 			} else { // lld
 			} else { // lld
 				result = system_exec_command_line_app("msvc-lld-link",
 				result = system_exec_command_line_app("msvc-lld-link",
 					"\"%.*s\\bin\\lld-link\" %s -OUT:\"%.*s\" %s "
 					"\"%.*s\\bin\\lld-link\" %s -OUT:\"%.*s\" %s "