Skip to content
This repository was archived by the owner on Nov 22, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 47 additions & 20 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,29 +1,56 @@
const std = @import("std");

pub fn build(b: *std.build.Builder) void {
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const arocc_dep = b.anonymousDependency("arocc", @import("arocc/build.zig"), .{
.target = target,
.optimize = optimize,
});
const textual = true;
if (!textual) {
const arocc_dep = b.anonymousDependency("arocc", @import("arocc/build.zig"), .{
.target = target,
.optimize = optimize,
});

const exe = b.addExecutable(.{
.name = "universal-headers",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
exe.addModule("arocc", arocc_dep.module("aro"));
b.installArtifact(exe);
const exe = b.addExecutable(.{
.name = "universal-headers",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
exe.addModule("arocc", arocc_dep.module("aro"));
b.installArtifact(exe);

const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}

const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
} else {
const addHeaders = b.addExecutable(.{
.name = "addHeaders",
.root_source_file = b.path("src/textdiff/addHeaders.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(addHeaders);

const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const outputHeaders = b.addExecutable(.{
.name = "outputHeaders",
.root_source_file = b.path("src/textdiff/outputHeaders.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(outputHeaders);

const testHeaders = b.addExecutable(.{
.name = "testHeaders",
.root_source_file = b.path("src/textdiff/testHeaders.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(testHeaders);
}
}
7 changes: 4 additions & 3 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.{
.name = "universal-headers",
.name = .universal_headers,
.version = "0.0.1",

.dependencies = .{ },
.fingerprint = 0xb8a12caa0ec708d5,
.paths = .{""},
.dependencies = .{},
}
31 changes: 31 additions & 0 deletions src/textdiff/HOWTO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

zig build
- should give you (in zig-out/bin): addHeaders, outputHeaders, testHeaders
- also shells out to diff


for the whole thing, run (for me this takes ~30min):
./src/textdiff/compile.bash headers/*

then to test (takes ~5min):
./src/textdiff/test.bash headers/*


What's going on:

1. addHeaders headers/foo
- takes files from foo
- normalizes them into uh_norm
- for each file:
- adds context prefix to each line
- outputs to uh_workfile
- diffs with file in uh_workspace and modifies uh_workspace

2. outputHeaders uh_headers
- reads files from uh_workspace and outputs universal headers in uh_headers
- uses reductions.zig to reduce #if statements

3. testHeaders headers/foo
- partially evaluates uh_headers for version foo and outputs to uh_test
- can then diff uh_test uh_norm/foo

Loading