| 1 | const std = @import("std"); |
| 2 | |
| 3 | pub fn main(init: std.process.Init) !void { |
| 4 | const io = init.io; |
| 5 | const arena = init.arena.allocator(); |
| 6 | |
| 7 | var iter = try init.minimal.args.iterateAllocator(arena); |
| 8 | std.debug.assert(iter.skip()); |
| 9 | while (iter.next()) |arg| { |
| 10 | const path_prefix = "path^"; |
| 11 | const path_suffix = "$"; |
| 12 | if (std.mem.startsWith(u8, arg, path_prefix) and std.mem.endsWith(u8, arg, path_suffix)) { |
| 13 | // If we're a path, log whether we're absolute or relative, and log the basename |
| 14 | const path = arg[path_prefix.len..][0 .. arg.len - path_prefix.len - path_suffix.len]; |
| 15 | if (std.fs.path.isAbsolute(path)) { |
| 16 | std.debug.print("abs ", .{}); |
| 17 | } else { |
| 18 | std.debug.print("rel ", .{}); |
| 19 | } |
| 20 | std.debug.print("{s}\n", .{std.fs.path.basename(path)}); |
| 21 | |
| 22 | // Create an empty dep file if necessary |
| 23 | if (std.mem.endsWith(u8, path, ".d")) { |
| 24 | const file = try std.Io.Dir.cwd().createFile(io, path, .{}); |
| 25 | defer file.close(io); |
| 26 | } |
| 27 | } else { |
| 28 | // If it's not a path, log the arg as is |
| 29 | std.debug.print("{s}\n", .{arg}); |
| 30 | } |
| 31 | } |
| 32 | } |