Skip to content

Commit

Permalink
resinator: Fix auto-detected includes only being used during preproce…
Browse files Browse the repository at this point in the history
…ssing

Also need to pass them to the .res compilation step, since files (cursors, icons, etc) can be found in the system include directories.
  • Loading branch information
squeek502 committed Mar 10, 2024
1 parent be59e5c commit e458558
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions lib/compiler/resinator/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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();

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e458558

Please sign in to comment.