-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathutils.zig
More file actions
63 lines (53 loc) · 1.44 KB
/
Copy pathutils.zig
File metadata and controls
63 lines (53 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const std = @import("std");
const Build = std.Build;
const Step = std.Build.Step;
const RunOutput = struct {
run: *Step.Run,
output: Build.LazyPath,
};
pub fn applyPatchToFile(
b: *Build,
target: Build.ResolvedTarget,
file: Build.LazyPath,
patch_file: Build.LazyPath,
output_file: []const u8,
) RunOutput {
const patch = b.addExecutable(.{
.name = "patch",
.root_module = b.createModule(.{
.root_source_file = b.path("build/patch.zig"),
.target = target,
}),
});
const patch_run = b.addRunArtifact(patch);
patch_run.addFileArg(file);
patch_run.addFileArg(patch_file);
const out = patch_run.addOutputFileArg(output_file);
return .{
.run = patch_run,
.output = out,
};
}
pub fn concatenateFiles(
b: *Build,
target: Build.ResolvedTarget,
file1: Build.LazyPath,
file2: Build.LazyPath,
output_file: []const u8,
) RunOutput {
const concatenate = b.addExecutable(.{
.name = "concat",
.root_module = b.createModule(.{
.root_source_file = b.path("build/header_gen.zig"),
.target = target,
}),
});
const concatenate_run = b.addRunArtifact(concatenate);
concatenate_run.addFileArg(file1);
concatenate_run.addFileArg(file2);
const out = concatenate_run.addOutputFileArg(output_file);
return .{
.run = concatenate_run,
.output = out,
};
}