Add more build options.
This commit is contained in:
parent
40cc8ecd8b
commit
c3bdbe4911
15
build.zig
15
build.zig
|
@ -4,7 +4,20 @@ const Builder = @import("std").build.Builder;
|
||||||
pub fn build(b: *Builder) void {
|
pub fn build(b: *Builder) void {
|
||||||
const mode = b.standardReleaseOptions();
|
const mode = b.standardReleaseOptions();
|
||||||
const exe = b.addExecutable("zar", "src/main.zig");
|
const exe = b.addExecutable("zar", "src/main.zig");
|
||||||
exe.addBuildOption(bool, "terminal_version", false);
|
const disable_colour = b.option(
|
||||||
|
bool,
|
||||||
|
"disable_colour",
|
||||||
|
"no colour",
|
||||||
|
) orelse false;
|
||||||
|
const terminal_version = b.option(
|
||||||
|
bool,
|
||||||
|
"terminal_version",
|
||||||
|
"terminal-only version",
|
||||||
|
) orelse false;
|
||||||
|
exe.addBuildOption(bool, "terminal_version", terminal_version);
|
||||||
|
exe.addBuildOption(bool, "disable_colour", disable_colour);
|
||||||
|
|
||||||
|
exe.strip = true;
|
||||||
exe.addPackage(.{
|
exe.addPackage(.{
|
||||||
.name = "interfaces",
|
.name = "interfaces",
|
||||||
.path = "deps/interfaces/interface.zig",
|
.path = "deps/interfaces/interface.zig",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const eql = std.mem.eql;
|
const eql = std.mem.eql;
|
||||||
const terminal_version = @import("build_options").terminal_version;
|
const terminal_version = @import("build_options").terminal_version;
|
||||||
|
const disable_colour = @import("build_options").disable_colour;
|
||||||
|
|
||||||
const TextColour = "#D8DEE9";
|
const TextColour = "#D8DEE9";
|
||||||
const DarkerTextColour = "#E5E9F0";
|
const DarkerTextColour = "#E5E9F0";
|
||||||
|
@ -18,9 +19,9 @@ const TerminalResetColour = "\u{001b}[37m";
|
||||||
const TerminalTextColour = TerminalResetColour;
|
const TerminalTextColour = TerminalResetColour;
|
||||||
const TerminalDarkerTextColour = TerminalResetColour;
|
const TerminalDarkerTextColour = TerminalResetColour;
|
||||||
const TerminalDarkestTextColour = TerminalResetColour;
|
const TerminalDarkestTextColour = TerminalResetColour;
|
||||||
const TerminalAccentLightColour = "\u{001b}[38;5;26m";
|
const TerminalAccentLightColour = "\u{001b}[38;5;38m";
|
||||||
const TerminalAccentMediumColour = "\u{001b}[38;5;32m";
|
const TerminalAccentMediumColour = "\u{001b}[38;5;32m";
|
||||||
const TerminalAccentDarkColour = "\u{001b}[38;5;38m";
|
const TerminalAccentDarkColour = "\u{001b}[38;5;26m";
|
||||||
const TerminalRedColour = "\u{001b}[31m";
|
const TerminalRedColour = "\u{001b}[31m";
|
||||||
const TerminalOrangeColour = "\u{001b}[31;1m";
|
const TerminalOrangeColour = "\u{001b}[31;1m";
|
||||||
const TerminalYellowColour = "\u{001b}[33m";
|
const TerminalYellowColour = "\u{001b}[33m";
|
||||||
|
@ -28,6 +29,8 @@ const TerminalGreenColour = "\u{001b}[32m";
|
||||||
const TerminalPurpleColour = "\u{001b}[35m";
|
const TerminalPurpleColour = "\u{001b}[35m";
|
||||||
|
|
||||||
pub fn colour(alloc: *std.mem.Allocator, clr: []const u8, str: []const u8) ![]const u8 {
|
pub fn colour(alloc: *std.mem.Allocator, clr: []const u8, str: []const u8) ![]const u8 {
|
||||||
|
if (disable_colour) return str;
|
||||||
|
|
||||||
if (clr[0] == '#' or clr[0] == '\u{001b}') {
|
if (clr[0] == '#' or clr[0] == '\u{001b}') {
|
||||||
if (terminal_version) {
|
if (terminal_version) {
|
||||||
return try std.fmt.allocPrint(alloc, "{}{}" ++ TerminalResetColour, .{ clr, str });
|
return try std.fmt.allocPrint(alloc, "{}{}" ++ TerminalResetColour, .{ clr, str });
|
||||||
|
|
Loading…
Reference in a new issue