const std = @import("std"); fn capstone(b: *std.Build, options: struct { target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, }) struct { dep: *std.Build.Dependency, artifact: *std.Build.Step.Compile, mod: *std.Build.Module, } { const capstone_dep = b.dependency("capstone", .{ .target = options.target, .optimize = options.optimize, }); const compiled_capstone = capstone_dep.artifact("capstone"); // I don't really know what I'm doing here, but it works const capstone_c = b.addTranslateC(.{ .root_source_file = b.path("deps/tmp/capstone-6.0.0-Alpha4/include/capstone/capstone.h"), // .root_source_file = capstone_dep.path("capstone.h"), .target = options.target, .optimize = options.optimize, .link_libc = true, }); const capstone_c_mod = capstone_c.createModule(); return .{ .dep = capstone_dep, .artifact = compiled_capstone, .mod = capstone_c_mod, }; } pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const elfo_module = b.createModule(.{ .root_source_file = b.path("src/elfo-pretty.zig"), .target = target, .optimize = optimize, }); const cs = capstone(b, .{ .target = target, .optimize = optimize, }); elfo_module.addImport("capstone", cs.mod); elfo_module.addLibraryPath(cs.artifact.getEmittedBin().dirname()); elfo_module.linkLibrary(cs.artifact); elfo_module.addIncludePath(cs.artifact.getEmittedIncludeTree()); const elfo = b.addExecutable(.{ .name = "elfo-pretty", .root_module = elfo_module, }); elfo.linkLibrary(cs.artifact); b.installArtifact(elfo); const run_cmd = b.addRunArtifact(elfo); const run_step = b.step("elfo", "See the pretty elfo!"); run_step.dependOn(&run_cmd.step); // TODO: add flag to run on pwndbg }