#addSystemCommand not executing as expected

1 messages · Page 1 of 1 (latest)

humble meadow
#
const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.resolveTargetQuery(.{
        .cpu_arch = std.Target.Cpu.Arch.riscv64,
        .os_tag = std.Target.Os.Tag.freestanding,
        .abi = std.Target.Abi.none,
    });

    const main_build_output = b.addExecutable(.{
        .name = "test",
        .root_source_file = b.path("src/main.zig"),
        .target = target,
    });

    main_build_output.setLinkerScript(.{ .src_path = .{ .sub_path = "linker.lds", .owner = b } });
    main_build_output.addAssemblyFile(.{ .src_path = .{ .sub_path = "boot.s", .owner = b } });

    b.installArtifact(main_build_output);

    const run_with_qemu = b.addSystemCommand(&.{"/usr/bin/qemu-system-riscv64 -machine virt -cpu rv64 -m 128M -nographic -serial mon:stdio -bios none -kernel /home/charles/projects/zigrtos/zig-out/bin/test"});

    const run_step = b.step("run", "Run the application");
    run_step.dependOn(&run_with_qemu.step);
}

error: unable to spawn /usr/bin/qemu-system-riscv64 -machine virt -cpu rv64 -m 128M -nographic -serial mon:stdio -bios none -kernel /home/charles/projects/zigrtos/zig-out/bin/test: FileNotFound

I run that command directly and it works fine.

neat plume
#

try

    const run_with_qemu = b.addSystemCommand(&.{
        "/usr/bin/qemu-system-riscv64",
        "-machine",
        "virt",
        "-cpu",
        "rv64",
        "-m",
        "128M",
        "-nographic",
        "-serial",
        "mon:stdio",
        "-bios",
        "none",
        "-kernel",
    });

    run_with_qemu.addFileArg(main_build_output.getEmittedBin());
humble meadow
#

i was just about to update that i did exactly that and it worked

#

previously i had tried to use addArgs but still paired arguments into single strings:

"-machine virt"