Jacob Young dee9f82f69 Run: add output directory arguments
This allows running commands that take an output directory argument. The
main thing that was needed for this feature was generated file subpaths,
to allow access to the files in a generated directory. Additionally, a
minor change was required to so that the correct directory is created
for output directory args.
2024-05-05 15:58:08 -04:00

41 lines
1.3 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Test it");
b.default_step = test_step;
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const create_file_exe = b.addExecutable(.{
.name = "create_file",
.root_source_file = b.path("create_file.zig"),
.target = target,
.optimize = optimize,
});
const create_first = b.addRunArtifact(create_file_exe);
const first_dir = create_first.addOutputDirectoryArg("first");
create_first.addArg("hello1.txt");
test_step.dependOn(&b.addCheckFile(first_dir.path(b, "hello1.txt"), .{ .expected_matches = &.{
std.fs.path.sep_str ++
\\first
\\hello1.txt
\\Hello, world!
\\
,
} }).step);
const create_second = b.addRunArtifact(create_file_exe);
const second_dir = create_second.addPrefixedOutputDirectoryArg("--dir=", "second");
create_second.addArg("hello2.txt");
test_step.dependOn(&b.addCheckFile(second_dir.path(b, "hello2.txt"), .{ .expected_matches = &.{
std.fs.path.sep_str ++
\\second
\\hello2.txt
\\Hello, world!
\\
,
} }).step);
}