authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-07 17:02:17-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-07 17:02:17-07:00
log3f6e651d5a850bb9623e628aa83cd9d70e83c417
tree12293884e7d96234b3972785a3a40c2c84997b93
parent5031519b737e9b8338f1091b5b6f4c059dfb5c2c

remove tool: update-license-headers

This tool is not needed since license headers were removed in d29871977f97b50fe5e3f16cd9c68ebeba02a562.

2 files changed, 0 insertions(+), 48 deletions(-)

test/standalone.zig-1
...@@ -67,7 +67,6 @@ pub const simple_cases = [_]SimpleCase{...@@ -67,7 +67,6 @@ pub const simple_cases = [_]SimpleCase{
67 .{ .src_path = "tools/gen_stubs.zig" },67 .{ .src_path = "tools/gen_stubs.zig" },
68 .{ .src_path = "tools/generate_linux_syscalls.zig" },68 .{ .src_path = "tools/generate_linux_syscalls.zig" },
69 .{ .src_path = "tools/process_headers.zig" },69 .{ .src_path = "tools/process_headers.zig" },
70 .{ .src_path = "tools/update-license-headers.zig" },
71 .{ .src_path = "tools/update-linux-headers.zig" },70 .{ .src_path = "tools/update-linux-headers.zig" },
72 .{ .src_path = "tools/update_clang_options.zig" },71 .{ .src_path = "tools/update_clang_options.zig" },
73 .{ .src_path = "tools/update_cpu_features.zig" },72 .{ .src_path = "tools/update_cpu_features.zig" },
tools/update-license-headers.zig deleted-47
...@@ -1,47 +0,0 @@
1const std = @import("std");
2
3/// This script replaces a matching license header from .zig source files in a directory tree
4/// with the `new_header` below.
5const new_header = "";
6
7pub fn main() !void {
8 var progress = std.Progress{};
9 const root_node = progress.start("", 0);
10 defer root_node.end();
11
12 var arena_allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator);
13 const arena = arena_allocator.allocator();
14
15 const args = try std.process.argsAlloc(arena);
16 const path_to_walk = args[1];
17 const dir = try std.fs.cwd().openDir(path_to_walk, .{ .iterate = true });
18
19 var walker = try dir.walk(arena);
20 defer walker.deinit();
21
22 var buffer: [500]u8 = undefined;
23 const expected_header = buffer[0..try std.io.getStdIn().readAll(&buffer)];
24
25 while (try walker.next()) |entry| {
26 if (!std.mem.endsWith(u8, entry.basename, ".zig"))
27 continue;
28
29 var node = root_node.start(entry.basename, 0);
30 node.activate();
31 defer node.end();
32
33 const source = try dir.readFileAlloc(arena, entry.path, 20 * 1024 * 1024);
34 if (!std.mem.startsWith(u8, source, expected_header)) {
35 std.debug.print("no match: {s}\n", .{entry.path});
36 continue;
37 }
38
39 const truncated_source = source[expected_header.len..];
40
41 const new_source = try arena.alloc(u8, truncated_source.len + new_header.len);
42 @memcpy(new_source[0..new_source.len], new_header);
43 @memcpy(new_source[new_header.len .. new_header.len + truncated_source.len], truncated_source);
44
45 try dir.writeFile(entry.path, new_source);
46 }
47}