mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Allow using precompiled .res file.
This commit is contained in:
@@ -1805,10 +1805,11 @@ gb_internal bool init_build_paths(String init_filename) {
|
|||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
if (bc->metrics.os == TargetOs_windows) {
|
if (bc->metrics.os == TargetOs_windows) {
|
||||||
if (bc->resource_filepath.len > 0) {
|
if (bc->resource_filepath.len > 0) {
|
||||||
bc->build_paths[BuildPath_RC] = path_from_string(ha, bc->resource_filepath);
|
bc->build_paths[BuildPath_RES] = path_from_string(ha, bc->resource_filepath);
|
||||||
bc->build_paths[BuildPath_RES] = path_from_string(ha, bc->resource_filepath);
|
if (!string_ends_with(bc->resource_filepath, str_lit(".res"))) {
|
||||||
bc->build_paths[BuildPath_RC].ext = copy_string(ha, STR_LIT("rc"));
|
bc->build_paths[BuildPath_RC] = path_from_string(ha, bc->resource_filepath);
|
||||||
bc->build_paths[BuildPath_RES].ext = copy_string(ha, STR_LIT("res"));
|
bc->build_paths[BuildPath_RC].ext = copy_string(ha, STR_LIT("rc"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bc->pdb_filepath.len > 0) {
|
if (bc->pdb_filepath.len > 0) {
|
||||||
|
|||||||
+23
-18
@@ -305,30 +305,35 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
|||||||
defer (gb_free(heap_allocator(), windows_sdk_bin_path.text));
|
defer (gb_free(heap_allocator(), windows_sdk_bin_path.text));
|
||||||
|
|
||||||
if (!build_context.use_lld) { // msvc
|
if (!build_context.use_lld) { // msvc
|
||||||
String res_path = {};
|
String temp_res_path = path_to_string(heap_allocator(), build_context.build_paths[BuildPath_RES]);
|
||||||
|
String temp_rc_path = path_to_string(heap_allocator(), build_context.build_paths[BuildPath_RC]);
|
||||||
|
defer (gb_free(heap_allocator(), temp_res_path.text));
|
||||||
|
defer (gb_free(heap_allocator(), temp_rc_path.text));
|
||||||
|
|
||||||
|
String res_path = concatenate3_strings(heap_allocator(), str_lit("\""), temp_res_path, str_lit("\""));
|
||||||
|
String rc_path = concatenate3_strings(heap_allocator(), str_lit("\""), temp_rc_path, str_lit("\""));
|
||||||
defer (gb_free(heap_allocator(), res_path.text));
|
defer (gb_free(heap_allocator(), res_path.text));
|
||||||
|
defer (gb_free(heap_allocator(), rc_path.text));
|
||||||
|
|
||||||
// TODO(Jeroen): Add ability to reuse .res file instead of recompiling, if `-resource:file.res` is given.
|
|
||||||
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]);
|
if (temp_rc_path == "") {
|
||||||
res_path = concatenate3_strings(heap_allocator(), str_lit("\""), temp_res_path, str_lit("\""));
|
debugf("Using precompiled resource %.*s\n", LIT(res_path));
|
||||||
gb_free(heap_allocator(), temp_res_path.text);
|
} else {
|
||||||
|
debugf("Compiling resource %.*s\n", LIT(res_path));
|
||||||
|
|
||||||
String temp_rc_path = path_to_string(heap_allocator(), build_context.build_paths[BuildPath_RC]);
|
result = system_exec_command_line_app("msvc-link",
|
||||||
String rc_path = concatenate3_strings(heap_allocator(), str_lit("\""), temp_rc_path, str_lit("\""));
|
"\"%.*src.exe\" /nologo /fo %.*s %.*s",
|
||||||
gb_free(heap_allocator(), temp_rc_path.text);
|
LIT(windows_sdk_bin_path),
|
||||||
defer (gb_free(heap_allocator(), rc_path.text));
|
LIT(res_path),
|
||||||
|
LIT(rc_path)
|
||||||
|
);
|
||||||
|
|
||||||
result = system_exec_command_line_app("msvc-link",
|
if (result) {
|
||||||
"\"%.*src.exe\" /nologo /fo %.*s %.*s",
|
return result;
|
||||||
LIT(windows_sdk_bin_path),
|
}
|
||||||
LIT(res_path),
|
|
||||||
LIT(rc_path)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
res_path = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
String linker_name = str_lit("link.exe");
|
String linker_name = str_lit("link.exe");
|
||||||
|
|||||||
+4
-2
@@ -1452,8 +1452,9 @@ gb_internal bool parse_build_flags(Array<String> args) {
|
|||||||
String path = value.value_string;
|
String path = value.value_string;
|
||||||
path = string_trim_whitespace(path);
|
path = string_trim_whitespace(path);
|
||||||
if (is_build_flag_path_valid(path)) {
|
if (is_build_flag_path_valid(path)) {
|
||||||
if(!string_ends_with(path, str_lit(".rc"))) {
|
bool is_resource = string_ends_with(path, str_lit(".rc")) || string_ends_with(path, str_lit(".res"));
|
||||||
gb_printf_err("Invalid -resource path %.*s, missing .rc\n", LIT(path));
|
if(!is_resource) {
|
||||||
|
gb_printf_err("Invalid -resource path %.*s, missing .rc or .res file\n", LIT(path));
|
||||||
bad_flags = true;
|
bad_flags = true;
|
||||||
break;
|
break;
|
||||||
} else if (!gb_file_exists((const char *)path.text)) {
|
} else if (!gb_file_exists((const char *)path.text)) {
|
||||||
@@ -2552,6 +2553,7 @@ gb_internal void print_show_help(String const arg0, String const &command) {
|
|||||||
print_usage_line(2, "[Windows only]");
|
print_usage_line(2, "[Windows only]");
|
||||||
print_usage_line(2, "Defines the resource file for the executable.");
|
print_usage_line(2, "Defines the resource file for the executable.");
|
||||||
print_usage_line(2, "Example: -resource:path/to/file.rc");
|
print_usage_line(2, "Example: -resource:path/to/file.rc");
|
||||||
|
print_usage_line(2, "or: -resource:path/to/file.res for a precompiled one.");
|
||||||
print_usage_line(0, "");
|
print_usage_line(0, "");
|
||||||
|
|
||||||
print_usage_line(1, "-pdb-name:<filepath>");
|
print_usage_line(1, "-pdb-name:<filepath>");
|
||||||
|
|||||||
Reference in New Issue
Block a user