aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorRyan Liptak <squeek502@hotmail.com>2023-06-24 15:22:56 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-25 01:42:12 -0700
commitb11170294052585ae81b9946d770f860d163da8f (patch)
treeeb4b73867e878ca8706b73f27eafa21ea6ccaa98 /src/Compilation.zig
parent9684947faae674e093dda4c81d94f51b9568369e (diff)
downloadzig-b11170294052585ae81b9946d770f860d163da8f.tar.gz
zig-b11170294052585ae81b9946d770f860d163da8f.zip
Recognize the .res extension and link it as if it were an object file
.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 #6488
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index d9273dcdd8..902586bf7a 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -4436,7 +4436,7 @@ pub fn addCCArgs(
try argv.append("-fno-unwind-tables");
}
},
- .shared_library, .ll, .bc, .unknown, .static_library, .object, .def, .zig => {},
+ .shared_library, .ll, .bc, .unknown, .static_library, .object, .def, .zig, .res => {},
.assembly, .assembly_with_cpp => {
// The Clang assembler does not accept the list of CPU features like the
// compiler frontend does. Therefore we must hard-code the -m flags for
@@ -4602,6 +4602,7 @@ pub const FileExt = enum {
static_library,
zig,
def,
+ res,
unknown,
pub fn clangSupportsDepFile(ext: FileExt) bool {
@@ -4617,6 +4618,7 @@ pub const FileExt = enum {
.static_library,
.zig,
.def,
+ .res,
.unknown,
=> false,
};
@@ -4639,6 +4641,7 @@ pub const FileExt = enum {
.static_library => target.staticLibSuffix(),
.zig => ".zig",
.def => ".def",
+ .res => ".res",
.unknown => "",
};
}
@@ -4730,6 +4733,8 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
return .cu;
} else if (mem.endsWith(u8, filename, ".def")) {
return .def;
+ } else if (mem.endsWith(u8, filename, ".res")) {
+ return .res;
} else {
return .unknown;
}