diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 15:14:31 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 15:15:21 -0300 |
| commit | 1d54a3d3220706acfe704a0c1d6cda47cc0df43d (patch) | |
| tree | c253dd23543dc6082ec72b52152214e466121c45 | |
| parent | 7e9bf9e6e85c6c6e7a400d4fa0b43b77133ed3cb (diff) | |
| download | computeranim-1d54a3d3220706acfe704a0c1d6cda47cc0df43d.tar.gz computeranim-1d54a3d3220706acfe704a0c1d6cda47cc0df43d.zip | |
build: the pass and the agent to preload are named lazy paths; canim uses them
A package that depends on ztrace no longer repeats the plugin's recipe or
searches the install step for the shared agent.
| -rw-r--r-- | anim/build.zig | 15 | ||||
| -rw-r--r-- | build/agent.zig | 3 | ||||
| -rw-r--r-- | build/llvm.zig | 2 |
3 files changed, 9 insertions, 11 deletions
diff --git a/anim/build.zig b/anim/build.zig index f410fb9..b693919 100644 --- a/anim/build.zig +++ b/anim/build.zig @@ -43,16 +43,9 @@ pub fn build(b: *std.Build) void { const embedded = b.addWriteFiles(); var table: std.ArrayList(u8) = .empty; - // The pass as ztrace's own build makes it. - // shortcut: its recipe is repeated here; the root package should name the plugin (`addNamedLazyPath`). - const cxx = b.addSystemCommand(&.{ "sh", "-c", "exec clang++ -shared -fPIC -O2 -fno-rtti $(llvm-config --cxxflags) \"$0\" -o \"$1\"" }); - cxx.addFileArg(zt.path("llvm/pass.cpp")); - const plugin = cxx.addOutputFileArg("ztrace-pass.so"); - // The agent to preload: of the two artifacts of that name, the shared one. - const agent = for (zt.builder.install_tls.step.dependencies.items) |step| { - const installed = step.cast(std.Build.Step.InstallArtifact) orelse continue; - if (std.mem.eql(u8, installed.artifact.name, "ztrace-agent") and installed.artifact.isDynamicLibrary()) break installed.artifact; - } else @panic("ztrace has no shared libztrace-agent"); + // The pass and the agent to preload, as ztrace's own build makes and names them. + const plugin = zt.namedLazyPath("ztrace-pass"); + const agent = zt.namedLazyPath("ztrace-agent"); const musl = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl }); const Recording = struct { @@ -108,7 +101,7 @@ pub fn build(b: *std.Build) void { if (r.instr != null) run.addArg("--ring"); if (r.alloc) { run.addArgs(&.{ "--alloc", "--preload" }); - run.addArtifactArg(agent); + run.addFileArg(agent); } run.addArg("-o"); const trace = run.addOutputFileArg(b.fmt("{s}.ztrace", .{r.name})); diff --git a/build/agent.zig b/build/agent.zig index d02880a..507171f 100644 --- a/build/agent.zig +++ b/build/agent.zig @@ -32,6 +32,9 @@ pub fn add(ctx: Ctx) *Compile { b.installArtifact(lib.*); } b.getInstallStep().dependOn(&b.addInstallHeaderFile(b.path("include/ztrace.h"), "ztrace.h").step); + // For a package that depends on this one: the library to preload, by a + // name of its own (two artifacts are called ztrace-agent). + b.addNamedLazyPath("ztrace-agent", libs[0].getEmittedBin()); const t: Tests = .{ .ctx = ctx, diff --git a/build/llvm.zig b/build/llvm.zig index b346f13..94b7501 100644 --- a/build/llvm.zig +++ b/build/llvm.zig @@ -24,6 +24,8 @@ pub fn add(ctx: Ctx) std.Build.LazyPath { cxx.addFileArg(b.path("llvm/pass.cpp")); const plugin = cxx.addOutputFileArg("ztrace-pass.so"); b.getInstallStep().dependOn(&b.addInstallLibFile(plugin, "ztrace-pass.so").step); + // For a package that depends on this one: `dependency.namedLazyPath("ztrace-pass")`. + b.addNamedLazyPath("ztrace-pass", plugin); // For whoever draws values: the parser of type descriptions. const types = b.addModule("ztrace-types", .{ .root_source_file = b.path("src/instr/types.zig"), .target = ctx.target, .optimize = ctx.optimize }); |
