Something went wrong. Try again.
A general purpose .. programming language written in zig ijadux2.tngl.sh/Rinnescript
zig language
Something went wrong. Try again.
Rinnescript build.zig
2.4 kB · 69 lines
Zig
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970const std = @import("std");
pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const mod = b.addModule("rinne", .{ .root_source_file = b.path("src/root.zig"), .target = target, .link_libc = true, });
const exe = b.addExecutable(.{ .name = "rinne", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "rinne", .module = mod }, }, }), });
b.installArtifact(exe);
// Deploy the freshly built binary to $BIN (default ~/.local/bin) so a // plain `zig build` puts a current `rinne` on PATH immediately (e.g. the // LSP backend used by editors). Env is expanded by the shell, avoiding a // libc/fs dependency in build.zig. Override with -Dbin=/path/to/dir, or // set $BIN; `install` also creates the target dir when needed. const bin_dir = b.option([]const u8, "bin", "Bin directory to deploy rinne to (overrides $BIN)"); // Command string: `install -m755 "$1" "$dest"` where dest honors a // -Dbin override, otherwise $BIN, otherwise ~/.local/bin. const dest = if (bin_dir) |d| b.fmt("install -m755 \"$1\" \"{s}\"", .{d}) else "install -m755 \"$1\" \"${BIN:-$HOME/.local/bin}\""; const deploy = b.addSystemCommand(&.{ "sh", "-c", dest, "deploy" }); deploy.addFileArg(exe.getEmittedBin()); const deploy_step = b.step("install.bin", "Copy rinne binary to $BIN (default ~/.local/bin)"); deploy_step.dependOn(&deploy.step); b.getInstallStep().dependOn(&deploy.step);
const run_step = b.step("run", "Run the app");
const run_cmd = b.addRunArtifact(exe); run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| { run_cmd.addArgs(args); }
const mod_tests = b.addTest(.{ .root_module = mod, });
const run_mod_tests = b.addRunArtifact(mod_tests); const exe_tests = b.addTest(.{ .root_module = exe.root_module, });
const run_exe_tests = b.addRunArtifact(exe_tests); const test_step = b.step("test", "Run tests"); test_step.dependOn(&run_mod_tests.step); test_step.dependOn(&run_exe_tests.step);}