diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -406,16 +406,20 @@ pub const App = struct { cwd: ?Build.LazyPath = null, }; - /// Plays a script headless against `exe` (from `addExecutable`), with a - /// throwaway state file. Fails when an expectation does. - pub fn addScript(app: App, exe: *Build.Step.Compile, script: Build.LazyPath, options: ScriptOptions) *Build.Step.Run { + /// Plays a script headless, with a throwaway state file, against + /// `artifact`: the executable (`addExecutable`), or the hot-reloadable + /// library (`addLibrary`) through the generic host, which scripts can + /// `reload`. Fails when an expectation or a console line does. + pub fn addScript(app: App, artifact: *Build.Step.Compile, script: Build.LazyPath, options: ScriptOptions) *Build.Step.Run { const b = app.sb.b; - const run = b.addRunArtifact(exe); + const library = artifact.isDynamicLibrary(); + const run = b.addRunArtifact(if (library) app.sb.host_exe else artifact); run.addArgs(&.{ "--headless", "--fresh", "--script" }); run.addFileArg(script); run.addArg("--state"); _ = run.addOutputFileArg(b.fmt("{s}.state", .{app.name})); for (options.defines) |pair| run.addArgs(&.{ "--define", b.fmt("{s}={s}", .{ pair[0], pair[1] }) }); + if (library) run.addArtifactArg(artifact); run.setCwd(options.cwd orelse b.path(".")); run.expectExitCode(0); run.has_side_effects = true; |
