diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-01-31 23:15:59 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-31 23:15:59 -0500 |
| commit | efa25e7d5bca63e83f6a653058c05dacc771d19e (patch) | |
| tree | 56b34421822584702b1647ab0eb38aec160386b4 /lib/std/Build/RemoveDirStep.zig | |
| parent | 6f13a725a3249c7f0a0f5258ac00003cd132bf15 (diff) | |
| parent | 8d37c6f71c790faecdb6acdd2868823be2bd2496 (diff) | |
| download | zig-efa25e7d5bca63e83f6a653058c05dacc771d19e.tar.gz zig-efa25e7d5bca63e83f6a653058c05dacc771d19e.zip | |
Merge pull request #14498 from ziglang/zig-build-api
Several enhancements to the build system. Many breaking changes to the API.
* combine `std.build` and `std.build.Builder` into `std.Build`
* eliminate `setTarget` and `setBuildMode`; use an options struct for `b.addExecutable` and friends
* implement passing options to dependency packages. closes #14285
* rename `LibExeObjStep` to `CompileStep`
* move src.type.CType to std lib, use it from std.Build, this helps with populating config.h files.
Diffstat (limited to 'lib/std/Build/RemoveDirStep.zig')
| -rw-r--r-- | lib/std/Build/RemoveDirStep.zig | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/std/Build/RemoveDirStep.zig b/lib/std/Build/RemoveDirStep.zig new file mode 100644 index 0000000000..f3b71dcec1 --- /dev/null +++ b/lib/std/Build/RemoveDirStep.zig @@ -0,0 +1,29 @@ +const std = @import("../std.zig"); +const log = std.log; +const fs = std.fs; +const Step = std.Build.Step; +const RemoveDirStep = @This(); + +pub const base_id = .remove_dir; + +step: Step, +builder: *std.Build, +dir_path: []const u8, + +pub fn init(builder: *std.Build, dir_path: []const u8) RemoveDirStep { + return RemoveDirStep{ + .builder = builder, + .step = Step.init(.remove_dir, builder.fmt("RemoveDir {s}", .{dir_path}), builder.allocator, make), + .dir_path = builder.dupePath(dir_path), + }; +} + +fn make(step: *Step) !void { + const self = @fieldParentPtr(RemoveDirStep, "step", step); + + const full_path = self.builder.pathFromRoot(self.dir_path); + fs.cwd().deleteTree(full_path) catch |err| { + log.err("Unable to remove {s}: {s}", .{ full_path, @errorName(err) }); + return err; + }; +} |
