| author | |
| committer | |
| log | b11170294052585ae81b9946d770f860d163da8f |
| tree | eb4b73867e878ca8706b73f27eafa21ea6ccaa98 |
| parent | 9684947faae674e093dda4c81d94f51b9568369e |
.res files are compiled Windows resource files that get linked into executables/libraries. The linker knows what to do with them, but previously you had to trick Zig into thinking it was an object file (by renaming it to have the .obj extension, for example).
After this commit, the following works:
zig build-exe main.zig resource.res
or, in build.zig:
exe.addObjectFile("resource.res");
Closes #64882 files changed, 8 insertions(+), 3 deletions(-)
src/Compilation.zig+6-1| ... | ... | @@ -4436,7 +4436,7 @@ pub fn addCCArgs( |
| 4436 | 4436 | try argv.append("-fno-unwind-tables"); |
| 4437 | 4437 | } |
| 4438 | 4438 | }, |
| 4439 | .shared_library, .ll, .bc, .unknown, .static_library, .object, .def, .zig => {}, | |
| 4439 | .shared_library, .ll, .bc, .unknown, .static_library, .object, .def, .zig, .res => {}, | |
| 4440 | 4440 | .assembly, .assembly_with_cpp => { |
| 4441 | 4441 | // The Clang assembler does not accept the list of CPU features like the |
| 4442 | 4442 | // compiler frontend does. Therefore we must hard-code the -m flags for |
| ... | ... | @@ -4602,6 +4602,7 @@ pub const FileExt = enum { |
| 4602 | 4602 | static_library, |
| 4603 | 4603 | zig, |
| 4604 | 4604 | def, |
| 4605 | res, | |
| 4605 | 4606 | unknown, |
| 4606 | 4607 | |
| 4607 | 4608 | pub fn clangSupportsDepFile(ext: FileExt) bool { |
| ... | ... | @@ -4617,6 +4618,7 @@ pub const FileExt = enum { |
| 4617 | 4618 | .static_library, |
| 4618 | 4619 | .zig, |
| 4619 | 4620 | .def, |
| 4621 | .res, | |
| 4620 | 4622 | .unknown, |
| 4621 | 4623 | => false, |
| 4622 | 4624 | }; |
| ... | ... | @@ -4639,6 +4641,7 @@ pub const FileExt = enum { |
| 4639 | 4641 | .static_library => target.staticLibSuffix(), |
| 4640 | 4642 | .zig => ".zig", |
| 4641 | 4643 | .def => ".def", |
| 4644 | .res => ".res", | |
| 4642 | 4645 | .unknown => "", |
| 4643 | 4646 | }; |
| 4644 | 4647 | } |
| ... | ... | @@ -4730,6 +4733,8 @@ pub fn classifyFileExt(filename: []const u8) FileExt { |
| 4730 | 4733 | return .cu; |
| 4731 | 4734 | } else if (mem.endsWith(u8, filename, ".def")) { |
| 4732 | 4735 | return .def; |
| 4736 | } else if (mem.endsWith(u8, filename, ".res")) { | |
| 4737 | return .res; | |
| 4733 | 4738 | } else { |
| 4734 | 4739 | return .unknown; |
| 4735 | 4740 | } |
src/main.zig+2-2| ... | ... | @@ -1510,7 +1510,7 @@ fn buildOutputType( |
| 1510 | 1510 | } |
| 1511 | 1511 | } else switch (file_ext orelse |
| 1512 | 1512 | Compilation.classifyFileExt(arg)) { |
| 1513 | .object, .static_library, .shared_library => try link_objects.append(.{ .path = arg }), | |
| 1513 | .object, .static_library, .shared_library, .res => try link_objects.append(.{ .path = arg }), | |
| 1514 | 1514 | .assembly, .assembly_with_cpp, .c, .cpp, .h, .ll, .bc, .m, .mm, .cu => { |
| 1515 | 1515 | try c_source_files.append(.{ |
| 1516 | 1516 | .src_path = arg, |
| ... | ... | @@ -1605,7 +1605,7 @@ fn buildOutputType( |
| 1605 | 1605 | .ext = file_ext, // duped while parsing the args. |
| 1606 | 1606 | }); |
| 1607 | 1607 | }, |
| 1608 | .unknown, .shared_library, .object, .static_library => try link_objects.append(.{ | |
| 1608 | .unknown, .shared_library, .object, .static_library, .res => try link_objects.append(.{ | |
| 1609 | 1609 | .path = it.only_arg, |
| 1610 | 1610 | .must_link = must_link, |
| 1611 | 1611 | }), |