Error if an .rc file uses the 'preprocess only' or 'no preprocess' flags

This commit is contained in:
Ryan Liptak 2023-10-18 18:12:22 -07:00
parent 81a61c8ecd
commit 8ec04b567e
2 changed files with 10 additions and 2 deletions

View File

@ -243,6 +243,8 @@ pub const RcSourceFile = struct {
file: LazyPath,
/// Any option that rc.exe accepts will work here, with the exception of:
/// - `/fo`: The output filename is set by the build system
/// - `/p`: Only running the preprocessor is not supported in this context
/// - `/:no-preprocess` (non-standard option): Not supported in this context
/// - Any MUI-related option
/// https://learn.microsoft.com/en-us/windows/win32/menurc/using-rc-the-rc-command-line-
///

View File

@ -4759,11 +4759,17 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
// unconditionally set `ignore_include_env_var` to true
options.ignore_include_env_var = true;
if (options.preprocess != .yes) {
return comp.failWin32Resource(win32_resource, "the '{s}' option is not supported in this context", .{switch (options.preprocess) {
.no => "/:no-preprocess",
.only => "/p",
.yes => unreachable,
}});
}
var argv = std.ArrayList([]const u8).init(comp.gpa);
defer argv.deinit();
// TODO: support options.preprocess == .no and .only
// alternatively, error if those options are used
try argv.appendSlice(&[_][]const u8{ self_exe_path, "clang" });
try resinator.preprocess.appendClangArgs(arena, &argv, options, .{