diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-02-01 12:47:35 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-02-01 12:47:35 +0100 |
| commit | 85bcada8cf78bdf2bfb3be583289686026e0f25e (patch) | |
| tree | 0ce404c4840432db9b6d3addd3947a736d103382 /build.zig | |
| parent | 2ce14aec655589f00442ab469b9d877a143eeefd (diff) | |
screen: start drm implementation
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 73 |
1 files changed, 53 insertions, 20 deletions
@@ -1,39 +1,72 @@ const std = @import("std"); +const Program = struct { + name: []const u8, + qemu: bool, +}; + +const programs = [_]Program { + .{ .name = "shell", .qemu = false }, + .{ .name = "screen", .qemu = true }, +}; + pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const pkg = b.dependency("eostre", .{ - .target = target, - .optimize = optimize, + const estd = b.createModule(.{ + .root_source_file = b.path("src/estd/root.zig"), }); - const exe = b.addExecutable(.{ - .name = "shell", - .root_source_file = b.path("src/main.zig"), + const init_exe = b.addExecutable(.{ + .name = "init", + .root_source_file = b.path("src/init/main.zig"), .target = target, - .optimize = optimize + .optimize = optimize, }); + init_exe.root_module.addImport("estd", estd); + + const test_step = b.step("test", "Run tests"); - const run_exe = b.addRunArtifact(exe); - const run_step = b.step("run", "Run the application"); - run_step.dependOn(&run_exe.step); + inline for (programs) |program| { + const path = b.path("src/" ++ program.name ++ "/main.zig"); - exe.root_module.addImport("eostre", pkg.module("eostre")); + const exe = b.addExecutable(.{ + .name = program.name, + .root_source_file = path, + .target = target, + .optimize = optimize + }); + exe.root_module.addImport("estd", estd); + b.installArtifact(exe); - const test_step = b.step("test", "Run unit tests"); + const run = b.step("run-" ++ program.name, "Run " ++ program.name); + + if (program.qemu) { + const run_qemu = b.addSystemCommand(&.{ "./build/run-qemu" }); + run_qemu.addFileArg(init_exe.getEmittedBin()); + run_qemu.addFileArg(exe.getEmittedBin()); + run_qemu.step.dependOn(&exe.step); + run_qemu.step.dependOn(&init_exe.step); + run.dependOn(&run_qemu.step); + } else { + const run_artifact = b.addRunArtifact(exe); + run.dependOn(&run_artifact.step); + } + + const tests = b.addTest(.{ + .name = program.name, + .root_source_file = path, + }); + tests.root_module.addImport("estd", estd); + const run_tests = b.addRunArtifact(tests); + test_step.dependOn(&run_tests.step); + } const tests = b.addTest(.{ - .name = "shell", - .root_source_file = b.path("src/main.zig"), - .target = target, + .name = "estd", + .root_source_file = b.path("src/estd/root.zig"), }); - tests.root_module.addImport("eostre", pkg.module("eostre")); - const run_tests = b.addRunArtifact(tests); test_step.dependOn(&run_tests.step); - - const lib_tests = b.addRunArtifact(pkg.artifact("eostre")); - test_step.dependOn(&lib_tests.step); } |