Skip to content

Commit

Permalink
std.Build: remove the "push installed file" mechanism
Browse files Browse the repository at this point in the history
Tracked by #14943
  • Loading branch information
andrewrk committed Jul 8, 2024
1 parent c7ae355 commit 99fac50
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 36 deletions.
36 changes: 2 additions & 34 deletions lib/std/Build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/std/Build/Step/InstallDir.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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(.{
Expand Down
1 change: 0 additions & 1 deletion lib/std/Build/Step/InstallFile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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(.{
Expand Down

0 comments on commit 99fac50

Please sign in to comment.