commit 3f92cbef89e13c90e2c9f7051dbf5edef76fa90b (tree)
parent c32e0d3000f4ee539c00577b75e18c683e84f2c4
Author: Ryan Liptak <squeek502@hotmail.com>
Date: Sat, 9 Mar 2024 23:15:06 -0800
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.
Diffstat:
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/lib/compiler/resinator/main.zig b/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,