Skip to content

Commit 8ec04b5

Browse files
committed
Error if an .rc file uses the 'preprocess only' or 'no preprocess' flags
1 parent 81a61c8 commit 8ec04b5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/std/Build/Step/Compile.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ pub const RcSourceFile = struct {
243243
file: LazyPath,
244244
/// Any option that rc.exe accepts will work here, with the exception of:
245245
/// - `/fo`: The output filename is set by the build system
246+
/// - `/p`: Only running the preprocessor is not supported in this context
247+
/// - `/:no-preprocess` (non-standard option): Not supported in this context
246248
/// - Any MUI-related option
247249
/// https://learn.microsoft.com/en-us/windows/win32/menurc/using-rc-the-rc-command-line-
248250
///

src/Compilation.zig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4759,11 +4759,17 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
47594759
// unconditionally set `ignore_include_env_var` to true
47604760
options.ignore_include_env_var = true;
47614761

4762+
if (options.preprocess != .yes) {
4763+
return comp.failWin32Resource(win32_resource, "the '{s}' option is not supported in this context", .{switch (options.preprocess) {
4764+
.no => "/:no-preprocess",
4765+
.only => "/p",
4766+
.yes => unreachable,
4767+
}});
4768+
}
4769+
47624770
var argv = std.ArrayList([]const u8).init(comp.gpa);
47634771
defer argv.deinit();
47644772

4765-
// TODO: support options.preprocess == .no and .only
4766-
// alternatively, error if those options are used
47674773
try argv.appendSlice(&[_][]const u8{ self_exe_path, "clang" });
47684774

47694775
try resinator.preprocess.appendClangArgs(arena, &argv, options, .{

0 commit comments

Comments
 (0)