From 089ebeb8736e9186c14d8228fa5594c518dcdb4b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 7 Jan 2024 22:15:28 -0700 Subject: [PATCH] update-mingw tool: add config.h to whitelist --- tools/update_mingw.zig | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/update_mingw.zig b/tools/update_mingw.zig index c3aa509728..8d708b7df4 100644 --- a/tools/update_mingw.zig +++ b/tools/update_mingw.zig @@ -45,13 +45,16 @@ pub fn main() !void { while (try walker.next()) |entry| { if (entry.kind != .file) continue; - // Special exception to keep the copyright file. - if (std.mem.eql(u8, entry.path, "COPYING")) continue; - src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, .{}) catch |err| switch (err) { error.FileNotFound => { - std.log.warn("deleting {s}", .{entry.path}); - try dest_crt_dir.deleteFile(entry.path); + const whitelisted = for (whitelist) |item| { + if (std.mem.eql(u8, entry.path, item)) break true; + } else false; + + if (!whitelisted) { + std.log.warn("deleting {s}", .{entry.path}); + try dest_crt_dir.deleteFile(entry.path); + } }, else => { std.log.err("unable to copy {s}: {s}", .{ entry.path, @errorName(err) }); @@ -105,6 +108,11 @@ pub fn main() !void { return std.process.cleanExit(); } +const whitelist = [_][]const u8{ + "COPYING", + "include" ++ std.fs.path.sep_str ++ "config.h", +}; + const ok_exts = [_][]const u8{ ".def", ".def.in",