Commit 26d506c0f8

Andrew Kelley <andrew@ziglang.org>
2024-07-05 22:05:56
std.Build: remove the "push installed file" mechanism
Tracked by #14943
1 parent 6e025fc
Changed files (3)
lib/std/Build/Step/InstallDir.zig
@@ -41,7 +41,6 @@ pub const Options = struct {
 };
 
 pub fn create(owner: *std.Build, options: Options) *InstallDir {
-    owner.pushInstalledFile(options.install_dir, options.install_subdir);
     const install_dir = owner.allocator.create(InstallDir) catch @panic("OOM");
     install_dir.* = .{
         .step = Step.init(.{
lib/std/Build/Step/InstallFile.zig
@@ -19,7 +19,6 @@ pub fn create(
     dest_rel_path: []const u8,
 ) *InstallFile {
     assert(dest_rel_path.len != 0);
-    owner.pushInstalledFile(dir, dest_rel_path);
     const install_file = owner.allocator.create(InstallFile) catch @panic("OOM");
     install_file.* = .{
         .step = Step.init(.{
lib/std/Build.zig
@@ -50,7 +50,6 @@ install_path: []const u8,
 sysroot: ?[]const u8 = null,
 search_prefixes: std.ArrayListUnmanaged([]const u8),
 libc_file: ?[]const u8 = null,
-installed_files: ArrayList(InstalledFile),
 /// Path to the directory containing build.zig.
 build_root: Cache.Directory,
 cache_root: Cache.Directory,
@@ -331,7 +330,6 @@ pub fn create(
         .exe_dir = undefined,
         .h_dir = undefined,
         .dest_dir = graph.env_map.get("DESTDIR"),
-        .installed_files = ArrayList(InstalledFile).init(arena),
         .install_tls = .{
             .step = Step.init(.{
                 .id = TopLevelStep.base_id,
@@ -433,7 +431,6 @@ fn createChildOnly(
         .sysroot = parent.sysroot,
         .search_prefixes = parent.search_prefixes,
         .libc_file = parent.libc_file,
-        .installed_files = ArrayList(InstalledFile).init(allocator),
         .build_root = build_root,
         .cache_root = parent.cache_root,
         .zig_lib_dir = parent.zig_lib_dir,
@@ -1138,15 +1135,8 @@ fn makeUninstall(uninstall_step: *Step, prog_node: std.Progress.Node) anyerror!v
     const uninstall_tls: *TopLevelStep = @fieldParentPtr("step", uninstall_step);
     const b: *Build = @fieldParentPtr("uninstall_tls", uninstall_tls);
 
-    for (b.installed_files.items) |installed_file| {
-        const full_path = b.getInstallPath(installed_file.dir, installed_file.path);
-        if (b.verbose) {
-            log.info("rm {s}", .{full_path});
-        }
-        fs.cwd().deleteTree(full_path) catch {};
-    }
-
-    // TODO remove empty directories
+    _ = b;
+    @panic("TODO implement https://github.com/ziglang/zig/issues/14943");
 }
 
 /// Creates a configuration option to be passed to the build.zig script.
@@ -1719,15 +1709,6 @@ pub fn addCheckFile(
     return Step.CheckFile.create(b, file_source, options);
 }
 
-/// deprecated: https://github.com/ziglang/zig/issues/14943
-pub fn pushInstalledFile(b: *Build, dir: InstallDir, dest_rel_path: []const u8) void {
-    const file = InstalledFile{
-        .dir = dir,
-        .path = dest_rel_path,
-    };
-    b.installed_files.append(file.dupe(b)) catch @panic("OOM");
-}
-
 pub fn truncateFile(b: *Build, dest_path: []const u8) !void {
     if (b.verbose) {
         log.info("truncate {s}", .{dest_path});
@@ -2567,19 +2548,6 @@ pub const InstallDir = union(enum) {
     }
 };
 
-pub const InstalledFile = struct {
-    dir: InstallDir,
-    path: []const u8,
-
-    /// Duplicates the installed file path and directory.
-    pub fn dupe(file: InstalledFile, builder: *Build) InstalledFile {
-        return .{
-            .dir = file.dir.dupe(builder),
-            .path = builder.dupe(file.path),
-        };
-    }
-};
-
 /// This function is intended to be called in the `configure` phase only.
 /// It returns an absolute directory path, which is potentially going to be a
 /// source of API breakage in the future, so keep that in mind when using this