authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-05 13:05:56-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-12 00:14:07-07:00
log26d506c0f8b5249fe29186506b82e5f515fcc56f
treee121b52ece56fe6a02f5f1b079787efaa2f7dbfd
parent6e025fc2e298c633ab36e9058a2cc610f57e4522

std.Build: remove the "push installed file" mechanism

Tracked by #14943

3 files changed, 2 insertions(+), 36 deletions(-)

lib/std/Build.zig+2-34
......@@ -50,7 +50,6 @@ install_path: []const u8,
5050sysroot: ?[]const u8 = null,
5151search_prefixes: std.ArrayListUnmanaged([]const u8),
5252libc_file: ?[]const u8 = null,
53installed_files: ArrayList(InstalledFile),
5453/// Path to the directory containing build.zig.
5554build_root: Cache.Directory,
5655cache_root: Cache.Directory,
......@@ -331,7 +330,6 @@ pub fn create(
331330 .exe_dir = undefined,
332331 .h_dir = undefined,
333332 .dest_dir = graph.env_map.get("DESTDIR"),
334 .installed_files = ArrayList(InstalledFile).init(arena),
335333 .install_tls = .{
336334 .step = Step.init(.{
337335 .id = TopLevelStep.base_id,
......@@ -433,7 +431,6 @@ fn createChildOnly(
433431 .sysroot = parent.sysroot,
434432 .search_prefixes = parent.search_prefixes,
435433 .libc_file = parent.libc_file,
436 .installed_files = ArrayList(InstalledFile).init(allocator),
437434 .build_root = build_root,
438435 .cache_root = parent.cache_root,
439436 .zig_lib_dir = parent.zig_lib_dir,
......@@ -1138,15 +1135,8 @@ fn makeUninstall(uninstall_step: *Step, prog_node: std.Progress.Node) anyerror!v
11381135 const uninstall_tls: *TopLevelStep = @fieldParentPtr("step", uninstall_step);
11391136 const b: *Build = @fieldParentPtr("uninstall_tls", uninstall_tls);
11401137
1141 for (b.installed_files.items) |installed_file| {
1142 const full_path = b.getInstallPath(installed_file.dir, installed_file.path);
1143 if (b.verbose) {
1144 log.info("rm {s}", .{full_path});
1145 }
1146 fs.cwd().deleteTree(full_path) catch {};
1147 }
1148
1149 // TODO remove empty directories
1138 _ = b;
1139 @panic("TODO implement https://github.com/ziglang/zig/issues/14943");
11501140}
11511141
11521142/// Creates a configuration option to be passed to the build.zig script.
......@@ -1719,15 +1709,6 @@ pub fn addCheckFile(
17191709 return Step.CheckFile.create(b, file_source, options);
17201710}
17211711
1722/// deprecated: https://github.com/ziglang/zig/issues/14943
1723pub fn pushInstalledFile(b: *Build, dir: InstallDir, dest_rel_path: []const u8) void {
1724 const file = InstalledFile{
1725 .dir = dir,
1726 .path = dest_rel_path,
1727 };
1728 b.installed_files.append(file.dupe(b)) catch @panic("OOM");
1729}
1730
17311712pub fn truncateFile(b: *Build, dest_path: []const u8) !void {
17321713 if (b.verbose) {
17331714 log.info("truncate {s}", .{dest_path});
......@@ -2567,19 +2548,6 @@ pub const InstallDir = union(enum) {
25672548 }
25682549};
25692550
2570pub const InstalledFile = struct {
2571 dir: InstallDir,
2572 path: []const u8,
2573
2574 /// Duplicates the installed file path and directory.
2575 pub fn dupe(file: InstalledFile, builder: *Build) InstalledFile {
2576 return .{
2577 .dir = file.dir.dupe(builder),
2578 .path = builder.dupe(file.path),
2579 };
2580 }
2581};
2582
25832551/// This function is intended to be called in the `configure` phase only.
25842552/// It returns an absolute directory path, which is potentially going to be a
25852553/// source of API breakage in the future, so keep that in mind when using this
lib/std/Build/Step/InstallDir.zig-1
......@@ -41,7 +41,6 @@ pub const Options = struct {
4141};
4242
4343pub fn create(owner: *std.Build, options: Options) *InstallDir {
44 owner.pushInstalledFile(options.install_dir, options.install_subdir);
4544 const install_dir = owner.allocator.create(InstallDir) catch @panic("OOM");
4645 install_dir.* = .{
4746 .step = Step.init(.{
lib/std/Build/Step/InstallFile.zig-1
......@@ -19,7 +19,6 @@ pub fn create(
1919 dest_rel_path: []const u8,
2020) *InstallFile {
2121 assert(dest_rel_path.len != 0);
22 owner.pushInstalledFile(dir, dest_rel_path);
2322 const install_file = owner.allocator.create(InstallFile) catch @panic("OOM");
2423 install_file.* = .{
2524 .step = Step.init(.{