Skip to content

eliminate std.Build.CheckObjectStep.runAndCompare #14969

@andrewrk

Description

@andrewrk

Extracted from #14647.

/// Runs and (optionally) compares the output of a binary.
/// Asserts `self` was generated from an executable step.
/// TODO this doesn't actually compare, and there's no apparent reason for it
/// to depend on the check object step. I don't see why this function should exist,
/// the caller could just add the run step directly.
pub fn runAndCompare(self: *CheckObjectStep) *std.Build.RunStep {
const dependencies_len = self.step.dependencies.items.len;
assert(dependencies_len > 0);
const exe_step = self.step.dependencies.items[dependencies_len - 1];
const exe = exe_step.cast(std.Build.CompileStep).?;
const run = self.step.owner.addRunArtifact(exe);
run.skip_foreign_checks = true;
run.step.dependOn(&self.step);
return run;
}

[nix-shell:~/dev/zig/build-release]$ grep -RI runAndCompare ../test/
../test/link/macho/weak_library/build.zig:    const run_cmd = check.runAndCompare();
../test/link/macho/entry/build.zig:    const run = check_exe.runAndCompare();
../test/link/macho/dylib/build.zig:    const run = check_exe.runAndCompare();
../test/link/macho/strict_validation/build.zig:    const run = check_exe.runAndCompare();
../test/link/macho/unwind_info/build.zig:    const run_cmd = check.runAndCompare();
../test/link/macho/stack_size/build.zig:    const run = check_exe.runAndCompare();
../test/link/macho/needed_library/build.zig:    const run_cmd = check.runAndCompare();
../test/link/macho/search_strategy/build.zig:        const run = check.runAndCompare();
../test/link/macho/dead_strip/build.zig:        const run_cmd = check.runAndCompare();
../test/link/macho/dead_strip/build.zig:        const run_cmd = check.runAndCompare();

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingImplementing this issue could cause existing code to no longer compile or have different behavior.contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions