Commit 8ec04b567e

Ryan Liptak <squeek502@hotmail.com>
2023-10-19 03:12:22
Error if an .rc file uses the 'preprocess only' or 'no preprocess' flags
1 parent 81a61c8
Changed files (2)
lib
std
Build
src
lib/std/Build/Step/Compile.zig
@@ -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-
     ///
src/Compilation.zig
@@ -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, .{