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,...@@ -50,7 +50,6 @@ install_path: []const u8,
50sysroot: ?[]const u8 = null,50sysroot: ?[]const u8 = null,
51search_prefixes: std.ArrayListUnmanaged([]const u8),51search_prefixes: std.ArrayListUnmanaged([]const u8),
52libc_file: ?[]const u8 = null,52libc_file: ?[]const u8 = null,
53installed_files: ArrayList(InstalledFile),
54/// Path to the directory containing build.zig.53/// Path to the directory containing build.zig.
55build_root: Cache.Directory,54build_root: Cache.Directory,
56cache_root: Cache.Directory,55cache_root: Cache.Directory,
...@@ -331,7 +330,6 @@ pub fn create(...@@ -331,7 +330,6 @@ pub fn create(
331 .exe_dir = undefined,330 .exe_dir = undefined,
332 .h_dir = undefined,331 .h_dir = undefined,
333 .dest_dir = graph.env_map.get("DESTDIR"),332 .dest_dir = graph.env_map.get("DESTDIR"),
334 .installed_files = ArrayList(InstalledFile).init(arena),
335 .install_tls = .{333 .install_tls = .{
336 .step = Step.init(.{334 .step = Step.init(.{
337 .id = TopLevelStep.base_id,335 .id = TopLevelStep.base_id,
...@@ -433,7 +431,6 @@ fn createChildOnly(...@@ -433,7 +431,6 @@ fn createChildOnly(
433 .sysroot = parent.sysroot,431 .sysroot = parent.sysroot,
434 .search_prefixes = parent.search_prefixes,432 .search_prefixes = parent.search_prefixes,
435 .libc_file = parent.libc_file,433 .libc_file = parent.libc_file,
436 .installed_files = ArrayList(InstalledFile).init(allocator),
437 .build_root = build_root,434 .build_root = build_root,
438 .cache_root = parent.cache_root,435 .cache_root = parent.cache_root,
439 .zig_lib_dir = parent.zig_lib_dir,436 .zig_lib_dir = parent.zig_lib_dir,
...@@ -1138,15 +1135,8 @@ fn makeUninstall(uninstall_step: *Step, prog_node: std.Progress.Node) anyerror!v...@@ -1138,15 +1135,8 @@ fn makeUninstall(uninstall_step: *Step, prog_node: std.Progress.Node) anyerror!v
1138 const uninstall_tls: *TopLevelStep = @fieldParentPtr("step", uninstall_step);1135 const uninstall_tls: *TopLevelStep = @fieldParentPtr("step", uninstall_step);
1139 const b: *Build = @fieldParentPtr("uninstall_tls", uninstall_tls);1136 const b: *Build = @fieldParentPtr("uninstall_tls", uninstall_tls);
11401137
1141 for (b.installed_files.items) |installed_file| {1138 _ = b;
1142 const full_path = b.getInstallPath(installed_file.dir, installed_file.path);1139 @panic("TODO implement https://github.com/ziglang/zig/issues/14943");
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
1150}1140}
11511141
1152/// Creates a configuration option to be passed to the build.zig script.1142/// Creates a configuration option to be passed to the build.zig script.
...@@ -1719,15 +1709,6 @@ pub fn addCheckFile(...@@ -1719,15 +1709,6 @@ pub fn addCheckFile(
1719 return Step.CheckFile.create(b, file_source, options);1709 return Step.CheckFile.create(b, file_source, options);
1720}1710}
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
1731pub fn truncateFile(b: *Build, dest_path: []const u8) !void {1712pub fn truncateFile(b: *Build, dest_path: []const u8) !void {
1732 if (b.verbose) {1713 if (b.verbose) {
1733 log.info("truncate {s}", .{dest_path});1714 log.info("truncate {s}", .{dest_path});
...@@ -2567,19 +2548,6 @@ pub const InstallDir = union(enum) {...@@ -2567,19 +2548,6 @@ pub const InstallDir = union(enum) {
2567 }2548 }
2568};2549};
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
2583/// This function is intended to be called in the `configure` phase only.2551/// This function is intended to be called in the `configure` phase only.
2584/// It returns an absolute directory path, which is potentially going to be a2552/// It returns an absolute directory path, which is potentially going to be a
2585/// source of API breakage in the future, so keep that in mind when using this2553/// 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 {...@@ -41,7 +41,6 @@ pub const Options = struct {
41};41};
4242
43pub fn create(owner: *std.Build, options: Options) *InstallDir {43pub fn create(owner: *std.Build, options: Options) *InstallDir {
44 owner.pushInstalledFile(options.install_dir, options.install_subdir);
45 const install_dir = owner.allocator.create(InstallDir) catch @panic("OOM");44 const install_dir = owner.allocator.create(InstallDir) catch @panic("OOM");
46 install_dir.* = .{45 install_dir.* = .{
47 .step = Step.init(.{46 .step = Step.init(.{
lib/std/Build/Step/InstallFile.zig-1
...@@ -19,7 +19,6 @@ pub fn create(...@@ -19,7 +19,6 @@ pub fn create(
19 dest_rel_path: []const u8,19 dest_rel_path: []const u8,
20) *InstallFile {20) *InstallFile {
21 assert(dest_rel_path.len != 0);21 assert(dest_rel_path.len != 0);
22 owner.pushInstalledFile(dir, dest_rel_path);
23 const install_file = owner.allocator.create(InstallFile) catch @panic("OOM");22 const install_file = owner.allocator.create(InstallFile) catch @panic("OOM");
24 install_file.* = .{23 install_file.* = .{
25 .step = Step.init(.{24 .step = Step.init(.{