aboutsummaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-02-20 20:52:26 -0500
committerJacob Young <jacobly0@users.noreply.github.com>2023-02-20 23:59:48 -0500
commit3eed197c95c21d850d503687f445946e6bd429c5 (patch)
treedea7f74c1bc864dfdc97829aaafbcc8b72b92207 /build.zig
parentd513792afa4893c21d5a9635c61d8e41689d9541 (diff)
downloadzig-3eed197c95c21d850d503687f445946e6bd429c5.tar.gz
zig-3eed197c95c21d850d503687f445946e6bd429c5.zip
CBE: use stdint.h types instead of `zig_` prefixes
This requires manual defines before C99 which may not have stdint.h. Also have update-zig1 leave a copy of lib/zig.h in stage1/zig.h, which allows lib/zig.h to be updated without needing to update zig1.wasm. Note that since the object already existed with the exact same contents, this completely avoids repo bloat due to zig.h changes.
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig31
1 files changed, 31 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index faf14cc405..175beeb422 100644
--- a/build.zig
+++ b/build.zig
@@ -506,8 +506,39 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
run_opt.addArg("-o");
run_opt.addFileSourceArg(.{ .path = "stage1/zig1.wasm" });
+ const CopyFileStep = struct {
+ const Step = std.Build.Step;
+ const FileSource = std.Build.FileSource;
+ const CopyFileStep = @This();
+
+ step: Step,
+ builder: *std.Build,
+ source: FileSource,
+ dest_rel_path: []const u8,
+
+ pub fn init(builder: *std.Build, source: FileSource, dest_rel_path: []const u8) CopyFileStep {
+ return CopyFileStep{
+ .builder = builder,
+ .step = Step.init(.custom, builder.fmt("install {s} to {s}", .{ source.getDisplayName(), dest_rel_path }), builder.allocator, make),
+ .source = source.dupe(builder),
+ .dest_rel_path = builder.dupePath(dest_rel_path),
+ };
+ }
+
+ fn make(step: *Step) !void {
+ const self = @fieldParentPtr(CopyFileStep, "step", step);
+ const full_src_path = self.source.getPath(self.builder);
+ const full_dest_path = self.builder.pathFromRoot(self.dest_rel_path);
+ try self.builder.updateFile(full_src_path, full_dest_path);
+ }
+ };
+
+ const copy_zig_h = try b.allocator.create(CopyFileStep);
+ copy_zig_h.* = CopyFileStep.init(b, .{ .path = "lib/zig.h" }, "stage1/zig.h");
+
const update_zig1_step = b.step("update-zig1", "Update stage1/zig1.wasm");
update_zig1_step.dependOn(&run_opt.step);
+ update_zig1_step.dependOn(&copy_zig_h.step);
}
fn addCompilerStep(