summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-03-05 13:00:01 -0300
committerGabriel Schneider <[email protected]>2026-06-08 23:04:50 -0300
commit80ba1db819a80e784a488d6d660a890e14b19282 (patch)
treeda005b5161094f24349c56acd149e4e89876410d /build.zig
parent70388a8fc6770c797c6f298886e90c982b2c721f (diff)
downloadcodenomicon-80ba1db819a80e784a488d6d660a890e14b19282.tar.gz
codenomicon-80ba1db819a80e784a488d6d660a890e14b19282.zip
simple shock
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig39
1 files changed, 35 insertions, 4 deletions
diff --git a/build.zig b/build.zig
index 36e5b53..08789c7 100644
--- a/build.zig
+++ b/build.zig
@@ -23,6 +23,16 @@ pub fn build(b: *std.Build) !void {
}),
});
+ const shock = b.addExecutable(.{
+ .name = "shock",
+ .root_module = b.createModule(.{
+ .root_source_file = b.path("src/shock.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ }),
+ });
+
const capstone_lib = capstone(b, .{
.optimize = optimize,
.target = target,
@@ -50,9 +60,9 @@ pub fn build(b: *std.Build) !void {
b.installArtifact(elfo);
b.installArtifact(gloves);
- const gdb_opt = b.option(bool, "gdb", "Run executable under gdb") orelse false;
+ const opt_gdb = b.option(bool, "gdb", "Run executable under gdb") orelse false;
const comp_opts = b.addOptions();
- comp_opts.addOption(bool, "gdb", gdb_opt);
+ comp_opts.addOption(bool, "gdb", opt_gdb);
const unit_tests = b.addTest(.{
.root_module = b.createModule(.{
@@ -62,23 +72,44 @@ pub fn build(b: *std.Build) !void {
}),
});
- const test_step = b.step("test", "Test the library");
+ // Looooopy
+ const gcc_test = b.addSystemCommand(&.{"gcc"});
+ gcc_test.addFileArg(b.path("tests/c/hello-world.c"));
+ gcc_test.addArg("-o");
+ const gcc_hello_file = gcc_test.addOutputFileArg("hello-world");
+
+ const runner = b.addRunArtifact(shock);
+ runner.addFileArg(gcc_hello_file);
+ runner.addFileArg(gcc_hello_file);
+
+ const loop_step = b.step("loop", "Interative Programming Loop! you should run it with watch: i.e. zig build loop --watch");
+ loop_step.dependOn(&runner.step);
+ // ---
+ const test_step = b.step("test", "Run unit tests");
const run_elfo_step = b.step("elfo", "See the pretty elfo!");
+ const run_shock_step = b.step("shock", "SHOCK something!");
const run_gloves_step = b.step("gloves", "See the pretty gloves!");
+ const zls_check = b.step("check", "Check if the program compiles");
+ zls_check.dependOn(&elfo.step);
+ zls_check.dependOn(&shock.step);
+ zls_check.dependOn(&unit_tests.step);
+
const run_steps = [_]struct { *std.Build.Step, *std.Build.Step.Compile }{
.{ test_step, unit_tests },
.{ run_elfo_step, elfo },
.{ run_gloves_step, gloves },
+ .{ run_shock_step, shock },
};
+
const gdbscript = b.addWriteFile("gdbscript",
\\r
);
for (run_steps) |run| {
run.@"1".root_module.addOptions("meta", comp_opts);
- if (gdb_opt) {
+ if (opt_gdb) {
const run_gdb = b.addSystemCommand(&.{"gdb"});
run_gdb.addArg("-x");
run_gdb.addFileArg(gdbscript.getDirectory().path(b, "gdbscript"));