Dataset Viewer
Auto-converted to Parquet Duplicate
avatar_url
stringlengths
46
53
name
stringlengths
2
33
full_name
stringlengths
8
45
created_at
stringdate
2018-01-12 15:05:58
2025-05-18 21:51:14
description
stringlengths
7
327
default_branch
stringclasses
11 values
open_issues
int64
0
156
stargazers_count
int64
0
3.96k
forks_count
int64
0
182
watchers_count
int64
0
3.96k
tags_url
stringlengths
42
79
license
stringclasses
20 values
topics
sequencelengths
0
18
size
int64
0
760k
fork
bool
2 classes
updated_at
stringdate
2021-04-12 07:17:39
2025-05-22 07:54:00
has_build_zig
bool
2 classes
has_build_zig_zon
bool
2 classes
zig_minimum_version
stringclasses
35 values
repo_from
stringclasses
1 value
dependencies
listlengths
0
121
readme_content
stringlengths
3
96.8k
dependents
sequencelengths
0
21
https://avatars.githubusercontent.com/u/3759175?v=4
zig-clap
Hejsil/zig-clap
2018-03-14T13:06:16Z
Command line argument parsing library
master
9
1,240
75
1,240
https://api.github.com/repos/Hejsil/zig-clap/tags
MIT
[ "argument-parser", "argument-parsing", "command-line", "command-line-parser", "parsed-arguments", "zig-package", "ziglang" ]
456
false
2025-05-21T11:29:52Z
true
true
0.14.0
github
[]
zig-clap A simple and easy to use command line argument parser library for Zig. Installation Developers tend to either use * The latest tagged release of Zig * The latest build of Zigs master branch Depending on which developer you are, you need to run different <code>zig fetch</code> commands: ```sh Version of zig-clap that works with a tagged release of Zig Replace <code>&lt;REPLACE ME&gt;</code> with the version of zig-clap that you want to use See: https://github.com/Hejsil/zig-clap/releases zig fetch --save https://github.com/Hejsil/zig-clap/archive/refs/tags/.tar.gz Version of zig-clap that works with latest build of Zigs master branch zig fetch --save git+https://github.com/Hejsil/zig-clap ``` Then add the following to <code>build.zig</code>: <code>zig const clap = b.dependency("clap", .{}); exe.root_module.addImport("clap", clap.module("clap"));</code> Features <ul> <li>Short arguments <code>-a</code></li> <li>Chaining <code>-abc</code> where <code>a</code> and <code>b</code> does not take values.</li> <li>Multiple specifications are tallied (e.g. <code>-v -v</code>).</li> <li>Long arguments <code>--long</code></li> <li>Supports both passing values using spacing and <code>=</code> (<code>-a 100</code>, <code>-a=100</code>)</li> <li>Short args also support passing values with no spacing or <code>=</code> (<code>-a100</code>)</li> <li>This all works with chaining (<code>-ba 100</code>, <code>-ba=100</code>, <code>-ba100</code>)</li> <li>Supports options that can be specified multiple times (<code>-e 1 -e 2 -e 3</code>)</li> <li>Print help message from parameter specification.</li> <li>Parse help message to parameter specification.</li> </ul> API Reference Automatically generated API Reference for the project can be found at https://Hejsil.github.io/zig-clap. Note that Zig autodoc is in beta; the website may be broken or incomplete. Examples <code>clap.parse</code> The simplest way to use this library is to just call the <code>clap.parse</code> function. ```zig pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>// First we specify what parameters our program can take. // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`. const params = comptime clap.parseParamsComptime( \\-h, --help Display this help and exit. \\-n, --number &lt;usize&gt; An option parameter, which takes a value. \\-s, --string &lt;str&gt;... An option parameter which can be specified multiple times. \\&lt;str&gt;... \\ ); // Initialize our diagnostics, which can be used for reporting useful errors. // This is optional. You can also pass `.{}` to `clap.parse` if you don't // care about the extra information `Diagnostics` provides. var diag = clap.Diagnostic{}; var res = clap.parse(clap.Help, &amp;params, clap.parsers.default, .{ .diagnostic = &amp;diag, .allocator = gpa.allocator(), }) catch |err| { // Report useful error and exit. diag.report(std.io.getStdErr().writer(), err) catch {}; return err; }; defer res.deinit(); if (res.args.help != 0) std.debug.print("--help\n", .{}); if (res.args.number) |n| std.debug.print("--number = {}\n", .{n}); for (res.args.string) |s| std.debug.print("--string = {s}\n", .{s}); for (res.positionals[0]) |pos| std.debug.print("{s}\n", .{pos}); </code> } const clap = @import("clap"); const std = @import("std"); ``` The result will contain an <code>args</code> field and a <code>positionals</code> field. <code>args</code> will have one field for each non-positional parameter of your program. The name of the field will be the longest name of the parameter. <code>positionals</code> will be a tuple with one field for each positional parameter. The fields in <code>args</code> and <code>postionals</code> are typed. The type is based on the name of the value the parameter takes. Since <code>--number</code> takes a <code>usize</code> the field <code>res.args.number</code> has the type <code>usize</code>. Note that this is only the case because <code>clap.parsers.default</code> has a field called <code>usize</code> which contains a parser that returns <code>usize</code>. You can pass in something other than <code>clap.parsers.default</code> if you want some other mapping. ```zig pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>// First we specify what parameters our program can take. // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`. const params = comptime clap.parseParamsComptime( \\-h, --help Display this help and exit. \\-n, --number &lt;INT&gt; An option parameter, which takes a value. \\-a, --answer &lt;ANSWER&gt; An option parameter which takes an enum. \\-s, --string &lt;STR&gt;... An option parameter which can be specified multiple times. \\&lt;FILE&gt;... \\ ); // Declare our own parsers which are used to map the argument strings to other // types. const YesNo = enum { yes, no }; const parsers = comptime .{ .STR = clap.parsers.string, .FILE = clap.parsers.string, .INT = clap.parsers.int(usize, 10), .ANSWER = clap.parsers.enumeration(YesNo), }; var diag = clap.Diagnostic{}; var res = clap.parse(clap.Help, &amp;params, parsers, .{ .diagnostic = &amp;diag, .allocator = gpa.allocator(), // The assignment separator can be configured. `--number=1` and `--number:1` is now // allowed. .assignment_separators = "=:", }) catch |err| { diag.report(std.io.getStdErr().writer(), err) catch {}; return err; }; defer res.deinit(); if (res.args.help != 0) std.debug.print("--help\n", .{}); if (res.args.number) |n| std.debug.print("--number = {}\n", .{n}); if (res.args.answer) |a| std.debug.print("--answer = {s}\n", .{@tagName(a)}); for (res.args.string) |s| std.debug.print("--string = {s}\n", .{s}); for (res.positionals[0]) |pos| std.debug.print("{s}\n", .{pos}); </code> } const clap = @import("clap"); const std = @import("std"); ``` Subcommands There is an option for <code>clap.parse</code> and <code>clap.parseEx</code> called <code>terminating_positional</code>. It allows for users of <code>clap</code> to implement subcommands in their cli application: ```zig // These are our subcommands. const SubCommands = enum { help, math, }; const main_parsers = .{ .command = clap.parsers.enumeration(SubCommands), }; // The parameters for <code>main</code>. Parameters for the subcommands are specified further down. const main_params = clap.parseParamsComptime( \-h, --help Display this help and exit. \ \ ); // To pass around arguments returned by clap, <code>clap.Result</code> and <code>clap.ResultEx</code> can be used to // get the return type of <code>clap.parse</code> and <code>clap.parseEx</code>. const MainArgs = clap.ResultEx(clap.Help, &amp;main_params, main_parsers); pub fn main() !void { var gpa_state = std.heap.GeneralPurposeAllocator(.{}){}; const gpa = gpa_state.allocator(); defer _ = gpa_state.deinit(); <code>var iter = try std.process.ArgIterator.initWithAllocator(gpa); defer iter.deinit(); _ = iter.next(); var diag = clap.Diagnostic{}; var res = clap.parseEx(clap.Help, &amp;main_params, main_parsers, &amp;iter, .{ .diagnostic = &amp;diag, .allocator = gpa, // Terminate the parsing of arguments after parsing the first positional (0 is passed // here because parsed positionals are, like slices and arrays, indexed starting at 0). // // This will terminate the parsing after parsing the subcommand enum and leave `iter` // not fully consumed. It can then be reused to parse the arguments for subcommands. .terminating_positional = 0, }) catch |err| { diag.report(std.io.getStdErr().writer(), err) catch {}; return err; }; defer res.deinit(); if (res.args.help != 0) std.debug.print("--help\n", .{}); const command = res.positionals[0] orelse return error.MissingCommand; switch (command) { .help =&gt; std.debug.print("--help\n", .{}), .math =&gt; try mathMain(gpa, &amp;iter, res), } </code> } fn mathMain(gpa: std.mem.Allocator, iter: *std.process.ArgIterator, main_args: MainArgs) !void { // The parent arguments are not used here, but there are cases where it might be useful, so // this example shows how to pass the arguments around. _ = main_args; <code>// The parameters for the subcommand. const params = comptime clap.parseParamsComptime( \\-h, --help Display this help and exit. \\-a, --add Add the two numbers \\-s, --sub Subtract the two numbers \\&lt;isize&gt; \\&lt;isize&gt; \\ ); // Here we pass the partially parsed argument iterator. var diag = clap.Diagnostic{}; var res = clap.parseEx(clap.Help, &amp;params, clap.parsers.default, iter, .{ .diagnostic = &amp;diag, .allocator = gpa, }) catch |err| { diag.report(std.io.getStdErr().writer(), err) catch {}; return err; }; defer res.deinit(); const a = res.positionals[0] orelse return error.MissingArg1; const b = res.positionals[1] orelse return error.MissingArg1; if (res.args.help != 0) std.debug.print("--help\n", .{}); if (res.args.add != 0) std.debug.print("added: {}\n", .{a + b}); if (res.args.sub != 0) std.debug.print("subtracted: {}\n", .{a - b}); </code> } const clap = @import("clap"); const std = @import("std"); ``` <code>streaming.Clap</code> The <code>streaming.Clap</code> is the base of all the other parsers. It's a streaming parser that uses an <code>args.Iterator</code> to provide it with arguments lazily. ```zig pub fn main() !void { const allocator = std.heap.page_allocator; <code>// First we specify what parameters our program can take. const params = [_]clap.Param(u8){ .{ .id = 'h', .names = .{ .short = 'h', .long = "help" }, }, .{ .id = 'n', .names = .{ .short = 'n', .long = "number" }, .takes_value = .one, }, .{ .id = 'f', .takes_value = .one }, }; var iter = try std.process.ArgIterator.initWithAllocator(allocator); defer iter.deinit(); // Skip exe argument. _ = iter.next(); // Initialize our diagnostics, which can be used for reporting useful errors. // This is optional. You can also leave the `diagnostic` field unset if you // don't care about the extra information `Diagnostic` provides. var diag = clap.Diagnostic{}; var parser = clap.streaming.Clap(u8, std.process.ArgIterator){ .params = &amp;params, .iter = &amp;iter, .diagnostic = &amp;diag, }; // Because we use a streaming parser, we have to consume each argument parsed individually. while (parser.next() catch |err| { // Report useful error and exit. diag.report(std.io.getStdErr().writer(), err) catch {}; return err; }) |arg| { // arg.param will point to the parameter which matched the argument. switch (arg.param.id) { 'h' =&gt; std.debug.print("Help!\n", .{}), 'n' =&gt; std.debug.print("--number = {s}\n", .{arg.value.?}), // arg.value == null, if arg.param.takes_value == .none. // Otherwise, arg.value is the value passed with the argument, such as "-a=10" // or "-a 10". 'f' =&gt; std.debug.print("{s}\n", .{arg.value.?}), else =&gt; unreachable, } } </code> } const clap = @import("clap"); const std = @import("std"); ``` Currently, this parser is the only parser that allows an array of <code>Param</code> that is generated at runtime. <code>help</code> <code>help</code> prints a simple list of all parameters the program can take. It expects the <code>Id</code> to have a <code>description</code> method and an <code>value</code> method so that it can provide that in the output. <code>HelpOptions</code> is passed to <code>help</code> to control how the help message is printed. ```zig pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>const params = comptime clap.parseParamsComptime( \\-h, --help Display this help and exit. \\-v, --version Output version information and exit. \\ ); var res = try clap.parse(clap.Help, &amp;params, clap.parsers.default, .{ .allocator = gpa.allocator(), }); defer res.deinit(); // `clap.help` is a function that can print a simple help message. It can print any `Param` // where `Id` has a `description` and `value` method (`Param(Help)` is one such parameter). // The last argument contains options as to how `help` should print those parameters. Using // `.{}` means the default options. if (res.args.help != 0) return clap.help(std.io.getStdErr().writer(), clap.Help, &amp;params, .{}); </code> } const clap = @import("clap"); const std = @import("std"); ``` ``` $ zig-out/bin/help --help -h, --help Display this help and exit. <code>-v, --version Output version information and exit. </code> ``` <code>usage</code> <code>usage</code> prints a small abbreviated version of the help message. It expects the <code>Id</code> to have a <code>value</code> method so it can provide that in the output. ```zig pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>const params = comptime clap.parseParamsComptime( \\-h, --help Display this help and exit. \\-v, --version Output version information and exit. \\ --value &lt;str&gt; An option parameter, which takes a value. \\ ); var res = try clap.parse(clap.Help, &amp;params, clap.parsers.default, .{ .allocator = gpa.allocator(), }); defer res.deinit(); // `clap.usage` is a function that can print a simple help message. It can print any `Param` // where `Id` has a `value` method (`Param(Help)` is one such parameter). if (res.args.help != 0) return clap.usage(std.io.getStdErr().writer(), clap.Help, &amp;params); </code> } const clap = @import("clap"); const std = @import("std"); ``` <code>$ zig-out/bin/usage --help [-hv] [--value &lt;str&gt;]</code>
[ "https://github.com/paoda/bp-jit", "https://github.com/paoda/turbo", "https://github.com/paoda/zba" ]
https://avatars.githubusercontent.com/u/1699414?v=4
sokol-zig
floooh/sokol-zig
2018-05-31T17:10:41Z
Zig bindings for the sokol headers (https://github.com/floooh/sokol)
master
10
513
66
513
https://api.github.com/repos/floooh/sokol-zig/tags
Zlib
[ "crossplatform", "sokol", "zig", "zig-package" ]
3,194
false
2025-05-21T16:08:15Z
true
true
0.14.0
github
[ { "commit": "4.0.3", "name": "emsdk", "tar_url": "https://github.com/emscripten-core/emsdk/archive/4.0.3.tar.gz", "type": "remote", "url": "https://github.com/emscripten-core/emsdk" }, { "commit": "9b5a3e2b57fe9783ba4d1f3249059bc4720b592f", "name": "shdc", "tar_url": "https://git...
<a></a><a></a> Auto-generated Zig bindings for the <a>sokol headers</a>. <a>Auto-generated docs</a> (wip) For Zig version 0.14.0+ In case of breaking changes in Zig, the bindings might fall behind. Please don't hesitate to ping me via a Github issue, or even better, provide a PR :) Support for stable Zig versions is in branches (e.g. <code>zig-0.12.0</code>), those versions are 'frozen in time' though. Related projects: <ul> <li><a>pacman.zig</a></li> <li><a>chipz emulators</a></li> <li><a>Dear ImGui sample project</a></li> </ul> Building the samples Supported platforms are: Windows, macOS, Linux (with X11) and web On Linux install the following packages: libglu1-mesa-dev, mesa-common-dev, xorg-dev, libasound-dev (or generally: the dev packages required for X11, GL and ALSA development) To build the platform-native samples: ```sh build all examples: zig build examples build and run individual examples zig build run-clear zig build run-triangle zig build run-quad zig build run-bufferoffsets zig build run-cube zig build run-noninterleaved zig build run-texcube zig build run-offscreen zig build run-instancing zig build run-mrt zig build run-saudio zig build run-sgl zig build run-sgl-context zig build run-sgl-points zig build run-debugtext zig build run-debugtext-print zig build run-debugtext-userfont zig build run-shapes ``` (also run <code>zig build -l</code> to get a list of build targets) By default, the backend 3D API will be selected based on the target platform: <ul> <li>macOS: Metal</li> <li>Windows: D3D11</li> <li>Linux: GL</li> </ul> To force the GL backend on macOS or Windows, build with <code>-Dgl=true</code>: ``` <blockquote> zig build -Dgl=true run-clear ``` </blockquote> The <code>clear</code> sample prints the selected backend to the terminal: <code>sokol-zig ➤ zig build -Dgl=true run-clear Backend: .sokol.gfx.Backend.GLCORE33</code> For the web-samples, run: ```sh zig build examples -Dtarget=wasm32-emscripten or to build and run one of the samples zig build run-clear -Dtarget=wasm32-emscripten ... ``` When building with target <code>wasm32-emscripten</code> for the first time, the build script will install and activate the Emscripten SDK into the Zig package cache for the latest SDK version. There is currently no build system functionality to update or delete the Emscripten SDK after this first install. The current workaround is to delete the global Zig cache (run <code>zig env</code> to see where the Zig cache resides). Improving the Emscripten SDK integration with the Zig build system is planned for the future. How to integrate sokol-zig into your project Add a build.zig.zon file to your project which has at least a <code>.sokol</code> dependency: <code>zig .{ .name = "my_project", .version = "0.1.0", .paths = .{ "src", "build.zig", "build.zig.zon", }, .dependencies = .{ .sokol = .{ .url = "git+https://github.com/floooh/sokol-zig.git#[commit-hash]", .hash = "[content-hash]", }, }, }</code> The easiest way to populate or update the <code>sokol</code> dependency is to run this on the cmdline: <code>zig fetch --save=sokol git+https://github.com/floooh/sokol-zig.git</code> This will automatically use the latest sokol-zig commit. For a native-only project, a <code>build.zig</code> file looks entirely vanilla: ```zig const std = @import("std"); const Build = std.Build; const OptimizeMode = std.builtin.OptimizeMode; pub fn build(b: *Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const dep_sokol = b.dependency("sokol", .{ .target = target, .optimize = optimize, }); const hello = b.addExecutable(.{ .name = "hello", .target = target, .optimize = optimize, .root_source_file = b.path("src/hello.zig"), }); hello.root_module.addImport("sokol", dep_sokol.module("sokol")); b.installArtifact(hello); const run = b.addRunArtifact(hello); b.step("run", "Run hello").dependOn(&amp;run.step); } ``` If you also want to run on the web via <code>-Dtarget=wasm32-emscripten</code>, the web platform build must look special, because Emscripten must be used for linking, and to run the build result in a browser, a special run step must be created. Such a 'hybrid' build script might look like this (copied straight from <a>pacman.zig</a>): ```zig const std = @import("std"); const Build = std.Build; const OptimizeMode = std.builtin.OptimizeMode; const sokol = @import("sokol"); pub fn build(b: *Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const dep_sokol = b.dependency("sokol", .{ .target = target, .optimize = optimize, }); <code>// special case handling for native vs web build if (target.result.cpu.arch.isWasm()) { try buildWeb(b, target, optimize, dep_sokol); } else { try buildNative(b, target, optimize, dep_sokol); } </code> } // this is the regular build for all native platforms, nothing surprising here fn buildNative(b: <em>Build, target: Build.ResolvedTarget, optimize: OptimizeMode, dep_sokol: </em>Build.Dependency) !void { const pacman = b.addExecutable(.{ .name = "pacman", .target = target, .optimize = optimize, .root_source_file = b.path("src/pacman.zig"), }); pacman.root_module.addImport("sokol", dep_sokol.module("sokol")); b.installArtifact(pacman); const run = b.addRunArtifact(pacman); b.step("run", "Run pacman").dependOn(&amp;run.step); } // for web builds, the Zig code needs to be built into a library and linked with the Emscripten linker fn buildWeb(b: <em>Build, target: Build.ResolvedTarget, optimize: OptimizeMode, dep_sokol: </em>Build.Dependency) !void { const pacman = b.addStaticLibrary(.{ .name = "pacman", .target = target, .optimize = optimize, .root_source_file = b.path("src/pacman.zig"), }); pacman.root_module.addImport("sokol", dep_sokol.module("sokol")); <code>// create a build step which invokes the Emscripten linker const emsdk = dep_sokol.builder.dependency("emsdk", .{}); const link_step = try sokol.emLinkStep(b, .{ .lib_main = pacman, .target = target, .optimize = optimize, .emsdk = emsdk, .use_webgl2 = true, .use_emmalloc = true, .use_filesystem = false, .shell_file_path = dep_sokol.path("src/sokol/web/shell.html"), }); // attach Emscripten linker output to default install step b.getInstallStep().dependOn(&amp;link_step.step); // ...and a special run step to start the web build output via 'emrun' const run = sokol.emRunStep(b, .{ .name = "pacman", .emsdk = emsdk }); run.step.dependOn(&amp;link_step.step); b.step("run", "Run pacman").dependOn(&amp;run.step); </code> } ``` Using sokol headers in C code The sokol-zig build.zig exposes a C library artifact called <code>sokol_clib</code>. You can lookup the build step for this library via: <code>zig const dep_sokol = b.dependency("sokol", .{ .target = target, .optimize = optimize, }); const sokol_clib = dep_sokol.artifact("sokol_clib");</code> ...once you have that library artifact, 'link' it to your compile step which contains your own C code: <code>zig const my_clib = ...; my_clib.linkLibrary(sokol_clib);</code> This makes the Sokol C headers available to your C code in a <code>sokol/</code> subdirectory: ```c include "sokol/sokol_app.h" include "sokol/sokol_gfx.h" // etc... ``` Keep in mind that the implementation is already provided in the <code>sokol_clib</code> static link library (e.g. don't try to build the Sokol implementations yourself via the <code>SOKOL_IMPL</code> macro). wasm32-emscripten caveats <ul> <li>Zig allocators use the <code>@returnAddress</code> builtin, which isn't supported in the Emscripten runtime out of the box (you'll get a runtime error in the browser's Javascript console looking like this: <code>Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER</code>. To link with <code>-sUSE_OFFSET_CONVERTER</code>, simply set the <code>.use_offset_converter</code> option in the Emscripten linker step in your build.zig:</li> </ul> <code>zig const link_step = try sokol.emLinkStep(b, .{ // ...other settings here .use_offset_converter = true, });</code> <ul> <li>the Zig stdlib only has limited support for the <code>wasm32-emscripten</code> target, for instance using <code>std.fs</code> functions will most likely fail to compile (the sokol-zig bindings might add more sokol headers in the future to fill some of the gaps)</li> </ul> Dear ImGui support The sokol-zig bindings come with sokol_imgui.h (exposed as the Zig package <code>sokol.imgui</code>), but integration into a project's build.zig requires some extra steps, mainly because I didn't want to add a <a>cimgui</a> dependency to the sokol-zig package (especially since cimgui uses git submodule which are not supported by the Zig package manager). The main steps to create Dear ImGui apps with sokol-zig are: <ol> <li>'bring your own cimgui'</li> <li>tell the sokol dependency that it needs to include sokol_imgui.h into the compiled C library: <code>zig const dep_sokol = b.dependency("sokol", .{ .target = target, .optimize = optimize, .with_sokol_imgui = true, });</code></li> <li> inject the path to the cimgui directory into the sokol dependency so that C compilation works (this needs to find the <code>cimgui.h</code> header) <code>zig dep_sokol.artifact("sokol_clib").addIncludePath(cimgui_root);</code> </li> </ol> Also see the following example project: https://github.com/floooh/sokol-zig-imgui-sample/
[]
https://avatars.githubusercontent.com/u/3759175?v=4
zig-bench
Hejsil/zig-bench
2018-12-05T09:26:06Z
Simple benchmarking library
master
2
64
8
64
https://api.github.com/repos/Hejsil/zig-bench/tags
MIT
[ "benchmarking", "zig", "zig-package" ]
41
false
2025-05-13T04:06:33Z
false
false
unknown
github
[]
zig-bench A simple benchmarking lib in Zig ``` Test [0/2] test "Debug benchmark"... Benchmark Iterations Min(ns) Max(ns) Variance Mean(ns) sum_slice(block=16) 100000 90 2690 243 107 sum_slice(block=32) 100000 170 1760 338 190 sum_slice(block=64) 100000 320 2340 476 352 sum_slice(block=128) 100000 630 2290 862 678 sum_slice(block=256) 100000 1270 3170 2402 1336 sum_slice(block=512) 100000 2550 8490 4835 2651 sum_reader(block=16) 100000 990 2640 1592 1039 sum_reader(block=32) 100000 1930 3890 3292 2012 sum_reader(block=64) 100000 3830 6250 6806 3962 sum_reader(block=128) 63673 7660 12830 15703 7852 sum_reader(block=256) 31967 15360 22190 31847 15641 sum_reader(block=512) 16031 30800 34690 59444 31191 Test [1/2] test "Debug benchmark generics"... Benchmark Iterations Min(ns) Max(ns) Variance Mean(ns) sum_vectors(vec4f16) 100000 2730 13390 3620 2775 sum_vectors(vec4f32) 100000 1289 5800 1277 1296 sum_vectors(vec4f64) 100000 1389 6870 1358 1400 sum_vectors(vec8f16) 100000 4400 9680 4613 4479 sum_vectors(vec8f32) 100000 1389 5180 1231 1400 sum_vectors(vec8f64) 100000 1390 6170 2260 1457 sum_vectors(vec16f16) 61088 8090 13980 15455 8184 sum_vectors(vec16f32) 100000 1399 4560 2069 1441 sum_vectors(vec16f64) 100000 1440 6080 1664 1475 All 2 tests passed. Test [0/2] test "ReleaseSafe benchmark"... Benchmark Iterations Min(ns) Max(ns) Variance Mean(ns) sum_slice(block=16) 100000 9 3550 164 18 sum_slice(block=32) 100000 9 940 22 18 sum_slice(block=64) 100000 49 1530 66 52 sum_slice(block=128) 100000 89 1280 102 92 sum_slice(block=256) 100000 169 1690 210 171 sum_slice(block=512) 100000 319 5530 724 329 sum_reader(block=16) 100000 60 2840 180 69 sum_reader(block=32) 100000 110 3059 288 121 sum_reader(block=64) 100000 209 2810 323 224 sum_reader(block=128) 100000 400 1780 387 431 sum_reader(block=256) 100000 790 2220 681 843 sum_reader(block=512) 100000 1550 4300 3805 1669 Test [1/2] test "ReleaseSafe benchmark generics"... Benchmark Iterations Min(ns) Max(ns) Variance Mean(ns) sum_vectors(vec4f16) 100000 1269 3790 1799 1283 sum_vectors(vec4f32) 100000 319 1680 300 328 sum_vectors(vec4f64) 100000 319 1860 355 329 sum_vectors(vec8f16) 100000 2399 5010 5014 2420 sum_vectors(vec8f32) 100000 319 2660 641 329 sum_vectors(vec8f64) 100000 319 7740 1019 330 sum_vectors(vec16f16) 100000 4599 9970 22580 4636 sum_vectors(vec16f32) 100000 319 4310 1231 330 sum_vectors(vec16f64) 100000 429 4070 1783 439 All 2 tests passed. Test [0/2] test "ReleaseFast benchmark"... Benchmark Iterations Min(ns) Max(ns) Variance Mean(ns) sum_slice(block=16) 100000 19 2840 128 21 sum_slice(block=32) 100000 19 1600 78 20 sum_slice(block=64) 100000 19 1970 74 21 sum_slice(block=128) 100000 19 1530 68 21 sum_slice(block=256) 100000 39 1250 74 44 sum_slice(block=512) 100000 59 1150 85 68 sum_reader(block=16) 100000 19 1170 21 20 sum_reader(block=32) 100000 19 1650 74 20 sum_reader(block=64) 100000 19 1250 34 20 sum_reader(block=128) 100000 19 1240 32 20 sum_reader(block=256) 100000 39 2180 177 44 sum_reader(block=512) 100000 59 2470 148 68 Test [1/2] test "ReleaseFast benchmark generics"... Benchmark Iterations Min(ns) Max(ns) Variance Mean(ns) sum_vectors(vec4f16) 100000 1259 8590 1678 1284 sum_vectors(vec4f32) 100000 319 1440 279 327 sum_vectors(vec4f64) 100000 319 1760 303 327 sum_vectors(vec8f16) 100000 2399 5260 1861 2417 sum_vectors(vec8f32) 100000 319 2080 434 327 sum_vectors(vec8f64) 100000 319 1710 329 328 sum_vectors(vec16f16) 100000 4599 9010 3883 4634 sum_vectors(vec16f32) 100000 319 2800 356 329 sum_vectors(vec16f64) 100000 429 1750 404 436 All 2 tests passed. Test [0/2] test "ReleaseSmall benchmark"... Benchmark Iterations Min(ns) Max(ns) Variance Mean(ns) sum_slice(block=16) 100000 19 2760 247 27 sum_slice(block=32) 100000 29 5090 363 37 sum_slice(block=64) 100000 50 2640 177 63 sum_slice(block=128) 100000 90 1830 157 102 sum_slice(block=256) 100000 169 5860 733 201 sum_slice(block=512) 100000 330 3690 1560 365 sum_reader(block=16) 100000 219 1430 276 226 sum_reader(block=32) 100000 420 1870 460 432 sum_reader(block=64) 100000 819 2690 770 837 sum_reader(block=128) 100000 1629 5390 1696 1649 sum_reader(block=256) 100000 3240 9080 3240 3274 sum_reader(block=512) 76638 6469 9780 5302 6524 Test [1/2] test "ReleaseSmall benchmark generics"... Benchmark Iterations Min(ns) Max(ns) Variance Mean(ns) sum_vectors(vec4f16) 100000 4859 16710 5250 4902 sum_vectors(vec4f32) 100000 319 1650 326 328 sum_vectors(vec4f64) 100000 319 1470 295 327 sum_vectors(vec8f16) 100000 3980 9070 3382 4254 sum_vectors(vec8f32) 100000 319 3740 459 328 sum_vectors(vec8f64) 100000 319 4100 534 330 sum_vectors(vec16f16) 79800 6219 15130 10000 6265 sum_vectors(vec16f32) 100000 319 3340 455 330 sum_vectors(vec16f64) 100000 429 2020 454 438 All 2 tests passed. ```
[]
https://avatars.githubusercontent.com/u/3759175?v=4
zig-midi
Hejsil/zig-midi
2018-08-17T09:04:10Z
null
master
1
35
3
35
https://api.github.com/repos/Hejsil/zig-midi/tags
MIT
[ "midi", "zig", "zig-library", "zig-package" ]
77
false
2025-05-04T08:50:05Z
true
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/3759175?v=4
zig-crc
Hejsil/zig-crc
2018-01-12T15:05:58Z
null
master
0
5
1
5
https://api.github.com/repos/Hejsil/zig-crc/tags
MIT
[ "crc", "zig", "zig-library", "zig-package" ]
37
false
2024-09-13T12:24:10Z
false
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/62312094?v=4
zigimg
zigimg/zigimg
2019-12-29T22:52:29Z
Zig library for reading and writing different image formats
master
43
607
100
607
https://api.github.com/repos/zigimg/zigimg/tags
MIT
[ "bitmap", "bmp", "image", "image-processing", "netpbm", "pcx", "png", "png-decoder", "zig", "zig-library", "zig-package" ]
1,100
false
2025-05-21T20:54:56Z
true
true
unknown
github
[]
Zig Image library This is a work in progress library to create, process, read and write different image formats with <a>Zig</a> programming language. <a></a> Install &amp; Build This library uses zig nominated <a>2024.11.0-mach</a>. To install using <a><code>zigup</code></a>: <code>sh zigup 0.14.0-dev.2577+271452d22</code> Use zigimg in your project How to add to your project: As a submodule <ol> <li>Clone this repository or add as a submodule</li> <li>Add to your <code>build.zig</code> <code>pub fn build(b: *std.Build) void { exe.root_module.addAnonymousModule("zigimg", .{ .root_source_file = b.path("zigimg.zig") }); }</code></li> </ol> Through the package manager <ol> <li>Run this command in your project folder to add <code>zigimg</code> to your <code>build.zig.zon</code></li> </ol> <code>sh zig fetch --save git+https://github.com/zigimg/zigimg.git</code> <ol> <li>Get the module in your <code>build.zig</code> file</li> </ol> ```zig const zigimg_dependency = b.dependency("zigimg", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("zigimg", zigimg_dependency.module("zigimg")); ``` After you are done setting up, you can look at the user guide below. Test suite To run the test suite, checkout the <a>test suite</a> and run <ol> <li>Checkout zigimg</li> <li>Go back one folder and checkout the <a>test suite</a> </li> <li>Run the tests with <code>zig build</code> <code>zig build test</code></li> </ol> Supported image formats | Image Format | Read | Write | | ------------- |:-------------:|:--------------:| | ANIM | ❌ | ❌ | | BMP | ✔️ (Partial) | ✔️ (Partial) | | Farbfeld | ✔️ | ✔️ | | GIF | ✔️ | ❌ | | ICO | ❌ | ❌ | | IFF | ✔️ | ❌ | | JPEG | ✔️ (Partial) | ❌ | | PAM | ✔️ | ✔️ | | PBM | ✔️ | ✔️ | | PCX | ✔️ | ✔️ | | PGM | ✔️ (Partial) | ✔️ (Partial) | | PNG | ✔️ | ✔️ (Partial) | | PPM | ✔️ (Partial) | ✔️ (Partial) | | QOI | ✔️ | ✔️ | | SGI | ✔️ | ❌ | | SUN | ✔️ | ❌ | | TGA | ✔️ | ✔️ | | TIFF | ✔️ (Partial) | ❌ | | XBM | ❌ | ❌ | | XPM | ❌ | ❌ | BMP - Bitmap <ul> <li>version 4 BMP</li> <li>version 5 BMP</li> <li>24-bit RGB read &amp; write</li> <li>32-bit RGBA read &amp; write</li> <li>Doesn't support any compression</li> </ul> GIF - Graphics Interchange Format <ul> <li>Support GIF87a and GIF89a</li> <li>Support animated GIF with Netscape application extension for looping information</li> <li>Supports interlaced</li> <li>Supports tiled and layered images used to achieve pseudo true color and more.</li> <li>The plain text extension is not supported</li> </ul> IFF - InterchangeFileFormat <ul> <li>Supports 1-8 bit, 24 bit, HAM6/8, EHB ILBM files</li> <li>Supports uncompressed, byterun 1 &amp; 2 (Atari) compressed ILBM files</li> <li>Supports PBM (Deluxe Paint DOS) encoded files</li> <li>Supports ACBM (Amiga Basic) files</li> <li>Color cycle chunks are ignored</li> <li>Mask is not supported (skipped)</li> </ul> JPEG - Joint Photographic Experts Group <ul> <li>8-bit baseline and progressive</li> </ul> PAM - Portable Arbitrary Map Currently, this only supports a subset of PAMs where: * The tuple type is official (see <code>man 5 pam</code>) or easily inferred (and by extension, depth is 4 or less) * All the images in a sequence have the same dimensions and maxval (it is technically possible to support animations with different maxvals and tuple types as each <code>AnimationFrame</code> has its own <code>PixelStorage</code>, however, this is likely not expected by users of the library) * Grayscale, * Grayscale with alpha * Rgb555 * Rgb24 and Rgba32 * Bgr24 and Bgra32 * Rgb48 and Rgba64 PBM - Portable Bitmap format <ul> <li>Everything is supported</li> </ul> PCX - ZSoft Picture Exchange format <ul> <li>Support monochrome, 4 color, 16 color and 256 color indexed images</li> <li>Support 24-bit RGB images</li> </ul> PGM - Portable Graymap format <ul> <li>Support 8-bit and 16-bit grayscale images</li> <li>16-bit ascii grayscale loading not tested</li> </ul> PNG - Portable Network Graphics <ul> <li>Support all pixel formats supported by PNG (grayscale, grayscale+alpha, indexed, truecolor, truecolor with alpha) in 8-bit or 16-bit.</li> <li>Support the mininal chunks in order to decode the image.</li> <li>Can write all supported pixel formats but writing interlaced images is not supported yet.</li> </ul> PPM - Portable Pixmap format <ul> <li>Support 24-bit RGB (8-bit per channel)</li> <li>Missing 48-bit RGB (16-bit per channel)</li> </ul> QOI - Quite OK Image format <ul> <li>Imported from https://github.com/MasterQ32/zig-qoi with blessing of the author</li> </ul> SGI - Silicon Graphics Image <ul> <li>Supports 8-bit, RGB (24/48-bit), RGBA(32/64-bit) files</li> <li>Supports RLE and uncompressed files</li> </ul> SUN - Sun Raster format <ul> <li>Supports 1/8/24/32-bit files</li> <li>Supports uncompressed &amp; RLE files</li> <li>Supports BGR/RGB encoding</li> <li>TIFF/IFF/Experimental encoding is not supported</li> </ul> TGA - Truevision TGA format <ul> <li>Supports uncompressed and compressed 8-bit grayscale, indexed with 16-bit and 24-bit colormap, truecolor with 16-bit(RGB555), 24-bit or 32-bit bit depth.</li> <li>Supports reading version 1 and version 2</li> <li>Supports writing version 2</li> </ul> TIFF - Tagged Image File Format What's supported: <ul> <li>bilevel, grayscale, palette and RGB(A) files</li> <li>most <em>baseline</em> tags</li> <li>Raw, LZW, Deflate, PackBits, CCITT 1D files</li> <li>big-endian (MM) and little-endian (II) files should both be decoded fine</li> </ul> What's missing: <ul> <li>Tile-based files are not supported</li> <li>YCbCr, CMJN and CIE Lab files are not supported</li> <li>JPEG, CCITT Fax 3 / 4 are not supported yet</li> </ul> Notes <ul> <li>Only the first IFD is decoded</li> <li>Orientation tag is not supported yet</li> </ul> Supported Pixel formats <ul> <li><strong>Indexed</strong>: 1bpp (bit per pixel), 2bpp, 4bpp, 8bpp, 16bpp</li> <li><strong>Grayscale</strong>: 1bpp, 2bpp, 4bpp, 8bpp, 16bpp, 8bpp with alpha, 16bpp with alpha</li> <li><strong>Truecolor</strong>: RGB332, RGB555, RGB565, RGB24 (8-bit per channel), RGBA32 (8-bit per channel), BGR555, BGR24 (8-bit per channel), BGRA32 (8-bit per channel), RGB48 (16-bit per channel), RGBA64 (16-bit per channel)</li> <li><strong>float</strong>: 32-bit float RGBA, this is the neutral format.</li> </ul> User Guide Design philosophy zigimg offers color and image functionality. The library is designed around either using the convenient <code>Image</code> (or <code>ImageUnmanaged</code>) struct that can read and write image formats no matter the format. Or you can also use the image format directly in case you want to extract more data from the image format. So if you find that <code>Image</code> does not give you the information that you need from a PNG or other format, you can use the PNG format albeit with a more manual API that <code>Image</code> hide from you. <code>Image</code> vs <code>ImageUnmanaged</code> <code>Image</code> bundle a memory allocator and <code>ImageUnmanaged</code> does not. Similar to <code>std.ArrayList()</code> and <code>std.ArrayListUnmanaged()</code> in Zig standard library. For all the examples we are going to use <code>Image</code> but it is similar with <code>ImageUnmanaged</code>. Read an image It is pretty straightforward to read an image using the <code>Image</code> struct. From a file You can use either a file path ```zig const std = @import("std"); const zigimg = @import("zigimg"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>const allocator = gpa.allocator(); var image = try zigimg.Image.fromFilePath(allocator, "my_image.png"); defer image.deinit(); // Do something with your image </code> } ``` or a <code>std.fs.File</code> directly ```zig const std = @import("std"); const zigimg = @import("zigimg"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>const allocator = gpa.allocator(); var file = try std.fs.cwd().openFile(file_path, .{}); defer file.close(); var image = try zigimg.Image.fromFile(allocator, file); defer image.deinit(); // Do something with your image </code> } ``` From memory ```zig const std = @import("std"); const zigimg = @import("zigimg"); const image_data = @embedFile("test.bmp"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>const allocator = gpa.allocator(); const image = try zigimg.Image.fromMemory(allocator, image_data[0..]); defer image.deinit(); // Do something with your image </code> } ``` Accessing pixel data For a single image, they are two ways to get access to the pixel data. Accessing a specific format directly You can access the pixel data directly using <code>Image.pixels</code>. <code>pixels</code> is an union of all supported pixel formats. For RGB pixel formats, just use the pixel format enum value and addresss the data directly. ```zig pub fn example() void { // [...] // Assuming you already have an image loaded <code>const first_pixel = image.pixels.rgb24[0]; </code> } ``` For grayscale formats, you need to use .value to get the grayscale value. It can also contain the alpha value if you use the grayscale with alpha. ```zig pub fn example() void { // [...] // Assuming you already have an image loaded <code>const first_pixel = image.pixels.grayscale8Alpha[0]; const grayscale = first_pixel.value; const alpha = grayscale.alpha; </code> } ``` For indexed formats, you need to first access the union value then either the indices or the palette. The palette color are stored in the <code>Rgba32</code> pixel format. ```zig pub fn example() void { // [...] // Assuming you already have an image loaded <code>const first_color_palette = image.pixels.indexed8.palette[0]; const first_pixel = image.pixels.indexed8.indices[0]; </code> } ``` If you want to know the current pixel format use <code>Image.pixelFormat()</code>. Using the color iterator You can use the iterator to get each pixel as the universal <code>Colorf32</code> pixel format. (32-bit floating ploint RGBA) ```zig pub fn example() void { // [...] // Assuming you already have an image loaded <code>const color_it = image.iterator(); while (color_it.next()) |color| { // Do something with color } </code> } ``` Accessing animation frames In the case of an <code>Image</code> containing multiple frames, you can use <code>Image.animation</code> to get access to the animation information. Use <code>Image.animation.frames</code> to access each indivial frame. Each frame contain the pixel data and a frame duration in seconds (32-bit floating point). <code>Image.pixels</code> will always point to the first frame of an animation also. ```zig pub fn example() void { // [...] // Assuming you already have an image loaded <code>const loop_count = image.animation.loop_count; for (image.animation.frames) |frame| { const rgb24_data = frame.pixels.rgb24; const frame_duration = frame.duration; } </code> } ``` Get raw bytes for texture transfer <code>Image</code> has helper functions to help you get the right data to upload your image to the GPU. ```zig pub fn example() void { // [...] // Assuming you already have an image loaded <code>const image_data = image.rawBytes(); const row_pitch = image.rowByteSize(); const image_byte_size = image.imageByteSize(); </code> } ``` Detect image format You can query the image format used by a file or a memory buffer. From a file You can use either a file path ```zig const std = @import("std"); const zigimg = @import("zigimg"); pub fn main() !void { const image_format = try zigimg.Image.detectFormatFromFilePath(allocator, "my_image.png"); <code>// Will print png std.log.debug("Image format: {}", .{image_format}); </code> } ``` or a <code>std.fs.File</code> directly ```zig const std = @import("std"); const zigimg = @import("zigimg"); pub fn main() !void { var file = try std.fs.cwd().openFile("my_image.gif", .{}); defer file.close(); <code>const image_format = try zigimg.Image.detectFormatFromFile(allocator, file); // Will print gif std.log.debug("Image format: {}", .{image_format}); </code> } ``` From memory ```zig const std = @import("std"); const zigimg = @import("zigimg"); const image_data = @embedFile("test.bmp"); pub fn main() !void { const image_format = try zigimg.Image.detectFormatFromMemory(allocator, image_data[0..]); <code>// Will print bmp std.log.debug("Image format: {}", .{image_format}); </code> } ``` Write an image Each 3 functions to write an image take a union of encoder options for the target format. To know the actual options you'll need to consult the source code. The active tag of the union determine the target format, not the file extension. Write to a file path ```zig pub fn example() !void { // [...] // Assuming you already have an image loaded <code>try image.writeToFilePath("my_new_image.png", .{ .png = .{} }); // Or with encoder options try image.writeToFilePath("my_new_image.png", .{ .png = .{ .interlaced = true } }); </code> } ``` Write to <code>std.fs.File</code> ```zig pub fn example() !void { // [...] // Assuming you already have an image loaded and the file already created <code>try image.writeToFile(file, .{ .bmp = .{} }); </code> } ``` Write to a memory buffer Ensure that you have enough place in your buffer before calling <code>writeToMemory()</code> ```zig pub fn example() !void { // [...] // Assuming you already have an image loaded and the buffer already allocated <code>try image.writeToMemory(buffer[0..], .{ .tga = .{} }); </code> } ``` Create an image Use <code>Image.create()</code> and pass the width, height and the pixel format that you want. ```zig const std = @import("std"); const zigimg = @import("zigimg"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>const allocator = gpa.allocator(); var image = try zigimg.Image.create(allocator, 1920, 1080, .rgba32); defer image.deinit(); // Do something with your image </code> } ``` Interpret raw pixels If you are not dealing with a image format, you can import your pixel data using <code>Image.fromRawPixels()</code>. It will create a copy of the pixels data. If you want the image to take ownership or just pass the data along to write it to a image format, use <code>ImageUnmanaged.fromRawPixelsOwned()</code>. Using <code>fromRawPixel()</code>: ```zig const std = @import("std"); const zigimg = @import("zigimg"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>const allocator = gpa.allocator(); const my_raw_pixels = @embedData("raw_bgra32.bin"); var image = try zigimg.Image.fromRawPixels(allocator, 1920, 1080, my_raw_pixels[0..], .bgra32); defer image.deinit(); // Do something with your image </code> } ``` Using <code>fromRawPixelsOwned()</code>: ```zig const std = @import("std"); const zigimg = @import("zigimg"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>const allocator = gpa.allocator(); const my_raw_pixels = @embedData("raw_bgra32.bin"); var image = try zigimg.ImageUnmanaged.fromRawPixelsOwned(1920, 1080, my_raw_pixels[0..], .bgra32); // Do something with your image </code> } ``` Use image format directly In the case you want more direct access to the image format, all the image formats are accessible from the <code>zigimg</code> module. However, you'll need to do a bit more manual steps in order to retrieve the pixel data. ```zig const std = @import("std"); const zigimg = @import("zigimg"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); <code>const allocator = gpa.allocator(); const image_data = @embedFile("windows_rgba_v5.bmp"); var stream_source = std.io.StreamSource{ .const_buffer = std.io.fixedBufferStream(image_data) }; var bmp = zigimg.formats.bmp.BMP{}; const pixels = try bmp.read(allocator, &amp;stream_source); defer pixels.deinit(allocator); std.log.info("BMP info header: {}", .{bmp.info_header}); </code> } ``` For the curious, the program above generate the following output: <code>info: BMP info header: src.formats.bmp.BitmapInfoHeader{ .v5 = src.formats.bmp.BitmapInfoHeaderV5{ .header_size = 124, .width = 240, .height = 160, .color_plane = 1, .bit_count = 32, .compression_method = src.formats.bmp.CompressionMethod.bitfields, .image_raw_size = 153600, .horizontal_resolution = 2835, .vertical_resolution = 2835, .palette_size = 0, .important_colors = 0, .red_mask = 16711680, .green_mask = 65280, .blue_mask = 255, .alpha_mask = 4278190080, .color_space = src.formats.bmp.BitmapColorSpace.srgb, .cie_end_points = src.formats.bmp.CieXyzTriple{ .red = src.formats.bmp.CieXyz{ ... }, .green = src.formats.bmp.CieXyz{ ... }, .blue = src.formats.bmp.CieXyz{ ... } }, .gamma_red = 0, .gamma_green = 0, .gamma_blue = 0, .intent = src.formats.bmp.BitmapIntent.graphics, .profile_data = 0, .profile_size = 0, .reserved = 0 } }</code> Convert between pixel formats You can use <code>Image.convert()</code> to convert between pixel formats. It will allocate the new pixel data and free the old one for you. It supports conversion from and to any pixel format. When converting down to indexed format, no dithering is done. ```zig pub fn example() !void { // [...] // Assuming you already have an image loaded <code>try image.convert(.float32); </code> } ``` PixelFormatConverter If you prefer, you can use <code>PixelFormatConverter</code> directly. ```zig pub fn example(allocator: std.mem.Allocator) !void { const indexed2_pixels = try zigimg.color.PixelStorage.init(allocator, .indexed2, 4); defer indexed2_pixels.deinit(allocator); <code>// [...] Setup your indexed2 pixel data const bgr24_pixels = try zigimg.PixelFormatConverter.convert(allocator, &amp;indexed2_pixels, .bgr24); defer bgr24_pixels.deinit(allocator); </code> } ``` OctTreeQuantizer If you prefer more granular control to create an indexed image, you can use the <code>OctTreeQuantizer</code> directly. ```zig pub fn example(allocator: std.mem.Allocator) !void { const image_data = @embedFile("windows_rgba_v5.bmp"); <code>var image = try zigimg.Image.fromMemory(allocator, image_data[0..]); defer image.deinit(); var quantizer = zigimg.OctTreeQuantizer.init(allocator); defer quantizer.deinit(); var color_it = image.iterator(); while (color_it.next()) |pixel| { try quantizer.addColor(pixel); } var palette_storage: [256]zigimg.color.Rgba32 = undefined; const palette = quantizer.makePalette(255, palette_storage[0..]); const palette_index = try quantizer.getPaletteIndex(zigimg.color.Rgba32.initRgba(110, 0, 0, 255)); </code> } ``` Get a color from a HTML hex string You can get a color from a HTML hex string. The alpha component is always last. It also supports the shorthand version. ```zig pub fn example() !void { const rgb24 = try zigimg.color.Rgb24.fromHtmlHex("#123499"); const rgba32 = try zigimg.color.Rgba32.fromHtmlHex("FF000045"); <code>const red_rgb24 = try zigimg.color.Rgb24.fromHtmlHex("#F00"); const blue_rgba32 = try zigimg.clor.Rgba32.fromHtmlHex("#00FA"); </code> } ``` Predefined colors You can access predefined colors for any pixel format using <code>Colors()</code>. ```zig const std = @import("std"); const zigimg = @import("zigimg"); pub fn main() !void { const red_float32 = zigimg.Colors(zigimg.color.Colorf32).Red; const blue_rgb24 = zigimg.Colors(zigimg.color.Rgb24).Blue; } ``` Color management &amp; color space While zigimg does not support ICC profile yet (see #36) it does support a variety of color models and color spaces. All color space and color model are done in 32-bit floating point. So if you are not using <code>Colorf32</code> / <code>float32</code> as your pixel format, you'll need to convert to that format first. The following device-dependent color model are supported: * HSL (Hue, Saturation, Luminance) * HSV (Hue, Saturation, Value) or also known as HSB (Hue, Saturation, Brightness) * CMYK (Cyan-Magenta-Yellow-Black) The following device-inpendent color spaces are supported, with or without alpha: * CIE XYZ * CIE Lab * CIE LCh(ab), the cylindral representation of CIE Lab * CIE Luv * CIE LCh(uv), the cylindral representation of CIE Luv * <a>HSLuv</a>, a HSL representation of CIE LCh(uv) which is a cylindrical representation of CIE Luv color space * <a>Oklab</a> * Oklch, the cylindrical representation of Oklab Convert between linear and gamma-corrected color All color space transformation are done assuming a linear version of the color. To convert between gamma-converted and linear, you need to use any RGB colorspace and then call <code>toGamma()</code> or <code>toLinear()</code>, in this example I'm using both <code>sRGB</code> and <code>BT709</code> (aka Rec.709). You can use either the accurate version or the fast version. For example the sRGB transfer function is linear below a threshold and an exponent curve above the threshold but the fast version will use the approximate exponent curve for the whole range. ```zig pub fn example(linear_color: zigimg.color.Colorf32) { const gamma_srgb = zigimg.color.sRGB.toGamma(linear_color); const gamma_bt709 = zigimg.color.BT709.toGammaFast(linear_color); <code>const linear_srgb = zigimg.color.sRGB.toLinearFast(gamma_srgb); const linear_bt709 = zigimg.color.BT709.toLinear(gamma_bt609); </code> } ``` Convert a single color to a different color space To convert to a device independant color space, you need first to use a reference RGB color space. Usually the most common for computer purposes is <code>sRGB</code>. Then each RGB colorspace has functions to convert from and to various color spaces. They support both non-alpha and alpha of the color space. To a color space: <code>zig pub fn example(linear_color: zigimg.color.Colorf32) void { const xyz = zigimg.color.sRGB.toXYZ(linear_color); const lab_alpha = zigimg.color.sRGB.toLabAlpha(linear_color); const lch_ab = zigimg.color.sRGB.toLCHab(linear_color); const luv_alpha = zigimg.color.sRGB.toLuvAlpha(linear_color); const lch_uv = zigimg.color.sRGB.toLCHuv(linear_color); const hsluv = zigimg.color.sRGB.toHSLuv(linear_color); const oklab = zigimg.color.sRGB.toOklab(linear_color); const oklch = zigimg.color.sRGB.toOkLCh(linear_color); }</code> When converting from a color space to a RGB color space, you need to specify if you want the color to be clamped inside the RGB colorspace or not because the resulting color could be outside of the RGB color space. <code>zig pub fn example(oklab: zigimg.color.Oklab) { const linear_srgb_clamped = zigimg.color.sRGB.fromOklab(oklab, .clamp); const linear_srgb = zigimg.color.sRGB.fromOklab(oklab, .none); }</code> Convert a slice of color to a different color space Converting each pixel individually will be tedious if you want to use image processing on the CPU. Almost all color space conversion offer an slice in-place conversion or a slice copy conversion. The in-place will reuse the same memory but interpret the color data differently. When you are conversion from a color space to a RGB color space, you need to specify if you want clamping or not. Those conversions are only available with the alpha version of each color space. ```zig pub fn exampleInPlace(linear_srgb_image: []zigimg.color.Colorf32) void { const slice_lab_alpha = zigimg.color.sRGB.sliceToLabAlphaInPlace(linear_srgb_image); <code>// Do your image manipulation in CIE L*a*b* // Convert back to linear sRGB _ = zigimg.color.sRGB.sliceFromLabAlphaInPlace(slice_lab_alpha, .clamp); // or without clamping _ = zigimg.color.sRGB.sliceFromLabAlphaInPlace(slice_lab_alpha, .none); </code> } pub fn exampleCopy(allocator: std.mem.Allocator, linear_srgb_image: []const zigimg.color.Colorf32) ![]zigimg.color.Colorf32 { const slice_oklab_alpha = try zigimg.color.sRGB.sliceToOklabCopy(allocator, linear_srgb_image); <code>// Do your image manipulatioon in Oklab // Convert back to linear sRGB return try zigimg.color.sRGB.sliceFromOklabCopy(allocator, slice_oklab_alpha, .clamp); // Or without clamping return try zigimg.color.sRGB.sliceFromOklabCopy(allocator, slice_oklab_alpha, .none); </code> } ``` Convert between some cylindrical representation CIE Lab, CIE Luv and Oklab have cylindrical representation of their color space, each color has functions to convert from and to the cylindrical version. ```zig pub fn example() void { const lab = zigimg.color.CIELab{ .l = 0.12, .a = -0.23, .b = 0.56 }; const luv_alpha = zigimg.color.CIELuvAlpha { .l = 0.4, .u = 0.5, .v = -0.2, .alpha = 0.8 }; const oklab = zigimg.color.Oklab{ .l = 0.67, .a = 0.1, .b = 0.56 }; <code>const lch_ab = lab.toLCHab(); const lch_uv_alpha = luv_alpha.toLCHuvAlpha(); const oklch = oklab.toOkLCh(); const result_lab = lch_ab.toLab(); const result_luv_alpha = lch_uv_alpha.toLuvAlpha(); const result_oklab = oklch.toOklab(); </code> } ``` Convert color between RGB color spaces To convert a single color, use the <code>convertColor()</code> function on the <code>RgbColorspace</code> struct: <code>zig pub fn example(linear_color: zigimg.color.Colorf32) void { const pro_photo_color = zigimg.color.sRGB.convertColor(zigimg.color.ProPhotoRGB, linear_color); }</code> If you want to convert a whole slice of pixels, use <code>convertColors()</code>, it will apply the conversion in-place: <code>zig pub fn example(linear_image: []zigimg.color.Colorf32) void { const adobe_image = zigimg.color.sRGB.convertColors(zigimg.color.AdobeRGB, linear_image); }</code> If the target RGB colorspace have a different white point, it will do the <a>chromatic adapdation</a> for you using the Bradford method. Predefined RGB color spaces Here the list of predefined RGB color spaces, all accessible from <code>zigimg.color</code> struct: <ul> <li><code>BT601_NTSC</code></li> <li><code>BT601_PAL</code></li> <li><code>BT709</code></li> <li><code>sRGB</code></li> <li><code>DCIP3.Display</code></li> <li><code>DCIP3.Theater</code></li> <li><code>DCIP3.ACES</code></li> <li><code>BT2020</code></li> <li><code>AdobeRGB</code></li> <li><code>AdobeWideGamutRGB</code></li> <li><code>ProPhotoRGB</code></li> </ul> Predefined white points All predefined white point are accessed with <code>zigimg.color.WhitePoints</code>. All the standard illuminants are defined there. Create your own RGB color space You can create your own RGB color space using <code>zigimg.color.RgbColorspace.init()</code>. Each coordinate is in the 2D version of the CIE xyY color space. If you don't care about linear and gamma conversion, just ignore those functions in the init struct. ```zig fn myColorSpaceToGamma(value: f32) f32 { return std.math.pow(f32, value, 1.0 / 2.4); } fn myColorSpaceToLinear(value: f32) f32 { return std.math.pow(f32, value, 2.4); } pub fn example() void { pub const my_color_space = zigimg.color.RgbColorspace.init(.{ .red = .{ .x = 0.6400, .y = 0.3300 }, .green = .{ .x = 0.3000, .y = 0.6000 }, .blue = .{ .x = 0.1500, .y = 0.0600 }, .white = zigimg.color.WhitePoints.D50, .to_gamma = myColorSpaceToGamma, .to_gamma_fast = myColorSpaceToGamma, .to_linear = myColorSpaceToLinear, .to_linear_fast = myColorSpaceToLinear, }); } ```
[ "https://github.com/ATTron/astroz", "https://github.com/Harry-Heath/micro", "https://github.com/Khitiara/imaginarium", "https://github.com/PhantomUIx/core", "https://github.com/SinclaM/ray-tracer-challenge", "https://github.com/capy-ui/capy", "https://github.com/chadwain/zss", "https://github.com/deck...
https://avatars.githubusercontent.com/u/3932972?v=4
SDL.zig
ikskuh/SDL.zig
2019-12-02T07:43:30Z
A shallow wrapper around SDL that provides object API and error handling
master
17
402
88
402
https://api.github.com/repos/ikskuh/SDL.zig/tags
MIT
[ "gamedev", "sdl", "sdl2", "zig", "zig-package", "ziglang" ]
995
false
2025-05-15T23:44:01Z
true
true
0.14.0
github
[]
SDL.zig A Zig package that provides you with the means to link SDL2 to your project, as well as a Zig-infused header implementation (allows you to not have the SDL2 headers on your system and still compile for SDL2) and a shallow wrapper around the SDL apis that allow a more Zig-style coding with Zig error handling and tagged unions. Getting started Linking SDL2 to your project This is an example <code>build.zig</code> that will link the SDL2 library to your project. ```zig const std = @import("std"); const sdl = @import("sdl"); // Replace with the actual name in your build.zig.zon pub fn build(b: *std.Build) !void { // Determine compilation target const target = b.standardTargetOptions(.{}); <code>// Create a new instance of the SDL2 Sdk // Specifiy dependency name explicitly if necessary (use sdl by default) const sdk = sdl.init(b, .{}); // Create executable for our example const demo_basic = b.addExecutable(.{ .name = "demo-basic", .root_source_file = b.path("my-game.zig"), .target = target, }); sdk.link(demo_basic, .dynamic, sdl.Library.SDL2); // link SDL2 as a shared library // Add "sdl2" package that exposes the SDL2 api (like SDL_Init or SDL_CreateWindow) demo_basic.root_module.addImport("sdl2", sdk.getNativeModule()); // Install the executable into the prefix when invoking "zig build" b.installArtifact(demo_basic); </code> } ``` Using the native API This package exposes the SDL2 API as defined in the SDL headers. Use this to create a normal SDL2 program: ```zig const std = @import("std"); const SDL = @import("sdl2"); // Add this package by using sdk.getNativeModule pub fn main() !void { if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_EVENTS | SDL.SDL_INIT_AUDIO) &lt; 0) sdlPanic(); defer SDL.SDL_Quit(); <code>var window = SDL.SDL_CreateWindow( "SDL2 Native Demo", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED, 640, 480, SDL.SDL_WINDOW_SHOWN, ) orelse sdlPanic(); defer _ = SDL.SDL_DestroyWindow(window); var renderer = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RENDERER_ACCELERATED) orelse sdlPanic(); defer _ = SDL.SDL_DestroyRenderer(renderer); mainLoop: while (true) { var ev: SDL.SDL_Event = undefined; while (SDL.SDL_PollEvent(&amp;ev) != 0) { if(ev.type == SDL.SDL_QUIT) break :mainLoop; } _ = SDL.SDL_SetRenderDrawColor(renderer, 0xF7, 0xA4, 0x1D, 0xFF); _ = SDL.SDL_RenderClear(renderer); SDL.SDL_RenderPresent(renderer); } </code> } fn sdlPanic() noreturn { const str = @as(?[*:0]const u8, SDL.SDL_GetError()) orelse "unknown error"; @panic(std.mem.sliceTo(str, 0)); } ``` Using the wrapper API This package also exposes the SDL2 API with a more Zig-style API. Use this if you want a more convenient Zig experience. <strong>Note:</strong> This API is experimental and might change in the future ```zig const std = @import("std"); const SDL = @import("sdl2"); // Created in build.zig by using exe.root_module.addImport("sdl2", sdk.getWrapperModule()); pub fn main() !void { try SDL.init(.{ .video = true, .events = true, .audio = true, }); defer SDL.quit(); <code>var window = try SDL.createWindow( "SDL2 Wrapper Demo", .{ .centered = {} }, .{ .centered = {} }, 640, 480, .{ .vis = .shown }, ); defer window.destroy(); var renderer = try SDL.createRenderer(window, null, .{ .accelerated = true }); defer renderer.destroy(); mainLoop: while (true) { while (SDL.pollEvent()) |ev| { switch (ev) { .quit =&gt; break :mainLoop, else =&gt; {}, } } try renderer.setColorRGB(0xF7, 0xA4, 0x1D); try renderer.clear(); renderer.present(); } </code> } ``` <code>build.zig</code> API <code>``zig /// Just call</code>Sdk.init(b, .{})<code>to obtain a handle to the Sdk! /// Use</code>sdl` as dependency name by default. const Sdk = @This(); /// Creates a instance of the Sdk and initializes internal steps. /// Initialize once, use everywhere (in your <code>build</code> function). /// /// const SdkOption = struct { /// dep_name: ?[]const u8 = "sdl", /// maybe_config_path: ?[]const u8 = null, /// maybe_sdl_ttf_config_path: ?[]const u8 = null, /// }; pub fn init(b: <em>Build, opt: SdkOption) </em>Sdk /// Returns a module with the raw SDL api with proper argument types, but no functional/logical changes /// for a more <em>ziggy</em> feeling. /// This is similar to the <em>C import</em> result. pub fn getNativeModule(sdk: <em>Sdk) </em>Build.Module; /// Returns a module with the raw SDL api with proper argument types, but no functional/logical changes /// for a more <em>ziggy</em> feeling, with Vulkan support! The Vulkan module provided by <code>vulkan-zig</code> must be /// provided as an argument. /// This is similar to the <em>C import</em> result. pub fn getNativeModuleVulkan(sdk: <em>Sdk, vulkan: </em>Build.Module) *Build.Module; /// Returns the smart wrapper for the SDL api. Contains convenient zig types, tagged unions and so on. pub fn getWrapperModule(sdk: <em>Sdk) </em>Build.Module; /// Returns the smart wrapper with Vulkan support. The Vulkan module provided by <code>vulkan-zig</code> must be /// provided as an argument. pub fn getWrapperModuleVulkan(sdk: <em>Sdk, vulkan: </em>Build.Module) *Build.Module; /// Links SDL2 or SDL2_ttf to the given exe and adds required installs if necessary. /// <strong>Important:</strong> The target of the <code>exe</code> must already be set, otherwise the Sdk will do the wrong thing! pub fn link(sdk: <em>Sdk, exe: </em>Build.Step.Compile, linkage: std.builtin.LinkMode, comptime library: Library) void; ``` Dependencies All of those are dependencies for the <em>target</em> platform, not for your host. Zig will run/build the same on all source platforms. Windows For Windows, you need to fetch the correct dev libraries from the <a>SDL download page</a>. It is recommended to use the MinGW versions if you don't require MSVC compatibility. MacOS Right now, cross-compiling for MacOS isn't possible. On a Mac, install SDL2 via <code>brew</code>. Linux If you are cross-compiling, no dependencies exist. The build Sdk compiles a <code>libSDL2.so</code> stub which is used for linking. If you compile to your target platform, you require SDL2 to be installed via your OS package manager. Support Matrix This project tries to provide you the best possible development experience for SDL2. Thus, this project supports the maximum amount of cross-compilation targets for SDL2. The following table documents this. The rows document the <em>target</em> whereas the columns are the <em>build host</em>: | | Windows (x86_64) | Windows (i386) | Linux (x86_64) | MacOS (x86_64) | MacOS (aarch64) | |-----------------------|------------------|----------------|----------------|----------------|-----------------| | <code>i386-windows-gnu</code> | ✅ | ✅ | ✅ | ✅ | ⚠️ | | <code>i386-windows-msvc</code> | ✅ | ✅ | ✅ | ✅ | ⚠️ | | <code>x86_64-windows-gnu</code> | ✅ | ✅ | ✅ | ✅ | ⚠️ | | <code>x86_64-windows-msvc</code> | ✅ | ✅ | ✅ | ✅ | ⚠️ | | <code>x86_64-macos</code> | ❌ | ❌ | ❌ | ✅ | ❌ | | <code>aarch64-macos</code> | ❌ | ❌ | ❌ | ❌ | ⚠️ | | <code>x86_64-linux-gnu</code> | 🧪 | 🧪 | ✅ | 🧪 | ⚠️ | | <code>aarch64-linux-gnu</code> | 🧪 | 🧪 | 🧪 | 🧪 | ⚠️ | Legend: - ✅ Cross-compilation is known to work and tested via CI - 🧪 Experimental cross-compilation support, covered via CI - ⚠️ Cross-compilation <em>might</em> work, but is not tested via CI - ❌ Cross-compilation is not possible right now Contributing You can contribute to this project in several ways: - Use it! This helps me to track bugs (which i know that there are some), and usability defects (which we can resolve then). I want this library to have the best development experience possible. - Implement/improve the linking experience: Right now, it's not possible to cross-compile for MacOS, which is very sad. We might find a way to do so, though! Also VCPKG is not well supported on windows platforms. - Improve the wrapper. Just add the functions you need and make a PR. Or improve existing ones. I won't do it for you, so you have to get your own hands dirty!
[]
https://avatars.githubusercontent.com/u/3932972?v=4
LoLa
ikskuh/LoLa
2019-07-17T17:56:20Z
LoLa is a small programming language meant to be embedded into games.
master
15
207
11
207
https://api.github.com/repos/ikskuh/LoLa/tags
MIT
[ "compiler", "interpreter", "language", "lola-language", "programming-language", "script-language", "zig", "zig-package" ]
13,512
false
2025-05-18T05:27:14Z
true
true
unknown
github
[ { "commit": "9425b94c103a031777fdd272c555ce93a7dea581", "name": "args", "tar_url": "https://github.com/ikskuh/zig-args/archive/9425b94c103a031777fdd272c555ce93a7dea581.tar.gz", "type": "remote", "url": "https://github.com/ikskuh/zig-args" }, { "commit": "d068b14cd30577783de018e280428953d...
LoLa Programming Language LoLa is a small programming language meant to be embedded into games to be programmed by the players. The compiler and runtime are implemented in Zig and C++. Short Example <code>js var list = [ "Hello", "World" ]; for(text in list) { Print(text); }</code> You can find more examples in the <a>examples</a> folder. Why LoLa when there is <em>X</em>? LoLa isn't meant to be your next best day-to-day scripting language. Its design is focused on embedding the language in environments where the users want/need/should write some small scripts like games or scriptable applications. In most script languages, you as a script host don't have control over the execution time of the scripts you're executing. LoLa protects you against programming errors like endless loops and such: Controlled Execution Environment Every script invocation gets a limit of instructions it might execute. When either this limit is reached or the script yields for other reasons (asynchronous functions), the execution is returned to the host. This means, you can execute the following script "in parallel" to your application main loop without blocking your application <em>and</em> without requiring complex multithreading setups: <code>js var timer = 0; while(true) { Print("Script running for ", timer, " seconds."); timer += 1; Sleep(1.0); }</code> Native Asynchronous Design LoLa features both synchronous and asynchronous host functions. Synchronous host function calls are short-lived and will be executed in-place. Asynchronous functions, in contrast, will be executed multiple times until they yield a value. When they don't yield a value, control will be returned to the script host. This script will not exhaust the instruction limit, but will only increment the counter, then return control back to the host: <code>js var counter = 0; while(true) { counter += 1; Yield(); }</code> This behaviour can be utilized to wait for certain events in the host environment, for example to react to key presses, a script could look like this: <code>js while(true) { var input = WaitForKey(); if(input == " ") { Print("Space was pressed!"); } }</code> <em>Note that the current implementation is not thread-safe, but requires to use the limited execution for running scripts in parallel.</em> Native "RPC" Design LoLa also allows executing multiple scripts on the same <em>environment</em>, meaning that you can easily create cross-script communications: ```js // script a: var buffer; function Set(val) { buffer = val; } function Get() { return val; } // script b: // GetBuffer() returns a object referencing a environment for "script a" var buffer = GetBuffer(); buffer.Set("Hello, World!"); // script c: // GetBuffer() returns a object referencing a environment for "script a" var buffer = GetBuffer(); Print("Buffer contains: ", buffer.Get()); ``` With a fitting network stack and library, this can even be utilized cross-computer. This example implements a small chat client and server that could work with LoLa RPC capabilities: ```js // Chat client implementation: var server = Connect("lola-rpc://random-projects.net/chat"); if(server == void) { Print("Could not connect to chat server!"); Exit(1); } while(true) { var list = server.GetMessages(GetUser()); for(msg in list) { Print("&lt; ", msg); } <code>Print("&gt; "); var msg = ReadLine(); if(msg == void) break; if(msg == "") continue; server.Send(GetUser(), msg); </code> } ``` ```js // Chat server implementation var messages = CreateDictionary(); function Send(user, msg) { for(other in messages.GetKeys()) { if(other != user) { var log = messages.Get(other); if(log != void) { log = log ++ [ user + ": " + msg ]; } else { log = []; } messages.Set(other, log); } } } function GetMessages(user) { var log = messages.Get(user); if(log != void) { messages.Set(user, []); return log; } else { return []; } } ``` Serializable State As LoLa has no reference semantics except for objects, it is easy to understand and learn. It is also simple in its implementation and does not require a complex garbage collector or advanced programming knowledge. Each LoLa value can be serialized/deserialized into a sequence of bytes (only exception are object handles, those require some special attention), so saving the current state of a environment/vm to disk and loading it at a later point is a first-class supported use case. This is especially useful for games where it is favourable to save your script state into a save game as well without having any drawbacks. Simple Error Handling LoLa provides little to no in-language error handling, as it's not designed to be robust against user programming errors. Each error is passed to the host as a panic, so it can show the user that there was an error (like <code>OutOfMemory</code> or <code>TypeMismatch</code>). In-language error handling is based on the dynamic typing: Functions that allow in-language error handling just return <code>void</code> instead of a actual return value or <code>true</code>/<code>false</code> for <em>success</em> or <em>failure</em>. This allows simple error checking like this: <code>js var string = ReadFile("demo.data"); if(string != void) { Print("File contained ", string); }</code> This design decision was made with the idea in mind that most LoLa programmers won't write the next best security critical software, but just do a quick hack in game to reach their next item unlock. Smart compiler As LoLa isn't the most complex language, the compiler can support the programmer. Even though the language has fully dynamic typing, the compiler can do some type checking at compile time already: <code>js // warning: Possible type mismatch detected: Expected number|string|array, found boolean if(a &lt; true) { }</code> Right now, this is only used for validating expressions, but it is planned to extend this behaviour to annotate variables as well, so even more type errors can be found during compile time. Note that this is a fairly new feature, it does not catch all your type mismatches, but can prevent the obvious ones. Starting Points To get familiar with LoLa, you can check out these starting points: <ul> <li><a>Documentation</a></li> <li><a>LoLa Examples</a></li> <li><a>Script Host Examples</a></li> </ul> When you want to contribute to the compiler, check out the following documents: <ul> <li><a>Source Code</a></li> <li><a>Bison Grammar</a></li> <li><a>Flex Tokenizer</a></li> <li><a>Issue List</a></li> </ul> Visual Studio Code Extension If you want syntax highlighting in VSCode, you can install the <a><code>lola-vscode</code></a> extension. Right now, it's not published in the gallery, so to install the extension, you have to sideload it. <a>See the VSCode documentation for this</a>. Building Continous Integration <a></a> <a></a> Requirements <ul> <li>The <a>Zig Compiler</a> (Version 0.12.0-dev.3438+5c628312b or newer)</li> </ul> Building <code>sh zig build ./zig-cache/bin/lola</code> Examples To compile the host examples, you can use <code>zig build examples</code> to build all provided examples. These will be available in <code>./zig-cache/bin</code> then. Running the test suite When you change things in the compiler or VM implementation, run the test suite: <code>sh zig build test</code> This will execute all zig tests, and also runs a set of predefined tests within the <a><code>src/test/</code></a> folder. These tests will verify that the compiler and language runtime behave correctly. Building the website The website generator is gated behind <code>-Denable-website</code> which removes a lot of dependencies for people not wanting to render a new version of the website. If you still want to update/change the website or documentation, use the following command: <code>sh zig build -Denable-website "-Dversion=$(git describe --tags || git rev-parse --short HEAD)" website</code> It will depend on <a>koino</a>, which is included as a git submodule. Adding new pages to the documentation is done by modifying the <code>menu_items</code> array in <code>src/tools/render-md-page.zig</code>.
[]
https://avatars.githubusercontent.com/u/28556218?v=4
linenoize
joachimschmidt557/linenoize
2020-01-30T13:46:37Z
A port of linenoise to zig
master
4
68
12
68
https://api.github.com/repos/joachimschmidt557/linenoize/tags
MIT
[ "readline", "zig", "zig-package" ]
122
false
2025-05-11T21:10:25Z
true
true
unknown
github
[ { "commit": "master", "name": "wcwidth", "tar_url": "https://github.com/joachimschmidt557/zig-wcwidth/archive/master.tar.gz", "type": "remote", "url": "https://github.com/joachimschmidt557/zig-wcwidth" } ]
linenoize A port of <a>linenoise</a> to zig aiming to be a simple readline for command-line applications written in zig. It is written in pure zig and doesn't require libc. <code>linenoize</code> works with the latest stable zig version (0.14.0). In addition to being a full-fledged zig library, <code>linenoize</code> also serves as a drop-in replacement for linenoise. As a proof of concept, the example application from linenoise can be built with <code>zig build c-example</code>. Features <ul> <li>Line editing</li> <li>Completions</li> <li>Hints</li> <li>History</li> <li>Multi line mode</li> <li>Mask input mode</li> </ul> Supported platforms <ul> <li>Linux</li> <li>macOS</li> <li>Windows</li> </ul> Add linenoize to a project Add linenoize as a dependency to your project: <code>bash zig fetch --save git+https://github.com/joachimschmidt557/linenoize.git#v0.1.0</code> Then add the following code to your <code>build.zig</code> file: <code>zig const linenoize = b.dependency("linenoize", .{ .target = target, .optimize = optimize, }).module("linenoise"); exe.root_module.addImport("linenoize", linenoize);</code> Examples Minimal example ```zig const std = @import("std"); const Linenoise = @import("linenoise").Linenoise; pub fn main() !void { const allocator = std.heap.page_allocator; <code>var ln = Linenoise.init(allocator); defer ln.deinit(); while (try ln.linenoise("hello&gt; ")) |input| { defer allocator.free(input); std.debug.print("input: {s}\n", .{input}); try ln.history.add(input); } </code> } ``` Example of more features ``` zig const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const log = std.log.scoped(.main); const Linenoise = @import("linenoise").Linenoise; fn completion(allocator: Allocator, buf: []const u8) ![]const []const u8 { if (std.mem.eql(u8, "z", buf)) { var result = ArrayList([]const u8).init(allocator); try result.append(try allocator.dupe(u8, "zig")); try result.append(try allocator.dupe(u8, "ziglang")); return result.toOwnedSlice(); } else { return &amp;[_][]const u8{}; } } fn hints(allocator: Allocator, buf: []const u8) !?[]const u8 { if (std.mem.eql(u8, "hello", buf)) { return try allocator.dupe(u8, " World"); } else { return null; } } var debug_allocator: std.heap.DebugAllocator(.{}) = .init; pub fn main() !void { defer _ = debug_allocator.deinit(); const allocator = debug_allocator.allocator(); <code>var ln = Linenoise.init(allocator); defer ln.deinit(); // Load history and save history later ln.history.load("history.txt") catch log.err("Failed to load history", .{}); defer ln.history.save("history.txt") catch log.err("Failed to save history", .{}); // Set up hints callback ln.hints_callback = hints; // Set up completions callback ln.completions_callback = completion; // Enable mask mode // ln.mask_mode = true; // Enable multiline mode // ln.multiline_mode = true; while (try ln.linenoise("hellö&gt; ")) |input| { defer allocator.free(input); log.info("input: {s}", .{input}); try ln.history.add(input); } </code> } ```
[]
https://avatars.githubusercontent.com/u/7283681?v=4
zigdig
lun-4/zigdig
2019-05-12T05:39:02Z
naive dns client library in zig
master
1
40
7
40
https://api.github.com/repos/lun-4/zigdig/tags
MIT
[ "dns", "zig", "zig-package" ]
647
false
2025-05-02T17:20:51Z
true
true
0.14.0
github
[]
zigdig naive dns client library in zig help me decide if this api is good: https://github.com/lun-4/zigdig/issues/10 what does it do <ul> <li>serialization and deserialization of dns packets as per rfc1035</li> <li>supports a subset of rdata (i do not have any plans to support 100% of DNS, but SRV/MX/TXT/A/AAAA are there, which most likely will be enough for your use cases)</li> <li>has helpers for reading <code>/etc/resolv.conf</code> (not that much, really)</li> </ul> what does it not do <ul> <li>no edns0</li> <li>support all resolv.conf options</li> <li>can deserialize pointer labels, but does not serialize into pointers</li> <li>follow CNAME records, this provides only the basic serialization/deserializtion</li> </ul> how do <ul> <li>zig 0.14.0: https://ziglang.org</li> <li>have a <code>/etc/resolv.conf</code></li> <li>tested on linux, should work on bsd i think</li> </ul> ``` git clone ... cd zigdig zig build test zig build install --prefix ~/.local/ ``` and then <code>bash zigdig google.com a</code> or, for the host(1) equivalent <code>bash zigdig-tiny google.com</code> using the library getAddressList-style api ```zig const dns = @import("dns"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer { _ = gpa.deinit(); } var allocator = gpa.alloator(); <code>var addresses = try dns.helpers.getAddressList("ziglang.org", allocator); defer addresses.deinit(); for (addresses.addrs) |address| { std.debug.print("we live in a society {}\n", .{address}); } </code> } ``` full api ```zig const dns = @import("dns"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer { _ = gpa.deinit(); } var allocator = gpa.alloator(); <code>var name_buffer: [128][]const u8 = undefined; const name = try dns.Name.fromString("ziglang.org", &amp;name_buffer); var questions = [_]dns.Question{ .{ .name = name, .typ = .A, .class = .IN, }, }; var packet = dns.Packet{ .header = .{ .id = dns.helpers.randomHeaderId(), .is_response = false, .wanted_recursion = true, .question_length = 1, }, .questions = &amp;questions, .answers = &amp;[_]dns.Resource{}, .nameservers = &amp;[_]dns.Resource{}, .additionals = &amp;[_]dns.Resource{}, }; // use helper function to connect to a resolver in the systems' // resolv.conf const conn = try dns.helpers.connectToSystemResolver(); defer conn.close(); try conn.sendPacket(packet); // you can also do this to support any Writer // const written_bytes = try packet.writeTo(some_fun_writer_goes_here); const reply = try conn.receivePacket(allocator, 4096); defer reply.deinit(); // you can also do this to support any Reader // const packet = try dns.Packet.readFrom(some_fun_reader, allocator); // defer packet.deinit(); const reply_packet = reply.packet; logger.info("reply: {}", .{reply_packet}); try std.testing.expectEqual(packet.header.id, reply_packet.header.id); try std.testing.expect(reply_packet.header.is_response); // ASSERTS that there's one A resource in the answer!!! you should verify // reply_packet.header.opcode to see if there's any errors const resource = reply_packet.answers[0]; var resource_data = try dns.ResourceData.fromOpaque( reply_packet, resource.typ, resource.opaque_rdata, allocator ); defer resource_data.deinit(allocator); // you now have an std.net.Address to use to your hearts content const ziglang_address = resource_data.A; </code> } ``` it is recommended to look at zigdig's source on <code>src/main.zig</code> to understand how things tick using the library, but it boils down to three things: - packet generation and serialization - sending/receiving (via a small shim on top of std.os.socket) - packet deserialization
[]
https://avatars.githubusercontent.com/u/1327032?v=4
zig-win32
GoNZooo/zig-win32
2019-09-06T08:02:55Z
Bindings for win32, with and without WIN32_LEAN_AND_MEAN
master
1
31
2
31
https://api.github.com/repos/GoNZooo/zig-win32/tags
MIT
[ "win32", "win32api", "zig", "zig-package" ]
1,335
false
2025-04-05T01:53:48Z
true
false
unknown
github
[]
zig-win32 Archived I would suggest using <a>this library</a> instead. If there is some reason you cannot, feel free to reach out and I'll unarchive this so people can continue to work on it if they want. Linking You will need to add something like the following to your <code>build.zig</code> depending on what you end up using: If you're using the <code>win32.c</code> module, most functions are annotated with their library information, so you don't need to link anything, but at the time of writing the <code>lean_and_mean</code> module is not annotated. With that in mind, you may have to add build instructions like the following, depending on which functions you use: <code>zig const exe = b.addExecutable("executable-name", "src/main.zig"); exe.addPackagePath("win32", "./dependencies/zig-win32/src/main.zig"); exe.linkSystemLibrary("c"); exe.linkSystemLibrary("gdi32"); exe.linkSystemLibrary("user32"); exe.linkSystemLibrary("kernel32");</code> Usage in files A simple import will do it, access the sub-namespaces with <code>c</code> and <code>lean_and_mean</code>: <code>zig const win32 = @import("win32"); _ = win32.c.MessageBoxA(...);</code> Or import one of the sub-namespaces directly: <code>zig const win32 = @import("win32").lean_and_mean; _ = win32.MessageBoxA(...);</code> Macros not available in the FFI files <code>MAKEINTRESOURCE{A,W}</code> is not available in the generated files, but is available in the top namespace: <code>zig const win32 = @import("win32"); const resource: windows.LPSTR = win32.MAKEINTRESOURCEA(32512);</code>
[]
https://avatars.githubusercontent.com/u/65570835?v=4
lscolors
ziglibs/lscolors
2019-11-03T15:47:57Z
A zig library for colorizing paths according to LS_COLORS
master
0
16
1
16
https://api.github.com/repos/ziglibs/lscolors/tags
MIT
[ "ls-colors", "zig", "zig-package", "ziglang" ]
98
false
2025-05-07T07:19:42Z
true
true
0.14.0
github
[ { "commit": "master", "name": "ansi_term", "tar_url": "https://github.com/ziglibs/ansi_term/archive/master.tar.gz", "type": "remote", "url": "https://github.com/ziglibs/ansi_term" } ]
lscolors A zig library for colorizing paths according to the <code>LS_COLORS</code> environment variable. Designed to work with Zig 0.14.0. Quick Example ```zig const std = @import("std"); const LsColors = @import("lscolors").LsColors; pub fn main() !void { var gpa: std.heap.DebugAllocator(.{}) = .init; defer _ = gpa.deinit(); const allocator = gpa.allocator(); <code>var lsc = try LsColors.fromEnv(allocator); defer lsc.deinit(); var dir = try std.fs.cwd().openDir(".", .{ .iterate = true }); defer dir.close(); var iterator = dir.iterate(); while (try iterator.next()) |itm| { std.log.info("{}", .{try lsc.styled(itm.name)}); } </code> } ```
[ "https://github.com/joachimschmidt557/zigfd" ]
https://avatars.githubusercontent.com/u/1327032?v=4
zig-editor-core
GoNZooo/zig-editor-core
2019-11-13T08:45:45Z
Eventually the core of an editor, interactive shell put on top.
master
0
5
0
5
https://api.github.com/repos/GoNZooo/zig-editor-core/tags
-
[ "editor", "vim", "zig", "zig-package", "ziglang" ]
482
false
2023-09-02T23:14:58Z
true
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/28556218?v=4
zig-termbox
joachimschmidt557/zig-termbox
2020-01-30T13:48:36Z
A termbox implementation in zig
master
0
3
1
3
https://api.github.com/repos/joachimschmidt557/zig-termbox/tags
MIT
[ "zig", "zig-package" ]
68
false
2025-04-04T18:07:52Z
true
true
unknown
github
[ { "commit": "master", "name": "wcwidth", "tar_url": "https://github.com/joachimschmidt557/zig-wcwidth/archive/master.tar.gz", "type": "remote", "url": "https://github.com/joachimschmidt557/zig-wcwidth" }, { "commit": "master", "name": "ansi_term", "tar_url": "https://github.com/z...
zig-termbox termbox-inspired library for creating terminal user interfaces Works with Zig 0.14.0. Concepts <code>termbox</code> is a <em>double-buffered</em> terminal library. This means that when you call functions to draw on the screen, you are not actually sending data to the terminal, but instead act on an intermediate data structure called the <em>back buffer</em>. Only when you call <code>Termbox.present</code>, the terminal is actually updated to reflect the state of the <em>back buffer</em>. An advantage of this design is that repeated calls to <code>Termbox.present</code> only update the parts of the terminal interface that have actually changed since the last call. <code>termbox</code> achieves this by tracking the current state of the terminal in the internal <em>front buffer</em>. Examples ```zig const std = @import("std"); const termbox = @import("termbox"); const Termbox = termbox.Termbox; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); <code>var t = try Termbox.init(allocator); defer t.shutdown() catch {}; var anchor = t.back_buffer.anchor(1, 1); try anchor.writer().print("Hello {s}!", .{"World"}); anchor.move(1, 2); try anchor.writer().print("Press any key to quit", .{}); try t.present(); _ = try t.pollEvent(); </code> } ``` Further examples can be found in the <code>examples</code> subdirectory.
[]
https://avatars.githubusercontent.com/u/1327032?v=4
zig-humantime
GoNZooo/zig-humantime
2019-08-07T14:41:51Z
Mini library for expressing integer time values in more human readable ways
master
0
2
0
2
https://api.github.com/repos/GoNZooo/zig-humantime/tags
MIT
[ "zig", "zig-package" ]
8
false
2021-09-23T09:52:12Z
true
false
unknown
github
[]
zig-humantime This library exports two functions to convert human readable time strings into integer values: ```zig test "1h2m3s" { const time = comptime seconds("1h2m3s"); // @compileLog(time) -&gt; 7446 testing.expectEqual(time, 3723); } test "2h4m6s" { const time = comptime seconds("2h4m6s"); testing.expectEqual(time, (3600 * 2) + (4 * 60) + 6); } test "1h2m3s in milliseconds" { const format_string = "1h2m3s"; const time = milliseconds(format_string); // @compileLog(time) -&gt; runtime value testing.expectEqual(time, comptime seconds(format_string) * 1000); } test "5d4h3m2s" { testing.expectEqual(seconds("5d4h3m2s"), 446582); } ```
[]
https://avatars.githubusercontent.com/u/28556218?v=4
zig-walkdir
joachimschmidt557/zig-walkdir
2019-06-26T07:40:29Z
Provides functions for walking directories recursively
master
1
1
0
1
https://api.github.com/repos/joachimschmidt557/zig-walkdir/tags
MIT
[ "zig", "zig-package" ]
45
false
2025-03-08T22:25:54Z
true
true
unknown
github
[]
zig-walkdir A zig package providing functions for recursively traversing directories. Works with zig 0.14.0. Todo <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Breadth-first search <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Depth-first search <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Tests <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Following symlinks <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Correct error handling
[]
https://avatars.githubusercontent.com/u/48649707?v=4
zig-cookie
tensorush/zig-cookie
2024-03-05T18:13:03Z
Zig port of cookie-rs library for HTTP cookie storage.
main
0
1
0
1
https://api.github.com/repos/tensorush/zig-cookie/tags
MIT
[ "zig-package" ]
36
false
2025-03-18T06:57:17Z
true
true
0.14.0
github
[]
zig-cookie Zig port of <a>cookie-rs library</a> for HTTP cookie storage. Usage <ul> <li>Add <code>cookie</code> dependency to <code>build.zig.zon</code>.</li> </ul> <code>sh zig fetch --save git+https://github.com/tensorush/zig-cookie</code> <ul> <li>Use <code>cookie</code> dependency in <code>build.zig</code>.</li> </ul> <code>zig const cookie_dep = b.dependency("cookie", .{ .target = target, .optimize = optimize, }); const cookie_mod = cookie_dep.module("cookie"); &lt;compile&gt;.root_module.addImport("cookie", cookie_mod);</code>
[]
https://avatars.githubusercontent.com/u/6756180?v=4
druntime-zigbuild
kassane/druntime-zigbuild
2024-06-22T16:32:24Z
D runtime build using zig-build
main
3
1
0
1
https://api.github.com/repos/kassane/druntime-zigbuild/tags
NOASSERTION
[ "build-system", "cross-compile", "d", "dlang", "zig-build", "zig-package" ]
4,636
false
2024-09-17T14:34:03Z
true
true
unknown
github
[ { "commit": "c7e33a3b1dfb3b9ca8f5da3d7cb282852ad34547", "name": "abs", "tar_url": "https://github.com/kassane/anotherBuildStep/archive/c7e33a3b1dfb3b9ca8f5da3d7cb282852ad34547.tar.gz", "type": "remote", "url": "https://github.com/kassane/anotherBuildStep" }, { "commit": "788d4b0fed3c7ba4...
Druntime + phobos (standalone) for zig-build (ABS) <blockquote> [!Note] A standalone runtime + stdlib (for easy cross-compile) using ABS is the goal of this project </blockquote> <strong>More info:</strong> <a>issue#6: cross-compile with Druntime + Phobos2</a> <code>bash Project-Specific Options: -Dtarget=[string] The CPU architecture, OS, and ABI to build for -Dcpu=[string] Target CPU features to add or subtract -Ddynamic-linker=[string] Path to interpreter on the target system -Doptimize=[enum] Prioritize performance, safety, or binary size Supported Values: Debug ReleaseSafe ReleaseFast ReleaseSmall -Dlinkage=[enum] Change linking mode (default: static) Supported Values: static dynamic -Dphobos=[bool] Build phobos library (default: false)</code>
[]
https://avatars.githubusercontent.com/u/22280250?v=4
zigStructPrint
Durobot/zigStructPrint
2024-03-01T09:52:26Z
Small library to pretty-print Zig structs (and arrays)
main
0
1
0
1
https://api.github.com/repos/Durobot/zigStructPrint/tags
MIT
[ "zig", "zig-package", "ziglang" ]
14
false
2024-10-10T07:01:19Z
true
true
0.12.0-dev.3097+5c0766b6c
github
[]
zigStructPrint Small library to pretty-print Zig structs (and arrays) <strong>zigStructPrint</strong> is licensed under under <a>the MIT License</a> and available from https://github.com/Durobot/zigStructPrint Please note that only Zig <strong>0.14.0-dev.1421+f87dd43c1</strong> (give or take) and up is supported because of <a>this breaking change</a> in the Zig standard library. If you need zigStructPrint for an earlier version of Zig, get <a>this version</a> instead. To use, either drop <a>zsp.zig</a> into your project, or, if you prefer Zig package manager: <ol> <li>In <code>build.zig.zon</code>, in <code>.dependencies</code>, add</li> </ol> <code>zig .zigStructPrint = .{ .url = "https://github.com/Durobot/zigStructPrint/archive/&lt;COMMIT HASH, 40 HEX DIGITS&gt;.tar.gz", .hash = "&lt;ZIG PACKAGE HASH, 68 HEX DIGITS&gt;" // Use arbitrary hash, get correct hash from the error }</code> <ol> <li>In <code>build.zig</code>, in <code>pub fn build</code>, before <code>b.installArtifact(exe);</code>, add</li> </ol> <code>zig const zsp = b.dependency("zigStructPrint", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("zigStructPrint", zsp.module("zigStructPrint"));</code> Build with <code>zig build</code>, as you normally do. Actually printing out your struct: ```zig const zsp = @import("zigStructPrint"); . . . const MyStruct = struct { a: i8 = -10, b: u32 = 10, c: [3]u8 = [_]u8 { 1, 2, 3 }, d: [2]Nested = .{ .{ .f = 10.0, .g = "Hello" }, .{ .f = -20.0, .g = "Bye" }, }, e: [3]Color = .{ .red, .green, .yellow }, <code>const Nested = struct { f: f32, g: []const u8 }; const Color = enum { red, yellow, green }; </code> }; const ms = MyStruct {}; zsp.printStruct(ms, true, 0); // try <code>false</code> to get full type names ``` And the output is: <code>zig { a: i8 = -10 b: u32 = 10 c: [3]u8 = [ 1, 2, 3, ] d: [2]Nested = [ { f: f32 = 10, g: []const u8 = "Hello", }, { f: f32 = -20, g: []const u8 = "Bye", }, ] e: [3]Color = [ red, green, yellow, ] }</code>
[]
https://avatars.githubusercontent.com/u/48999343?v=4
sysexits-zig
sorairolake/sysexits-zig
2024-05-04T11:55:57Z
The system exit codes as defined by <sysexits.h> for Zig
develop
0
1
1
1
https://api.github.com/repos/sorairolake/sysexits-zig/tags
Apache-2.0
[ "exitcode", "sysexits", "zig", "zig-library", "zig-package", "ziglang" ]
99
false
2025-05-12T22:03:00Z
true
true
0.14.0
github
[]
sysexits-zig <a></a> <strong>sysexits-zig</strong> is a library that provides the system exit code constants as defined by [<code>&lt;sysexits.h&gt;</code>]. This library is a port of <a>sysexits-rs</a>. Usage Add this package to your <code>build.zig.zon</code>: <code>sh zig fetch --save git+https://github.com/sorairolake/sysexits-zig.git</code> Add the following to your <code>build.zig</code>: <code>zig const sysexits = b.dependency("sysexits", .{}); exe.root_module.addImport("sysexits", sysexits.module("sysexits"));</code> Documentation To build the documentation: <code>sh zig build doc</code> The result is generated in <code>zig-out/doc/sysexits</code>. If you want to preview this, run a HTTP server locally. For example: <code>sh python -m http.server -d zig-out/doc/sysexits</code> Then open <code>http://localhost:8000/</code> in your browser. Zig version This library is compatible with Zig version 0.14.0. Source code The upstream repository is available at <a>https://github.com/sorairolake/sysexits-zig.git</a>. The source code is also available at: <ul> <li><a>https://gitlab.com/sorairolake/sysexits-zig.git</a></li> <li><a>https://codeberg.org/sorairolake/sysexits-zig.git</a></li> </ul> Changelog Please see <a>CHANGELOG.adoc</a>. Contributing Please see <a>CONTRIBUTING.adoc</a>. Similar projects <ul> <li><a>https://github.com/sorairolake/Sysexits.jl</a> (Julia)</li> <li><a>https://github.com/sorairolake/sysexits-rs</a> (Rust)</li> </ul> You can discover more projects at <a>https://github.com/sorairolake/awesome-sysexits</a>. License Copyright (C) 2023 Shun Sakai (see <a>AUTHORS.adoc</a>) This library is distributed under the terms of either the <em>Apache License 2.0</em> or the <em>MIT License</em>. This project is compliant with version 3.3 of the <a><em>REUSE Specification</em></a>. See copyright notices of individual files for more details on copyright and licensing information.
[]
https://avatars.githubusercontent.com/u/48649707?v=4
zig-exhaustigen
tensorush/zig-exhaustigen
2024-07-17T18:44:59Z
Zig port of exhaustigen-rs library for exhaustive testing.
main
0
1
0
1
https://api.github.com/repos/tensorush/zig-exhaustigen/tags
MIT
[ "zig-package" ]
12
false
2025-05-04T02:07:17Z
true
true
0.14.0
github
[]
zig-exhaustigen Zig port of <a>exhaustigen-rs library</a> for exhaustive testing. Usage <ul> <li>Add <code>exhaustigen</code> dependency to <code>build.zig.zon</code>.</li> </ul> <code>sh zig fetch --save git+https://github.com/tensorush/zig-exhaustigen</code> <ul> <li>Use <code>exhaustigen</code> dependency in <code>build.zig</code>.</li> </ul> <code>zig const exhaustigen_dep = b.dependency("exhaustigen", .{ .target = target, .optimize = optimize, }); const exhaustigen_mod = exhaustigen_dep.module("Gen"); &lt;compile&gt;.root_module.addImport("Gen", exhaustigen_mod);</code>
[]
https://avatars.githubusercontent.com/u/25912761?v=4
zigenity
r4gus/zigenity
2024-03-03T15:07:13Z
Like zenity but in Zig
master
0
1
0
1
https://api.github.com/repos/r4gus/zigenity/tags
MIT
[ "gtk", "gtk3", "gui", "zig", "zig-package" ]
39
false
2025-05-11T21:44:52Z
true
true
0.14.0
github
[ { "commit": "a1717e0d0758417cc59de63ab0d65592d08a03ff", "name": "dvui", "tar_url": "https://github.com/david-vanderson/dvui/archive/a1717e0d0758417cc59de63ab0d65592d08a03ff.tar.gz", "type": "remote", "url": "https://github.com/david-vanderson/dvui" } ]
zigenity Like <a>zenity</a> but in <a>Zig</a> and only for Linux. Dialog Types | Type | Supported | |:----:|:---------:| | calendar | | | entry | | | error | | | info | | | file-selection | | | list | | | notification | | | progress | | | question | ✅ | | warning | | | scale | | | text-info | | | color-selection | | | password | ✅ | | forms | | Getting started Run <code>zigenity --help</code> for a list of options. This application uses the same return codes and options as <a>zenity</a>, including: * <code>0</code> - Ok button was pressed * <code>1</code> - Cancel button was pressed * <code>5</code> - Timeout (this is only returned when using the <code>--timeout</code> option) * <code>255</code> - Some other error (e.g., no dialog type has been selected)
[]
https://avatars.githubusercontent.com/u/146390816?v=4
cfitsio
allyourcodebase/cfitsio
2024-07-16T10:22:37Z
Zig build of CFITSIO library.
main
0
1
0
1
https://api.github.com/repos/allyourcodebase/cfitsio/tags
MIT
[ "cfitsio", "fits", "fits-files", "fits-image", "fitsio", "zig", "zig-lang", "zig-language", "zig-library", "zig-package", "ziglang" ]
12
false
2024-07-24T11:00:42Z
true
true
0.13.0
github
[ { "commit": "cfitsio4_4_1_20240617.tar.gz", "name": "cfitsio", "tar_url": "https://github.com/HEASARC/cfitsio/archive/cfitsio4_4_1_20240617.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/HEASARC/cfitsio" } ]
cfitsio <a></a> <a></a> Zig build of <a>cfitsio library</a>. :rocket: Usage <ul> <li>Add <code>cfitsio</code> dependency to <code>build.zig.zon</code>.</li> </ul> <code>sh zig fetch --save https://github.com/allyourcodebase/cfitsio/archive/&lt;git_tag_or_commit_hash&gt;.tar.gz</code> <ul> <li>Use <code>cfitsio</code> dependency in <code>build.zig</code>.</li> </ul> <code>zig const cfitsio_dep = b.dependency("cfitsio", .{ .target = target, .optimize = optimize, }); const cfitsio_mod = cfitsio_dep.module("cfitsio"); &lt;compile&gt;.root_module.addImport("cfitsio", cfitsio_mod);</code>
[ "https://github.com/allyourcodebase/cfitsio" ]
https://avatars.githubusercontent.com/u/4185906?v=4
zig-ulid
Vemahk/zig-ulid
2024-06-17T03:55:29Z
A binary, zero-allocation Ulid implementation written in Zig.
master
0
1
0
1
https://api.github.com/repos/Vemahk/zig-ulid/tags
MIT
[ "zig-package" ]
12
false
2024-07-21T01:17:32Z
true
true
0.12.0
github
[]
zig-ulid A binary, zero-alloc <a>zig</a> implementation of <a>Ulid</a>. Tested with zig 0.12.0 and 0.13.0. If not for b.path(), it would probably work for 0.11.0. Features <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> No allocations <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> To/From String <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Monotonicity Examples ```zig // Default usage const Ulid = @import("ulid"); const id = Ulid.new(); const str = id.toString(); // e.g. "01J0J510YN2KZV7APEE1BQ8BYP" const copy = try Ulid.parseString(str); // == id const epoch_ms: u48 = ulid.timestamp(); const random_data: [10]u8 = ulid.data(); // Monotonic var monotonic = Ulid.MonotonicFactory{}; const ulid_1 = try monotonic.next(); // e.g. "01J0JBY3EXAVVZ227VE93QJD2M" const ulid_2 = try monotonic.next(); // e.g. "01J0JBY3EXAVVZ227VE93QJD2N" // or using the global factory (not recommended but available) const ulid_3 = try Ulid.newMonotonic(); // e.g. "01J0JC10BFE2CJB7M2SZXX98NH" const ulid_4 = try Ulid.newMonotonic(); // e.g. "01J0JC10BFE2CJB7M2SZXX98NJ" ``` Use build.zig.zon <code>.ulid = .{ .url = "https://github.com/Vemahk/zig-ulid/archive/&lt;git_commit_hash&gt;.tar.gz", },</code> build.zig ```zig const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const root = b.path("src/main.zig"); const exe = b.addExecutable(.{ .name = "your_project", .root_source_file = root, .target = target, .optimize = optimize, }); const dep_opts = .{ .target = target, .optimize = optimize }; const ulid_mod = b.dependency("ulid", dep_opts).module("ulid"); exe.root_module.addImport("ulid", ulid_mod); b.installArtifact(exe); ```
[]
https://avatars.githubusercontent.com/u/57362253?v=4
wayland.zig
tiawl/wayland.zig
2024-02-28T20:54:45Z
wayland headers packaged for @ziglang
trunk
0
1
1
1
https://api.github.com/repos/tiawl/wayland.zig/tags
Unlicense
[ "binding", "spaceporn", "wayland", "wayland-protocol", "zig", "zig-package", "ziglang" ]
397
false
2025-05-09T12:11:20Z
true
true
0.14.0
github
[ { "commit": "master", "name": "toolbox", "tar_url": "https://github.com/tiawl/toolbox/archive/master.tar.gz", "type": "remote", "url": "https://github.com/tiawl/toolbox" } ]
wayland.zig This is a fork of <a>hexops/wayland-headers</a> which itself gather various <a>Wayland</a> headers <a>GLFW</a> needs. Why this forkception ? The intention under this fork is the same as <a>hexops</a> had when they opened their repository: gather <a>Wayland</a> headers and package them to compile <a>GLFW</a> with <a>Zig</a>. However this repository has subtle differences for maintainability tasks: * No shell scripting, * A cron runs every day to check <a>Wayland</a> repositories. Then it updates this repository if a new release is available. How to use it The current usage of this repository is centered around <a>tiawl/glfw.zig</a> compilation. But you could use it for your own projects. Headers are here and there are no planned evolution to modify them. See <a>tiawl/glfw.zig</a> to see how you can use it. Maybe for your own need, some headers are missing. If it happens, open an issue: this repository is open to potential usage evolution. Dependencies The <a>Zig</a> part of this package is relying on the latest <a>Zig</a> release (0.14.0) and will only be updated for the next one (so for the 0.14.1). Here the repositories' version used by this fork: * <a>wayland/wayland</a> * <a>wayland/wayland-protocols</a> CICD reminder These repositories are automatically updated when a new release is available: * <a>tiawl/glfw.zig</a> This repository is automatically updated when a new release is available from these repositories: * <a>wayland/wayland</a> * <a>wayland/wayland-protocols</a> * <a>tiawl/toolbox</a> <code>zig build</code> options These additional options have been implemented for maintainability tasks: <code>-Dfetch Update .references folder and build.zig.zon then stop execution -Dupdate Update binding</code> License This repository is not subject to a unique License: The parts of this repository originated from this repository are dedicated to the public domain. See the LICENSE file for more details. <strong>For other parts, it is subject to the License restrictions their respective owners choosed. By design, the public domain code is incompatible with the License notion. In this case, the License prevails. So if you have any doubt about a file property, open an issue.</strong>
[]
https://avatars.githubusercontent.com/u/2828351?v=4
Zig-fmtHelper
bcrist/Zig-fmtHelper
2024-05-13T22:42:38Z
Some std.fmt helpers for Zig programs
main
0
1
0
1
https://api.github.com/repos/bcrist/Zig-fmtHelper/tags
MIT
[ "formatting", "gigabytes", "kilobytes", "megabytes", "units", "utilities", "utility-library", "zig", "zig-library", "zig-package", "ziglang" ]
20
false
2025-05-20T03:59:08Z
true
true
0.14.0
github
[]
Zig-fmtHelper Includes several std.fmt helpers, including: <ul> <li><code>bytes</code>: automatically format large byte values in KB, MB, GB, TB, etc.</li> <li><code>si</code>: automatically format large or small values using SI unit prefixes.</li> </ul> Installation Add to your <code>build.zig.zon</code>: <code>$ zig fetch --save git+https://github.com/bcrist/Zig-fmtHelper</code> Add to your <code>build.zig</code>: ```zig pub fn build(b: *std.Build) void { const fmt_module = b.dependency("fmt_helper", .{}).module("fmt"); <code>//... const exe = b.addExecutable(.{ //... }); exe.root_module.addImport("fmt", fmt_module); //... </code> } ``` Example Usage ```zig pub fn print_stats(some_number_of_bytes: usize, some_number_of_nanoseconds: usize) !void { std.io.getStdOut().writer().print( \ some number of bytes: {} \ some duration: {} \ , .{ fmt.bytes(some_number_of_bytes), fmt.si.ns(some_number_of_nanoseconds), }); } const fmt = @import("fmt"); const std = @import("std"); <code>Possible output:</code> some number of bytes: 3 KB some duration: 47 ms ```
[]
https://avatars.githubusercontent.com/u/164784529?v=4
ja3-spoof
bstrdlord/ja3-spoof
2024-03-28T15:09:29Z
http client for zig that spoofs tls/ssl ja3
main
0
1
0
1
https://api.github.com/repos/bstrdlord/ja3-spoof/tags
-
[ "curl", "ja3", "spoof", "ssl", "tls", "zig", "zig-package" ]
22
false
2024-03-30T01:25:30Z
true
true
unknown
github
[]
TTL/SSL JA3 Spoof <strong>A curl-based zig http client that can spoof <a>tls/ssl ja3</a></strong> 📦 Installing 1. Install ja3_spoof <code>zig fetch --save https://github.com/blockkwork/ja3-spoof/archive/refs/tags/[LATEST TAG].tar.gz</code> Example <code>zig fetch --save https://github.com/blockkwork/ja3-spoof/archive/refs/tags/0.0.1.tar.gz</code> 2. Add ja3_spoof to build.zig Add to build.zig <code>zig const ja3_spoof = b.dependency("ja3_spoof", .{}).module("ja3_spoof"); exe.root_module.addImport("ja3_spoof", ja3_spoof);</code> 🚀 Examples Example in ./examples folder Run with command: <code>make EXAMPLE</code> ```zig const client = ja3_spoof.init(.{ .allocator = allocator, .custom_cookies = "Cookie", .custom_user_agent = "ja3 spoof", .custom_ciphers = "AES256-SHA", }) catch |err| { std.debug.print("error: {}\n", .{err}); return; }; const response = client.send("https://tools.scrapfly.io/api/tls") catch |err| { std.debug.print("error: {}\n", .{err}); return; }; std.debug.print("status_code: {}\nresponse: {s}\n", .{ response.status_code, response.response }); ``` 🛡️ Spoofing To spoof ja3 you need to change .custom_ciphers to any other in Client Options
[]
https://avatars.githubusercontent.com/u/41784264?v=4
zTroy
jinzhongjia/zTroy
2024-06-25T13:34:56Z
a zig library
main
0
1
0
1
https://api.github.com/repos/jinzhongjia/zTroy/tags
-
[ "zig", "zig-package" ]
26
false
2025-05-03T19:19:22Z
true
true
0.12.0
github
[]
zTroy A versatile libary. The goal of this library is to create a general library of basic functional functions <blockquote> Now, this library is developing! </blockquote> Feature <code>.ini</code> parse Install zig version: <code>0.12.0</code> or higher! <ol> <li>Add to <code>build.zig.zon</code></li> </ol> ```sh It is recommended to replace the following branch with commit id zig fetch --save https://github.com/jinzhongjia/zTroy/archive/main.tar.gz Of course, you can also use git+https to fetch this package! ``` <ol> <li>Config <code>build.zig</code></li> </ol> Add this: <code>``zig // To standardize development, maybe you should use</code>lazyDependency()<code>instead of</code>dependency()` // more info to see: https://ziglang.org/download/0.12.0/release-notes.html#toc-Lazy-Dependencies const zTroy = b.dependency("zTroy", .{ .target = target, .optimize = optimize, }); // add module exe.root_module.addImport("tory", zTroy.module("troy")); ``` Document Waiting to be added!
[]
https://avatars.githubusercontent.com/u/98696261?v=4
sap
Reokodoku/sap
2024-08-02T10:35:31Z
A simple argument parser library for zig
main
0
1
0
1
https://api.github.com/repos/Reokodoku/sap/tags
MIT
[ "argument-parser", "zig", "zig-package" ]
28
false
2024-09-05T19:27:20Z
true
true
0.14.0-dev.1421+f87dd43c1
github
[]
sap sap is a simple argument parser library for zig that uses a tuple of flags to create a struct containing the value of the arguments. How to add the library <ol> <li>Run in the terminal: <code>sh zig fetch --save git+https://github.com/Reokodoku/sap</code></li> <li>Add in your <code>build.zig</code>: <code>zig const sap = b.dependency("sap", .{}); exe.root_module.addImport("sap", sap.module("sap"));</code></li> </ol> Examples Minimal example: ```zig const sap = @import("sap"); var arg_parser = sap.Parser(.{ sap.flag([]const u8, "hello", 'h', "world"), }).init(allocator); defer arg_parser.deinit(); const args = try arg_parser.parseArgs(); std.debug.print("Executable name: {s}\n", .{args.executable_name}); var positionals_iter = args.positionals.iterator(); std.debug.print("Positionals:\n", .{}); while (positionals_iter.next()) |str| std.debug.print(" {s}\n", .{str}); std.debug.print("<code>hello</code>|<code>h</code> flag value: {s}\n", .{args.hello}); ``` You can find more examples in the <code>examples/</code> folder. For more information, see the source code or documentation (<code>zig build docs</code>). Features <ul> <li>short arguments</li> <li>long arguments</li> <li>pass values after an equal (<code>--foo=bar</code>) or a space (<code>--foo bar</code>)</li> <li>flags can be specified multiple times</li> <li>flags that call a function</li> <li>supported types:<ul> <li>booleans</li> <li>strings</li> <li>ints (signed and unsigned)</li> <li>floats</li> <li>enums</li> <li>and all optional variants of the above (<code>?bool</code>, <code>?[]const u8</code>, ...)</li> </ul> </li> </ul> Zig version sap targets the master branch of zig. In the <code>build.zig.zon</code> file, there is the <code>minimum_zig_version</code> field which specifies the latest version of zig in which sap compiles. When the zig master branch breaks the compilation, a commit will be merged to: <ul> <li>fix the compilation errors</li> <li>update the <code>minimum_zig_version</code> field with the new zig version</li> </ul>
[]
https://avatars.githubusercontent.com/u/112193680?v=4
zig-river-config
nitrogenez/zig-river-config
2024-06-05T21:31:10Z
River configuration with the power of a programming language.
main
0
1
0
1
https://api.github.com/repos/nitrogenez/zig-river-config/tags
BSD-3-Clause
[ "configuration", "river", "riverwm", "utility", "wayland", "wayland-compositor", "zig", "zig-lang", "zig-language", "zig-library", "zig-package", "ziglang" ]
22
false
2024-06-09T07:00:17Z
true
true
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/28966224?v=4
escalator
weskoerber/escalator
2024-05-23T02:36:36Z
A library for privelege-escalation written in Zig.
main
1
1
0
1
https://api.github.com/repos/weskoerber/escalator/tags
MIT
[ "zig", "zig-package" ]
4
false
2024-08-09T03:29:37Z
true
true
0.12.0
github
[]
Escalator A library for privelege-escalation written in Zig. Requirements <ul> <li><a>zig</a> compiler (<code>0.12.0</code> or newer)</li> </ul> Install First, add the dependency to your <code>build.zig.zon</code> using <code>zig fetch</code>: <code>console zig fetch --save git+https://github.com/weskoerber/escalator#main</code> Then, import <code>escalator</code> into your <code>build.zig</code>: ```zig const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); <code>const escalator = b.dependency("escalator", .{ .target = target, .optimize = optimize, }).module("escalator"); const my_exe = b.addExecutable(.{ .name = "my_exe", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); my_exe.root_module.addImport(escalator); </code> } ``` Usage Documentation can be found at https://weskoerber.github.io/escalator. The docs are generated by Zig's autodoc feature and deployed via Github Actions. Also see the <code>examples</code> directory for example usage. Example executables can be built by setting the <code>examples</code> option to <code>true</code>: <code>zig const mac_address = b.dependency("escalator", .{ .target = target, .optimize = optimize, .examples = true, }).module("escalator");</code> Acknowlegments <ul> <li><a>dns2utf8/sudo.rs</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/146390816?v=4
rabbitmq-c
allyourcodebase/rabbitmq-c
2024-08-03T17:29:16Z
RabbitMQ C client (zig build)
zig-build
0
1
1
1
https://api.github.com/repos/allyourcodebase/rabbitmq-c/tags
MIT
[ "librabbitmq-c", "rabbitmq", "rabbitmq-client", "zig-build", "zig-package" ]
2,201
true
2025-05-17T14:46:59Z
true
false
unknown
github
[]
RabbitMQ C AMQP client library <a></a> <a></a> <a></a> Introduction This is a C-language AMQP client library for use with v2.0+ of the <a>RabbitMQ</a> broker. <ul> <li><a>http://github.com/alanxz/rabbitmq-c</a></li> </ul> Announcements regarding the library are periodically made on the rabbitmq-c-users and cross-posted to rabbitmq-users. <ul> <li><a>https://groups.google.com/forum/#!forum/rabbitmq-c-users</a></li> <li><a>https://groups.google.com/forum/#!forum/rabbitmq-users</a></li> </ul> Latest Stable Version The latest stable release of rabbitmq-c can be found at: <ul> <li><a>https://github.com/alanxz/rabbitmq-c/releases/latest</a></li> </ul> Documentation API documentation for v0.8.0+ can viewed from: <a>http://alanxz.github.io/rabbitmq-c/docs/0.8.0/</a> Getting started Building and installing Prereqs: <ul> <li><a>CMake v3.22 or better</a></li> <li>A C compiler (GCC 4.4+, clang, and MSVC are test. Other compilers may also work)</li> <li><em>Optionally</em> <a>OpenSSL</a> v1.1.1+ to enable support for connecting to RabbitMQ over SSL/TLS</li> <li><em>Optionally</em> <a>POpt</a> to build some handy command-line tools.</li> <li><em>Optionally</em> <a>XmlTo</a> to build man pages for the handy command-line tools</li> <li><em>Optionally</em> <a>Doxygen</a> to build developer API documentation.</li> </ul> After downloading and extracting the source from a tarball to a directory (<a>see above</a>), the commands to build rabbitmq-c on most systems are: <code>mkdir build &amp;&amp; cd build cmake .. cmake --build . [--config Release] </code> The --config Release flag should be used in multi-configuration generators e.g., Visual Studio or XCode. It is also possible to point the CMake GUI tool at the CMakeLists.txt in the root of the source tree and generate build projects or IDE workspace Installing the library and optionally specifying a prefix can be done with: <code>cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. cmake --build . [--config Release] --target install </code> More information on CMake can be found on its FAQ (http://www.cmake.org/Wiki/CMake_FAQ) Other interesting flags that can be passed to CMake: <ul> <li><code>BUILD_EXAMPLES=ON/OFF</code> toggles building the examples. OFF by default.</li> <li><code>BUILD_SHARED_LIBS=ON/OFF</code> toggles building rabbitmq-c as a shared library. ON by default.</li> <li><code>BUILD_STATIC_LIBS=ON/OFF</code> toggles building rabbitmq-c as a static library. ON by default.</li> <li><code>BUILD_TESTING=ON/OFF</code> toggles building test code. ON by default.</li> <li><code>BUILD_TOOLS=ON/OFF</code> toggles building the command line tools. By default this is ON if the build system can find the POpt header and library.</li> <li><code>BUILD_TOOLS_DOCS=ON/OFF</code> toggles building the man pages for the command line tools. By default this is ON if BUILD_TOOLS is ON and the build system can find the XmlTo utility.</li> <li><code>ENABLE_SSL_SUPPORT=ON/OFF</code> toggles building rabbitmq-c with SSL support. By default this is ON if the OpenSSL headers and library can be found.</li> <li><code>BUILD_API_DOCS=ON/OFF</code> - toggles building the Doxygen API documentation, by default this is OFF</li> <li><code>RUN_SYSTEM_TESTS=ON/OFF</code> toggles building the system tests (i.e. tests requiring an accessible RabbitMQ server instance on localhost), by default this is OFF</li> </ul> Building RabbitMQ - Using vcpkg You can download and install RabbitMQ using the <a>vcpkg</a> dependency manager: <code>git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install librabbitmq </code> The RabbitMQ port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please <a>create an issue or pull request</a> on the vcpkg repository. Running the examples Arrange for a RabbitMQ or other AMQP server to be running on <code>localhost</code> at TCP port number 5672. In one terminal, run <code>./examples/amqp_listen localhost 5672 amq.direct test </code> In another terminal, <code>./examples/amqp_sendstring localhost 5672 amq.direct test "hello world" </code> You should see output similar to the following in the listener's terminal window: <code>Delivery 1, exchange amq.direct routingkey test Content-type: text/plain ---- 00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64 hello world 0000000B: </code> Writing applications using <code>librabbitmq</code> Please see the <code>examples</code> directory for short examples of the use of the <code>librabbitmq</code> library. Threading You cannot share a socket, an <code>amqp_connection_state_t</code>, or a channel between threads using <code>librabbitmq</code>. The <code>librabbitmq</code> library is built with event-driven, single-threaded applications in mind, and does not yet cater to any of the requirements of <code>pthread</code>ed applications. Your applications instead should open an AMQP connection (and an associated socket, of course) per thread. If your program needs to access an AMQP connection or any of its channels from more than one thread, it is entirely responsible for designing and implementing an appropriate locking scheme. It will generally be much simpler to have a connection exclusive to each thread that needs AMQP service. License &amp; Copyright Portions created by Alan Antonuk are Copyright (c) 2012-2021 Alan Antonuk. All Rights Reserved. Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. All Rights Reserved. Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[]
https://avatars.githubusercontent.com/u/53385738?v=4
zig-pkg
roastpie/zig-pkg
2024-04-12T11:55:13Z
Zig Package Aggregator
main
0
1
0
1
https://api.github.com/repos/roastpie/zig-pkg/tags
-
[ "zig-package", "ziglang" ]
0
false
2024-04-28T23:17:19Z
false
false
unknown
github
[]
Zig Package Aggregator
[]
https://avatars.githubusercontent.com/u/57362253?v=4
spirv.zig
tiawl/spirv.zig
2024-04-08T17:05:20Z
spirv-tools packaged for @ziglang
trunk
0
1
1
1
https://api.github.com/repos/tiawl/spirv.zig/tags
Unlicense
[ "binding", "spaceporn", "spirv", "spirv-tools", "zig", "zig-package", "ziglang" ]
3,225
false
2025-05-21T09:17:48Z
true
true
0.14.0
github
[ { "commit": "master", "name": "toolbox", "tar_url": "https://github.com/tiawl/toolbox/archive/master.tar.gz", "type": "remote", "url": "https://github.com/tiawl/toolbox" } ]
spirv.zig This is a fork of <a>hexops/spirv-tools</a> which itself is a fork of <a>KhronosGroup/SPIRV-Tools</a>. Why this forkception ? The intention under this fork is the same as <a>hexops</a> had when they forked <a>KhronosGroup/SPIRV-Tools</a>: package the headers for <a>Zig</a>. So: * Unnecessary files have been deleted, * The build system has been replaced with <code>build.zig</code>. However this repository has subtle differences for maintainability tasks: * No shell scripting, * A cron runs every day to check <a>KhronosGroup/SPIRV-Tools</a> and <a>KhronosGroup/SPIRV-Headers</a>. Then it updates this repository if a new release is available. How to use it The current usage of this repository is centered around <a>tiawl/shaderc.zig</a> compilation. But you could use it for your own projects. Headers are here and there are no planned evolution to modify them. See <a>tiawl/shaderc.zig</a> to see how you can use it. Maybe for your own need, some headers are missing. If it happens, open an issue: this repository is open to potential usage evolution. Dependencies The <a>Zig</a> part of this package is relying on the latest <a>Zig</a> release (0.14.0) and will only be updated for the next one (so for the 0.14.1). Here the repositories' version used by this fork: * <a>KhronosGroup/SPIRV-Tools</a> * <a>KhronosGroup/SPIRV-Headers</a> CICD reminder These repositories are automatically updated when a new release is available: * <a>tiawl/shaderc.zig</a> This repository is automatically updated when a new release is available from these repositories: * <a>KhronosGroup/SPIRV-Tools</a> * <a>KhronosGroup/SPIRV-Headers</a> * <a>tiawl/toolbox</a> <code>zig build</code> options These additional options have been implemented for maintainability tasks: <code>-Dfetch Update .references folder and build.zig.zon then stop execution -Dupdate Update binding</code> License This repository is not subject to a unique License: The parts of this repository originated from this repository are dedicated to the public domain. See the LICENSE file for more details. <strong>For other parts, it is subject to the License restrictions their respective owners choosed. By design, the public domain code is incompatible with the License notion. In this case, the License prevails. So if you have any doubt about a file property, open an issue.</strong>
[]
https://avatars.githubusercontent.com/u/57362253?v=4
glslang.zig
tiawl/glslang.zig
2024-04-09T10:07:03Z
glslang packaged for @ziglang
trunk
0
1
2
1
https://api.github.com/repos/tiawl/glslang.zig/tags
Unlicense
[ "binding", "glslang", "spaceporn", "zig", "zig-package", "ziglang" ]
2,058
false
2025-05-21T09:18:50Z
true
true
0.14.0
github
[ { "commit": "master", "name": "toolbox", "tar_url": "https://github.com/tiawl/toolbox/archive/master.tar.gz", "type": "remote", "url": "https://github.com/tiawl/toolbox" } ]
glslang.zig This is a fork of <a>KhronosGroup/glslang</a> packaged for <a>Zig</a> Why this fork ? The intention under this fork is to package <a>KhronosGroup/glslang</a> for <a>Zig</a>. So: * Unnecessary files have been deleted, * The build system has been replaced with <code>build.zig</code>, * A cron runs every day to check <a>KhronosGroup/glslang</a>. Then it updates this repository if a new release is available. How to use it The goal of this repository is not to provide a <a>Zig</a> binding for <a>KhronosGroup/glslang</a>. There are at least as many legit ways as possible to make a binding as there are active accounts on Github. So you are not going to find an answer for this question here. The point of this repository is to abstract the <a>KhronosGroup/glslang</a> compilation process with <a>Zig</a> (which is not new comers friendly and not easy to maintain) to let you focus on your application. So you can use <strong>glslang.zig</strong>: - as raw (no available example, open an issue if you are interested in, we will be happy to help you), - as a daily updated interface for your <a>Zig</a> binding of <a>KhronosGroup/glslang</a> (again: no available example). Important note The current usage of this repository is centered around <a>tiawl/shaderc.zig</a> compilation. So for your usage it could break because some files have been filtered in the process. If it happens, open an issue: this repository is open to potential usage evolution. Dependencies The <a>Zig</a> part of this package is relying on the latest <a>Zig</a> release (0.14.0) and will only be updated for the next one (so for the 0.14.1). Here the repositories' version used by this fork: * <a>KhronosGroup/glslang</a> CICD reminder These repositories are automatically updated when a new release is available: * <a>tiawl/shaderc.zig</a> This repository is automatically updated when a new release is available from these repositories: * <a>KhronosGroup/glslang</a> * <a>tiawl/toolbox</a> <code>zig build</code> options These additional options have been implemented for maintainability tasks: <code>-Dfetch Update .references folder and build.zig.zon then stop execution -Dupdate Update binding</code> License This repository is not subject to a unique License: The parts of this repository originated from this repository are dedicated to the public domain. See the LICENSE file for more details. <strong>For other parts, it is subject to the License restrictions their respective owners choosed. By design, the public domain code is incompatible with the License notion. In this case, the License prevails. So if you have any doubt about a file property, open an issue.</strong>
[]
https://avatars.githubusercontent.com/u/85372264?v=4
zstd.zig
Syndica/zstd.zig
2024-03-21T16:09:03Z
Zig binding of Z Standard
master
0
1
0
1
https://api.github.com/repos/Syndica/zstd.zig/tags
MIT
[ "zig", "zig-package" ]
513
true
2024-11-08T12:27:37Z
true
true
unknown
github
[ { "commit": "794ea1b0afca0f020f4e57b6732332231fb23c70.tar.gz", "name": "zstd", "tar_url": "https://github.com/facebook/zstd/archive/794ea1b0afca0f020f4e57b6732332231fb23c70.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/facebook/zstd" } ]
zstd.zig Zig binding of Z Standard based on <em><code>v1.5.2</code></em> how to import in your <code>build.zig</code>: ```zig pub fn build(b: *std.Build) void { // ... <code>const zstd_dep = b.dependency("zstd", opts); const zstd_mod = zstd_dep.module("zstd"); const zstd_c_lib = zstd_dep.artifact("zstd"); const exec = ... // link it exec.addModule("zstd", zstd_mod); exec.linkLibrary(zstd_c_lib); // ... </code> } ``` usage ```zig const ZstdReader = @import("zstd").Reader; ... pub fn main() { const path = ... <code>const file = try std.fs.cwd().openFile(path, .{}); defer file.close(); const file_stat = try file.stat(); const file_size: u64 = @intCast(file_stat.size); var memory = try std.os.mmap( null, file_size, std.os.PROT.READ, std.os.MAP.PRIVATE, file.handle, 0, ); var decompressed_stream = try ZstdReader.init(memory); var reader = decompressed_stream.reader(); ... </code> } ```
[]
https://avatars.githubusercontent.com/u/28365338?v=4
concurrent-channel
ahmdhusam/concurrent-channel
2024-05-22T23:22:00Z
A thread-safe communication channel for concurrent programming in Zig.
master
0
1
0
1
https://api.github.com/repos/ahmdhusam/concurrent-channel/tags
-
[ "zig-library", "zig-package" ]
7
false
2024-10-28T14:31:43Z
true
true
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/2828351?v=4
tempora
bcrist/tempora
2024-03-09T02:04:51Z
Simple Zig Dates/Times/Timezones
main
0
1
0
1
https://api.github.com/repos/bcrist/tempora/tags
MIT
[ "calendar", "date", "datetime", "time", "tz", "tzdata", "tzinfo", "zig", "zig-library", "zig-package", "ziglang" ]
358
false
2025-02-14T02:25:44Z
true
true
0.14.0-dev.3217+5b9b5e45c
github
[]
Tempora Simple Zig Dates/Times/Timezones Features <ul> <li>Efficient storage (32b <code>Time</code>, 32b <code>Date</code>, 64b <code>Date_Time</code>)</li> <li>Composition and decomposition (year, ordinal day/week, month, day, weekday, hour, minute, second, ms)</li> <li>Add/subtract days/hours/minutes/seconds/ms</li> <li>Advance to the next weekday/day/ordinal day</li> <li>Convert to/from unix timestamps</li> <li>Embedded IANA timezone database and modified version of <a>zig-tzif</a> (adds about 200k to binary size when used)</li> <li>Query current timezone on both unix and Windows systems</li> <li>Moment.js style formatting and parsing (through <code>std.fmt</code>)</li> </ul> Limitations <ul> <li>It's not possible to store most "out of bounds" dates/times (e.g. Jan 32).</li> <li>Localized month and weekday names are not supported; only English.</li> <li>Non-Gregorian calendars are not supported.</li> <li>Date/time values directly correspond to timestamps, so accurate durations that take leap seconds into account are not possible (but leap seconds are being abolished in 2035 anyway).</li> <li>I am certain that there are more optimized algorithms for timestamp &lt;--&gt; calendar conversions (but performance should be fine for all but the most demanding use cases).</li> </ul>
[ "https://github.com/bcrist/shittip" ]
https://avatars.githubusercontent.com/u/16764864?v=4
zigpokerhands
andy5995/zigpokerhands
2024-03-12T07:04:23Z
A program that uses zigdeck to evaluate five cards to determine if it matches a poker hand
trunk
1
1
0
1
https://api.github.com/repos/andy5995/zigpokerhands/tags
MIT
[ "cards", "mit-license", "poker", "simulations", "zig", "zig-package" ]
36
false
2025-03-18T11:36:45Z
true
true
unknown
github
[ { "commit": "master", "name": "zigdeck", "tar_url": "https://github.com/andy5995/zigdeck/releases/download/v0.1.0/zigdeck-0.1.0.tar.gz/archive/master.tar.gz", "type": "remote", "url": "https://github.com/andy5995/zigdeck/releases/download/v0.1.0/zigdeck-0.1.0.tar.gz" } ]
<a></a> zigpokerhands A program that uses <a>zigdeck</a> to evaluate five cards to determine if it matches a poker hand Output examples ``` Evaluating 1000000 hands... <code> Pair: 421692 TwoPair: 47047 ThreeOfAKind: 20578 Straight: 4090 Flush: 2514 FullHouse: 1450 FourOfAKind: 244 StraightFlush: 18 RoyalFlush: 1 </code> ``` ``` Evaluating 1000000 hands... <code> Pair: 421887 TwoPair: 47001 ThreeOfAKind: 20558 Straight: 4168 Flush: 2511 FullHouse: 1378 FourOfAKind: 225 StraightFlush: 21 RoyalFlush: 0 </code> ``` ``` Evaluating 1000000 hands... <code> Pair: 420623 TwoPair: 47240 ThreeOfAKind: 20832 Straight: 4136 Flush: 2587 FullHouse: 1391 FourOfAKind: 252 StraightFlush: 19 RoyalFlush: 2 </code> ```
[]
https://avatars.githubusercontent.com/u/6756180?v=4
zig-scudo
kassane/zig-scudo
2024-07-03T12:45:33Z
Scudo Allocator for Zig
main
0
0
0
0
https://api.github.com/repos/kassane/zig-scudo/tags
Apache-2.0
[ "allocator", "scudo-allocator", "zig-package" ]
156
false
2024-07-05T21:52:38Z
true
true
0.13.0
github
[ { "commit": null, "name": "runner", "tar_url": null, "type": "remote", "url": "git+https://gist.github.com/karlseguin/c6bea5b35e4e8d26af6f81c22cb5d76b/#f303e77231e14b405e4e800072e7deacac4a4881" } ]
scudo-zig Scudo Allocator for Zig Requires <ul> <li><a>Zig</a> v0.13.0 or master</li> </ul> How to use ```bash Create a project $ mkdir project_name $ cd project_name $ zig init get zig-scudo (add on zon file - overwrited) zig fetch --save=scudo git+https://github.com/kassane/zig-scudo ``` In <code>build.zig</code>, add: ```zig // pkg name (same in zon file) const scudo_dep = b.dependency("scudo",.{.target = target, .optimize = optimize }); const scudo_module = scudo_dep.module("scudoAllocator"); // get lib + zig bindings // my project (executable) exe.root_module.addImport("scudoAllocator", scudo_module); ``` References <ul> <li><a>LLVM-Doc: Scudo Allocator</a></li> <li><a>SCUDO Hardened Allocator — Unofficial Internals</a> authored by <a>Rodrigo Rubira</a></li> <li><a>High level overview of Scudo</a> by Kostya</li> <li><a>What is the Scudo hardened allocator?</a> by Kostya</li> <li><a>google/rust-scudo</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/81112205?v=4
zorsig
RohanVashisht1234/zorsig
2024-06-20T18:09:44Z
null
main
0
0
0
0
https://api.github.com/repos/RohanVashisht1234/zorsig/tags
NOASSERTION
[ "zig-package" ]
22
false
2024-11-13T11:23:03Z
true
true
unknown
github
[]
Zorsig: a better morse library for Zig programming language Features: - minimum version of zig: 0.13.0 - Memory safe - No allocators used - High performance library How to use? ```zig const std = @import("std"); const Zorsig = @import("zorsig"); const print = std.debug.print; pub fn main() void { const res1 = Zorsig.char_to_morse('A'); print("{s}\n", .{res1}); <code>const res2 = Zorsig.morse_to_char(".-"); print("{c}\n", .{res2}); // No allocator var res3 = Zorsig.morse_to_string(".... . .-.. .-.. --- --..-- / .-- --- .-. .-.. -.. -.-.--"); while (res3.next()) |next_element| { print("{c}", .{next_element}); } print("\n", .{}); var res4 = Zorsig.string_to_morse("HELLO, WORLD!"); while (res4.next()) |next_element| { print("{s} ", .{next_element}); } </code> } ``` Output: Get started: <strong>Run the following command in your terminal:</strong> <code>sh zig fetch --save "https://github.com/RohanVashisht1234/zorsig/archive/refs/tags/v0.0.1.tar.gz"</code> **Add the following to your build.zig (just above the line <code>b.installArtifact(exe);</code>): ** ```zig const zorsig = b.dependency("zorsig", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("zorsig", zorsig.module("zorsig")); ``` That's it, now use the Zorsig.
[]
https://avatars.githubusercontent.com/u/109492796?v=4
zig-todo-web-app
zigcc/zig-todo-web-app
2024-07-19T06:03:04Z
A Single-page TODO app in Zig!
main
0
0
0
0
https://api.github.com/repos/zigcc/zig-todo-web-app/tags
-
[ "zig", "zig-library", "zig-package", "zig-programming-language", "ziglang" ]
47
false
2024-07-25T15:12:30Z
false
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/36482619?v=4
zig-extras
jkoop/zig-extras
2024-07-29T01:31:44Z
An assortment of random utility functions that aren't in std and don't need to be their own pacakge.
master
0
0
0
0
https://api.github.com/repos/jkoop/zig-extras/tags
MIT
[ "zig-package" ]
109
true
2024-07-29T01:42:39Z
true
true
0.13.0
github
[]
zig-extras An assortment of random utility functions that aren't in std and don't deserve their own package. License MIT
[]
https://avatars.githubusercontent.com/u/6756180?v=4
ffi-flang-zig
kassane/ffi-flang-zig
2024-06-18T15:16:52Z
FFI flang-new runtime with Zig
main
2
0
0
0
https://api.github.com/repos/kassane/ffi-flang-zig/tags
Apache-2.0
[ "cross-compile", "ffi", "ffi-bindings", "flang", "fortran", "llvm", "zig", "zig-package" ]
3,002
false
2025-03-31T13:00:07Z
true
false
unknown
github
[]
ffi-flang-zig FFI between Fortran runtime and Zig <a>LLVM/flang v19.1.7</a> files are included in this repository. Inspired by <a>sourceryinstitute/ISO_Fortran_binding</a>. However, for LLVM-based only! Requires <ul> <li><a>Zig</a> v0.14.0 or master</li> <li><a>Flang</a></li> </ul> How to use Build docker and run image: <code>bash $ docker build -t flang-zig -f .devcontainer/Dockerfile $ docker run -it --rm -v $(pwd):/app -w /app flang-zig bash</code> Build help <code>bash Project-Specific Options: -Doptimize=[enum] Prioritize performance, safety, or binary size Supported Values: Debug ReleaseSafe ReleaseFast ReleaseSmall -Dtarget=[string] The CPU architecture, OS, and ABI to build for -Dcpu=[string] Target CPU features to add or subtract -Ddynamic-linker=[string] Path to interpreter on the target system -Dshared=[bool] Build as shared library [default: false] -Damalgamation=[bool] Build as amalgamation [default: false] -Denable-tests=[bool] Build tests [default: false]</code>
[]
https://avatars.githubusercontent.com/u/1356248?v=4
zargunaught
srjilarious/zargunaught
2024-04-20T14:17:40Z
Zig argument parsing library, based on my C++ argunaught library
main
0
0
0
0
https://api.github.com/repos/srjilarious/zargunaught/tags
MIT
[ "zig", "zig-package" ]
507
false
2025-03-12T22:10:21Z
true
true
0.14.0
github
[]
404
[]
https://avatars.githubusercontent.com/u/2828351?v=4
dizzy
bcrist/dizzy
2024-03-26T01:04:14Z
Zig Comptime Dependency Injection
main
0
0
0
0
https://api.github.com/repos/bcrist/dizzy/tags
MIT
[ "dependency-injection", "zig", "zig-library", "zig-package", "ziglang" ]
11
false
2025-02-14T02:38:15Z
true
true
0.14.0-dev.3217+5b9b5e45c
github
[]
Dizzy Function Parameter Dependency Injection for Zig See test.zig for example usage.
[ "https://github.com/bcrist/shittip", "https://github.com/neurocyte/flow" ]
https://avatars.githubusercontent.com/u/2828351?v=4
zkittle
bcrist/zkittle
2024-05-10T23:40:05Z
A little Zig template engine
main
0
0
0
0
https://api.github.com/repos/bcrist/zkittle/tags
MIT
[ "file-format", "template", "template-engine", "templates", "vscode-extension", "zig", "zig-library", "zig-package", "ziglang" ]
192
false
2025-02-14T02:34:30Z
true
true
0.14.0-dev.3217+5b9b5e45c
github
[ { "commit": "e39301c1d36b3a2aa98a8c7c8e5fa2eaddfd1000", "name": "console_helper", "tar_url": "https://github.com/bcrist/zig-consolehelper/archive/e39301c1d36b3a2aa98a8c7c8e5fa2eaddfd1000.tar.gz", "type": "remote", "url": "https://github.com/bcrist/zig-consolehelper" }, { "commit": "5bb61...
Zkittle A basic templating language for Zig programs. The name is pronounced like "skittle," not "zee kittle". Syntax <code>A template always starts with "literal" text. i.e. text that will just be included in the final document verbatim. You can add data to your templates by surrounding a \\command block// with double slashes. Whitespace inside command blocks is ignored, and it's legal to have an empty \\// command block. \\ $ If a command block contains a $, then // everything else in that command block is considered a comment. \\$ If there is no // to close a block on the same line, it ends at the end of the line. \\$ The final newline character is not included in the output document in this case. \\$ Since comments end at the end of their containing command block, they are also at most one line. Templates are evaluated using a "data context", which is usually a struct value. The \\identifiers// in the command block reference fields of the data struct. You can reference nested data structures the same way you would in Zig: \\ parent_field.child_field // Individual elements of "collections" (arrays and slices) are accessed with '.': \\ some_array.0 // Optionals are treated as a collection of size 0 or 1. The length of a collection can be printed with: \\ some_array.# // Accessing an out-of-bounds element is allowed; it becomes a void value (printing it is a no-op). Tagged union fields can be accessed the same way as structs, but only the active field will resolve to actual data; inactive fields will resolve to void. Values of type void are considered a special 'nil' value. This includes accessing a struct field that doesn't exist, an enum or union tag that isn't active (or doesn't exist), or a collection index that's out of bounds, as well as data explicitly declared to have a type of `void` or `@TypeOf(undefined)`. All values have a \\value.@exists// pseudo-field which converts the value to a bool, where nil becomes false, and anything else becomes true. The special \\*// syntax represents the whole data context (similar to the "this" or "self" pointer in some programming languages). It can be useful when the current data context is not a struct, union, or collection. Identifiers that aren't qualified by '^' can reference a field in the current context, or the first parent context that has a non-nil value for the field. This is useful because sometimes a template is designed to be imported, but you don't know if it will be inside a "within" block. You can explicitly search only the current context by using \\*.field// instead of \\field//. You can "push" a new data context with the ':' operator (a.k.a "within"). This can be useful if you want to access multiple fields of a deeply nested struct. For example, instead of: First Name: \\phonebook.z.ziggleman.0.first// Last Name: \\phonebook.z.ziggleman.0.last// Phone Number: \\phonebook.z.ziggleman.0.phone// we could instead write: \\ phonebook.z.ziggleman.0: First Name: \\first// Last Name: \\last// Phone Number: \\phone// \\ ~ Note that the sequence does not end at the end of the command block, so that it can include literal text easily. Instead, the ~ character ends the region. When the data selected by a "within" block is a collection, the sequence will be evaluated once for each item in the collection. You can print the current index with the \\@index// syntax. When not inside a "within" region, nothing will be output. You can access the entire collection instead of an individual item with \\ ^* //. You can access the "outer" data context with \\ ^^* //. (note this also works when the within block isn't a collection) If you have nested "within" blocks, the '^' prefixes can be chained as needed. The conditional '?' operator only evaluates its subsequent region when its data value is "truthy," but it does not push a new data context: \\ should_render_section? // whatever \\ ~ Boolean false, the number zero, and empty collections (including void-like values) are considered falsey; all other values are truthy. Both ':' and '?' regions may contain a ';' before the '~' to create an "otherwise" region. This region will only be evaluated if the first region is not evaluated. e.g. \\ has_full_name ? full_name ; first_name last_name ~ // \\x / y// is mostly equivalent to \\x? x ; y ~// except that the former can be used as an expression, while the latter always just prints x or y. Similarly \\x | y// is corresponds to \\x.@exists? x ; y ~// in the same way. Application-specific extensions can be added by adding functions to the data context. These functions will be passed the writer, escape functions, and the root data context, as well as a list of any parameters from the template. Calling a function from a template looks like this: \\ :my_func param1 param2 param3 // Note that ":" is used for both function calls and "within" blocks. In order to be treated as a function call, it must be followed immediately by a non-whitespace character. By default all strings will be printed with an HTML escape function. This can be overridden or disabled in code when generating other types of documents. You can also disable it for a specific expression with \\ @raw some_value //. An alternative escaping function can be used for specific expressions with \\ @url some_value //. By default, this will escape using percent encoding; suitable for embedding arbitrary data in URLs. Within command blocks, you can use string literals, wrapped in double quotes, anywhere an expression is expected. Note that no escape sequences are supported; the string literal simply ends as soon as the next double quote is seen, so string literals can never contain a double quote. Often string literals are functionally equivalent to closing the command block and opening another immediately after: \\ "Hellorld!" //Hellorld!\\ \\ $ but string literals also let you do things like: \\ @raw "&lt;table&gt;" $ prevent escaping of HTML tags \\ :func "asdf" $ pass literals to a function String literals can also be used to access fields with names that aren't valid zkittle identifiers. This only works when used after the "." or `^` operators: \\ something."has weird fields"."and even recursive ones" \\ *."I am in the current context" \\ ^^"I'm in the parent context" The \\ @include "path/to/template" // syntax can be used to pull the entire content of another template into the current one. Note that this happens at compile time, not at runtime (the template source is provided to the template parser by a callback). The \\ @resource "whatever" // syntax works similarly to @include, but instead of interpreting the data returned by the callback as template source, it treats it as a raw literal to be printed. Sometimes you may want to render only a part of a template in some cases. To facilitate this, you can define a \\ #fragment_name // to refer to part of the template, ending with the \\~// operator. This doesn't affect how the overall template is rendered, but allows you to access the sub-template by name from code. See https://htmx.org/essays/template-fragments/ for more information about how this technique might be useful. </code>
[ "https://github.com/bcrist/shittip" ]
https://avatars.githubusercontent.com/u/52572989?v=4
zig-time
Protonull/zig-time
2024-05-13T23:27:57Z
zig-time but with Zig packaging
master
0
0
1
0
https://api.github.com/repos/Protonull/zig-time/tags
MIT
[ "zig", "zig-library", "zig-package" ]
87
true
2025-01-18T09:42:16Z
true
true
0.12.0
github
[ { "commit": "3dcc531937b58d787e183c25bad535c91bab1f7d", "name": "zig_extras", "tar_url": "https://github.com/nektro/zig-extras/archive/3dcc531937b58d787e183c25bad535c91bab1f7d.tar.gz", "type": "remote", "url": "https://github.com/nektro/zig-extras" } ]
zig-time This is a fork of <a>zig-time</a> that's uses Zig's native packaging instead of <a>zigmod</a>. Usage Add this repository to your <code>build.zig.zon</code>, eg: <code>zon // build.zig.zon .{ .name = "awesome-project", .version = "0.1.0", .minimum_zig_version = "0.12.0", .paths = .{ "" }, .dependencies = .{ .zig_time = .{ .url = "git+https://github.com/Protonull/zig-time#&lt;COMMIT HASH&gt;", .hash = "&lt;HASH&gt;" // Comment this out Zig will automatically tell you what has to use. }, }, }</code> After that, add the dependency to your build script, eg: ```zig // build.zig const std = @import("std"); pub fn build( b: *std.Build ) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); <code>const exe = b.addExecutable(.{ .name = "awesome-project", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); // zig-time dependency goes here exe.root_module.addImport("zig-time", b.dependency("zig_time", .{}).module("time")); b.installArtifact(exe); </code> } ``` You may notice there's <code>zig-time</code>, <code>zig_time</code>, and <code>time</code>. <ul> <li><code>zig-time</code> is what you'd use as the import, like so: <code>const time = @import("zig-time")</code></li> <li><code>zig_time</code> is the key to match in <code>build.zig.zon</code>, which doesn't like dashes.</li> <li><code>time</code> is the name of the exported module from zig-time, the library itself.</li> </ul>
[]
https://avatars.githubusercontent.com/u/2828351?v=4
shittip
bcrist/shittip
2024-03-30T23:44:17Z
Another shitty HTTP server
main
0
0
0
0
https://api.github.com/repos/bcrist/shittip/tags
MIT
[ "http", "http-server", "server", "zig", "zig-library", "zig-package", "ziglang" ]
167
false
2025-02-14T02:43:54Z
true
true
0.14.0-dev.1694+3b465ebec
github
[ { "commit": "058f6331d499e81df7b58858e7307543d5484404", "name": "Temp_Allocator", "tar_url": "https://github.com/bcrist/zig-tempallocator/archive/058f6331d499e81df7b58858e7307543d5484404.tar.gz", "type": "remote", "url": "https://github.com/bcrist/zig-tempallocator" }, { "commit": "3fcba...
SHITTIP A shitty HTTP server
[]
https://avatars.githubusercontent.com/u/6756180?v=4
tlsf
kassane/tlsf
2024-04-01T18:49:00Z
Two-Level Segregated Fit memory allocator implementation.
main
0
0
0
0
https://api.github.com/repos/kassane/tlsf/tags
-
[ "c", "cmake", "tlsf", "zig-package" ]
20
true
2024-04-01T19:07:13Z
true
true
unknown
github
[]
tlsf Two-Level Segregated Fit memory allocator implementation. Written by Matthew Conte (matt@baisoku.org). Released under the BSD license. Features <ul> <li>O(1) cost for malloc, free, realloc, memalign</li> <li>Extremely low overhead per allocation (4 bytes)</li> <li>Low overhead per TLSF management of pools (~3kB)</li> <li>Low fragmentation</li> <li>Compiles to only a few kB of code and data</li> <li>Support for adding and removing memory pool regions on the fly</li> </ul> Caveats <ul> <li>Currently, assumes architecture can make 4-byte aligned accesses</li> <li>Not designed to be thread safe; the user must provide this</li> </ul> Notes This code was based on the TLSF 1.4 spec and documentation found at: <code>http://www.gii.upv.es/tlsf/main/docs </code> It also leverages the TLSF 2.0 improvement to shrink the per-block overhead from 8 to 4 bytes. History 2016/04/10 - v3.1 * Code moved to github * tlsfbits.h rolled into tlsf.c * License changed to BSD 2014/02/08 - v3.0 * This version is based on improvements from 3DInteractive GmbH * Interface changed to allow more than one memory pool * Separated pool handling from control structure (adding, removing, debugging) * Control structure and pools can still be constructed in the same memory block * Memory blocks for control structure and pools are checked for alignment * Added functions to retrieve control structure size, alignment size, min and max block size, overhead of pool structure, and overhead of a single allocation * Minimal Pool size is tlsf_block_size_min() + tlsf_pool_overhead() * Pool must be empty when it is removed, in order to allow O(1) removal 2011/10/20 - v2.0 * 64-bit support * More compiler intrinsics for ffs/fls * ffs/fls verification during TLSF creation in debug builds 2008/04/04 - v1.9 * Add tlsf_heap_check, a heap integrity check * Support a predefined tlsf_assert macro * Fix realloc case where block should shrink; if adjacent block is in use, execution would go down the slow path 2007/02/08 - v1.8 * Fix for unnecessary reallocation in tlsf_realloc 2007/02/03 - v1.7 * tlsf_heap_walk takes a callback * tlsf_realloc now returns NULL on failure * tlsf_memalign optimization for 4-byte alignment * Usage of size_t where appropriate 2006/11/21 - v1.6 * ffs/fls broken out into tlsfbits.h * tlsf_overhead queries per-pool overhead 2006/11/07 - v1.5 * Smart realloc implementation * Smart memalign implementation 2006/10/11 - v1.4 * Add some ffs/fls implementations * Minor code footprint reduction 2006/09/14 - v1.3 * Profiling indicates heavy use of blocks of size 1-128, so implement small block handling * Reduce pool overhead by about 1kb * Reduce minimum block size from 32 to 12 bytes * Realloc bug fix 2006/09/09 - v1.2 * Add tlsf_block_size * Static assertion mechanism for invariants * Minor bugfixes 2006/09/01 - v1.1 * Add tlsf_realloc * Add tlsf_walk_heap 2006/08/25 - v1.0 * First release
[]
https://avatars.githubusercontent.com/u/160516989?v=4
lumi
Lumi-Engine/lumi
2024-02-19T16:06:29Z
The main Lumi engine repo
main
0
0
0
0
https://api.github.com/repos/Lumi-Engine/lumi/tags
BSD-3-Clause
[ "gamedev", "gamedev-framework", "gamedev-library", "gamedevelopment", "zig", "zig-lang", "zig-language", "zig-lib", "zig-library", "zig-package", "zig-programming-language", "ziglang" ]
68
false
2024-02-19T16:09:57Z
true
true
unknown
github
[ { "commit": "63da35e57c3695a787b927e69e4140eb74ffc234", "name": "mach_glfw", "tar_url": "https://github.com/hexops/mach-glfw/archive/63da35e57c3695a787b927e69e4140eb74ffc234.tar.gz", "type": "remote", "url": "https://github.com/hexops/mach-glfw" } ]
Lumi Engine is a 2D game engine which aims to provide a performant, flexible and easy game development environment.
[]
https://avatars.githubusercontent.com/u/36482619?v=4
zig-time
jkoop/zig-time
2024-07-29T01:18:30Z
zig-time but with Zig packaging
master
0
0
0
0
https://api.github.com/repos/jkoop/zig-time/tags
MIT
[ "zig-package" ]
94
true
2024-07-29T02:54:19Z
true
true
0.13.0
github
[ { "commit": "8e59b16cf18473c7a307fd1441a716bc2b2b802a.zip", "name": "zig_extras", "tar_url": "https://github.com/jkoop/zig-extras/archive/8e59b16cf18473c7a307fd1441a716bc2b2b802a.zip.tar.gz", "type": "remote", "url": "https://github.com/jkoop/zig-extras" } ]
zig-time This is a fork of <a>zig-time</a> that's uses Zig's native packaging instead of <a>zigmod</a>. Usage Add this repository to your <code>build.zig.zon</code>, eg: <code>zon // build.zig.zon .{ .name = "awesome-project", .version = "0.1.0", .minimum_zig_version = "0.12.0", .paths = .{ "" }, .dependencies = .{ .zig_time = .{ .url = "git+https://github.com/Protonull/zig-time#&lt;COMMIT HASH&gt;", .hash = "&lt;HASH&gt;" // Comment this out Zig will automatically tell you what has to use. }, }, }</code> After that, add the dependency to your build script, eg: ```zig // build.zig const std = @import("std"); pub fn build( b: *std.Build ) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); <code>const exe = b.addExecutable(.{ .name = "awesome-project", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); // zig-time dependency goes here exe.root_module.addImport("zig-time", b.dependency("zig_time", .{}).module("time")); b.installArtifact(exe); </code> } ``` You may notice there's <code>zig-time</code>, <code>zig_time</code>, and <code>time</code>. <ul> <li><code>zig-time</code> is what you'd use as the import, like so: <code>const time = @import("zig-time")</code></li> <li><code>zig_time</code> is the key to match in <code>build.zig.zon</code>, which doesn't like dashes.</li> <li><code>time</code> is the name of the exported module from zig-time, the library itself.</li> </ul>
[]
https://avatars.githubusercontent.com/u/170934839?v=4
zig-utilities
Ang3lERR404/zig-utilities
2024-06-03T17:01:27Z
Utilities for zig, in a smol, convenient file
main
0
0
0
0
https://api.github.com/repos/Ang3lERR404/zig-utilities/tags
GPL-3.0
[ "utilities", "zig", "zig-package", "ziglang" ]
14
false
2024-06-11T20:08:52Z
false
false
unknown
github
[]
Utils.zig A smol utility library before skill issues were found :D <strong><em>IN THE ENTIRE STANDARD LIBRARY FOR ZIG</em></strong> =~= <blockquote> W h y\ a r e\ y o u\ l i k e\ t h i s </blockquote>
[]
https://avatars.githubusercontent.com/u/1562827?v=4
combinato
travisstaloch/combinato
2024-07-01T12:10:36Z
Parser combinators in zig
main
0
0
0
0
https://api.github.com/repos/travisstaloch/combinato/tags
MIT
[ "parser-combinators", "zig-package" ]
30
false
2024-08-17T03:41:06Z
true
true
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/46655455?v=4
zbencode
4zv4l/zbencode
2024-07-05T04:21:48Z
zig bencode library
main
0
0
0
0
https://api.github.com/repos/4zv4l/zbencode/tags
GPL-3.0
[ "zig-package" ]
77
false
2025-02-02T14:49:24Z
true
true
unknown
github
[]
zbencode zig bencode library Example of usage ```zig const std = @import("std"); const bencode = @import("bencode"); const sizeFmt = std.fmt.fmtIntSizeBin; pub fn main() !void { // setup + args const allocator = std.heap.page_allocator; const args = try std.process.argsAlloc(allocator); defer std.process.argsFree(allocator, args); if (args.len != 2) { print("usage: {s} [file.torrent]\n", .{args[0]}); return; } <code>// read file + decoding const data = try std.fs.cwd().readFileAlloc(tally, "debian.torrent", 1 * 1024 * 1024); defer tally.free(data); var arena = std.heap.ArenaAllocator.init(tally); var bencode = try parse(&amp;arena, data); defer bencode.deinit(&amp;arena); // pretty print const root = bencode.dictionnary; const info = root.get("info").?.dictionnary; std.debug.print("name : {}\n", .{info.get("name").?}); std.debug.print("length : {}\n", .{sizeFmt(@intCast(info.get("length").?.integer))}); std.debug.print("tracker: {}\n", .{root.get("announce").?}); std.debug.print("creator: {}\n", .{root.get("created by").?}); std.debug.print("created: {}\n", .{root.get("creation date").?}); </code> ``` <code>$ btest debian.torrent name : debian-12.9.0-amd64-netinst.iso length : 632MiB tracker: http://bttracker.debian.org:6969/announce creator: mktorrent 1.1 created: 1736599700</code>
[]
https://avatars.githubusercontent.com/u/48649707?v=4
zig-quickphf
tensorush/zig-quickphf
2024-03-25T20:41:27Z
Zig port of quickphf library for static hash map generation.
main
0
0
0
0
https://api.github.com/repos/tensorush/zig-quickphf/tags
MIT
[ "zig-package" ]
24
false
2025-03-18T06:57:05Z
true
true
unknown
github
[]
zig-quickphf Zig port of <a>quickphf library</a> for static hash map generation. Usage <ul> <li>Add <code>quickphf</code> dependency to <code>build.zig.zon</code>.</li> </ul> <code>sh zig fetch --save git+https://github.com/tensorush/zig-quickphf</code> <ul> <li>Use <code>quickphf</code> dependency in <code>build.zig</code>.</li> </ul> <code>zig const quickphf_dep = b.dependency("quickphf", .{ .target = target, .optimize = optimize, }); const quickphf_mod = quickphf_dep.module("quickphf"); &lt;compile&gt;.root_module.addImport("quickphf", quickphf_mod);</code>
[]
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
7