mirror of
https://github.com/ziglang/zig.git
synced 2026-01-04 20:43:19 +00:00
remove tool: update-license-headers
This tool is not needed since license headers were removed in d29871977f97b50fe5e3f16cd9c68ebeba02a562.
This commit is contained in:
parent
5031519b73
commit
3f6e651d5a
@ -67,7 +67,6 @@ pub const simple_cases = [_]SimpleCase{
|
||||
.{ .src_path = "tools/gen_stubs.zig" },
|
||||
.{ .src_path = "tools/generate_linux_syscalls.zig" },
|
||||
.{ .src_path = "tools/process_headers.zig" },
|
||||
.{ .src_path = "tools/update-license-headers.zig" },
|
||||
.{ .src_path = "tools/update-linux-headers.zig" },
|
||||
.{ .src_path = "tools/update_clang_options.zig" },
|
||||
.{ .src_path = "tools/update_cpu_features.zig" },
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// This script replaces a matching license header from .zig source files in a directory tree
|
||||
/// with the `new_header` below.
|
||||
const new_header = "";
|
||||
|
||||
pub fn main() !void {
|
||||
var progress = std.Progress{};
|
||||
const root_node = progress.start("", 0);
|
||||
defer root_node.end();
|
||||
|
||||
var arena_allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
const arena = arena_allocator.allocator();
|
||||
|
||||
const args = try std.process.argsAlloc(arena);
|
||||
const path_to_walk = args[1];
|
||||
const dir = try std.fs.cwd().openDir(path_to_walk, .{ .iterate = true });
|
||||
|
||||
var walker = try dir.walk(arena);
|
||||
defer walker.deinit();
|
||||
|
||||
var buffer: [500]u8 = undefined;
|
||||
const expected_header = buffer[0..try std.io.getStdIn().readAll(&buffer)];
|
||||
|
||||
while (try walker.next()) |entry| {
|
||||
if (!std.mem.endsWith(u8, entry.basename, ".zig"))
|
||||
continue;
|
||||
|
||||
var node = root_node.start(entry.basename, 0);
|
||||
node.activate();
|
||||
defer node.end();
|
||||
|
||||
const source = try dir.readFileAlloc(arena, entry.path, 20 * 1024 * 1024);
|
||||
if (!std.mem.startsWith(u8, source, expected_header)) {
|
||||
std.debug.print("no match: {s}\n", .{entry.path});
|
||||
continue;
|
||||
}
|
||||
|
||||
const truncated_source = source[expected_header.len..];
|
||||
|
||||
const new_source = try arena.alloc(u8, truncated_source.len + new_header.len);
|
||||
@memcpy(new_source[0..new_source.len], new_header);
|
||||
@memcpy(new_source[new_header.len .. new_header.len + truncated_source.len], truncated_source);
|
||||
|
||||
try dir.writeFile(entry.path, new_source);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user