Commit 3f92cbef89

Ryan Liptak <squeek502@hotmail.com>
2024-03-10 08:15:06
resinator: Fix auto-detected includes only being used during preprocessing
Also need to pass them to the .res compilation step, since files (cursors, icons, etc) can be found in the system include directories.
1 parent c32e0d3
Changed files (1)
lib
compiler
resinator
lib/compiler/resinator/main.zig
@@ -14,6 +14,10 @@ pub fn main() !void {
     defer std.debug.assert(gpa.deinit() == .ok);
     const allocator = gpa.allocator();
 
+    var arena_state = std.heap.ArenaAllocator.init(allocator);
+    defer arena_state.deinit();
+    const arena = arena_state.allocator();
+
     const stderr = std.io.getStdErr();
     const stderr_config = std.io.tty.detectConfig(stderr);
 
@@ -101,6 +105,22 @@ pub fn main() !void {
     }
     const maybe_dependencies_list: ?*std.ArrayList([]const u8) = if (options.depfile_path != null) &dependencies_list else null;
 
+    const include_paths = getIncludePaths(arena, options.auto_includes, zig_lib_dir) catch |err| switch (err) {
+        error.OutOfMemory => |e| return e,
+        else => |e| {
+            switch (e) {
+                error.MsvcIncludesNotFound => {
+                    try error_handler.emitMessage(allocator, .err, "MSVC include paths could not be automatically detected", .{});
+                },
+                error.MingwIncludesNotFound => {
+                    try error_handler.emitMessage(allocator, .err, "MinGW include paths could not be automatically detected", .{});
+                },
+            }
+            try error_handler.emitMessage(allocator, .note, "to disable auto includes, use the option /:auto-includes none", .{});
+            std.os.exit(1);
+        },
+    };
+
     const full_input = full_input: {
         if (options.preprocess != .no) {
             var preprocessed_buf = std.ArrayList(u8).init(allocator);
@@ -112,22 +132,6 @@ pub fn main() !void {
             defer aro_arena_state.deinit();
             const aro_arena = aro_arena_state.allocator();
 
-            const include_paths = getIncludePaths(aro_arena, options.auto_includes, zig_lib_dir) catch |err| switch (err) {
-                error.OutOfMemory => |e| return e,
-                else => |e| {
-                    switch (e) {
-                        error.MsvcIncludesNotFound => {
-                            try error_handler.emitMessage(allocator, .err, "MSVC include paths could not be automatically detected", .{});
-                        },
-                        error.MingwIncludesNotFound => {
-                            try error_handler.emitMessage(allocator, .err, "MinGW include paths could not be automatically detected", .{});
-                        },
-                    }
-                    try error_handler.emitMessage(allocator, .note, "to disable auto includes, use the option /:auto-includes none", .{});
-                    std.os.exit(1);
-                },
-            };
-
             var comp = aro.Compilation.init(aro_arena);
             defer comp.deinit();
 
@@ -211,6 +215,7 @@ pub fn main() !void {
         .dependencies_list = maybe_dependencies_list,
         .ignore_include_env_var = options.ignore_include_env_var,
         .extra_include_paths = options.extra_include_paths.items,
+        .system_include_paths = include_paths,
         .default_language_id = options.default_language_id,
         .default_code_page = options.default_code_page orelse .windows1252,
         .verbose = options.verbose,