avatar_url
stringlengths 46
116
⌀ | name
stringlengths 1
46
| full_name
stringlengths 7
60
| created_at
stringdate 2016-04-01 08:17:56
2025-05-20 11:38:17
| description
stringlengths 0
387
⌀ | default_branch
stringclasses 45
values | open_issues
int64 0
4.93k
| stargazers_count
int64 0
78.2k
| forks_count
int64 0
3.09k
| watchers_count
int64 0
78.2k
| tags_url
stringlengths 0
94
| license
stringclasses 27
values | topics
listlengths 0
20
| size
int64 0
4.82M
| fork
bool 2
classes | updated_at
stringdate 2018-11-13 14:41:18
2025-05-22 08:23:54
| has_build_zig
bool 2
classes | has_build_zig_zon
bool 2
classes | zig_minimum_version
stringclasses 60
values | repo_from
stringclasses 3
values | dependencies
listlengths 0
121
| readme_content
stringlengths 0
437k
| dependents
listlengths 0
21
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
https://avatars.githubusercontent.com/u/24614?v=4 | LearnZig | ryogrid/LearnZig | 2023-02-03T06:41:19Z | Execution time comparison of fib(46) between raw JS and WebAssembly on web browser | main | 0 | 2 | 0 | 2 | https://api.github.com/repos/ryogrid/LearnZig/tags | - | [
"wasm",
"web",
"webassembly",
"zig"
]
| 98 | false | 2023-02-06T12:53:40Z | true | false | unknown | github | []
| LearnZig
<ul>
<li>build</li>
<li>
$zig build -Drelease-fast=true
</li>
<li>
<a>Comparison of execution time of fib(46) between raw JS and wasm</a> (GitHub Pages)
</li>
</ul> | []
|
https://avatars.githubusercontent.com/u/4615889?v=4 | zig-mpack | Techcable/zig-mpack | 2022-05-07T00:58:03Z | Msgpack library for Zig (bindings to ludocode/mpack) | master | 5 | 2 | 0 | 2 | https://api.github.com/repos/Techcable/zig-mpack/tags | MIT | [
"mpack",
"msgpack",
"zig"
]
| 44 | false | 2023-08-31T03:54:41Z | true | false | unknown | github | []
| zig-mpack
Zig bindings to <a>ludocode/mpack</a>.
The underlying library is excellent (and ~60K). We just add a nice Zig wrapper.
The bindings pretty closely match the underlying C API, with a handful exceptions:
<ol>
<li>We convert to zig-style errors for use with <code>try</code>/<code>catch</code></li>
</ol>
TODO?
These bindings are incomplete, please open a PR (or an issue) if there is something you need and we don't have.
In particular, we don't include bindings to the Node API (yet). See issue #4
Type reflection doesn't work with structs. This is fairly difficult to do when input is a map
and the fields can be in any order :( | []
|
https://avatars.githubusercontent.com/u/49621563?v=4 | edsm-in-zig-demo-3 | dee0xeed/edsm-in-zig-demo-3 | 2022-11-08T21:37:36Z | file system events | main | 0 | 2 | 0 | 2 | https://api.github.com/repos/dee0xeed/edsm-in-zig-demo-3/tags | NOASSERTION | [
"event-driven",
"filesystem-events",
"inotify",
"linux",
"state-machines",
"zig"
]
| 21 | false | 2025-02-11T00:25:01Z | true | false | unknown | github | []
| File System Events
This project shows how to track file system
activity using event driven state machines.
Examples
Scanning directory
<code>file system events = 0x40000020
DirMon-1 @ WORK got 'F5' from OS
'/tmp/test/': opened
file system events = 0x40000001
DirMon-1 @ WORK got 'F0' from OS
'/tmp/test/': accessed
file system events = 0x40000001
DirMon-1 @ WORK got 'F0' from OS
'/tmp/test/': accessed
file system events = 0x40000010
DirMon-1 @ WORK got 'F4' from OS
'/tmp/test/': closed (read)</code>
Touching a file
<code>file system events = 0x00000020
DirMon-1 @ WORK got 'F5' from OS
'a': opened
file system events = 0x00000004
DirMon-1 @ WORK got 'F2' from OS
'a': metadata changed
file system events = 0x00000008
DirMon-1 @ WORK got 'F3' from OS
'a': closed (write)</code> | []
|
https://avatars.githubusercontent.com/u/6756180?v=4 | LKModule-zig | kassane/LKModule-zig | 2022-04-29T20:08:05Z | Zig Kernel Module | main | 0 | 2 | 0 | 2 | https://api.github.com/repos/kassane/LKModule-zig/tags | GPL-2.0 | [
"linux-module",
"zig"
]
| 40 | false | 2025-05-06T01:27:51Z | true | false | unknown | github | []
| Linux Kernel Module on Zig
Build linux kernel module with zig.
TODO
<ul>
<li>More tests.</li>
</ul>
Requires
<ul>
<li>Zig v0.9.0 or later.</li>
<li>You need kernel headers and gcc toolchain (with build-essential [debian] or base-devel [archlinux]).</li>
</ul>
Build with:
<code>bash
make</code> | []
|
https://avatars.githubusercontent.com/u/135217?v=4 | zigos | gthvn1/zigos | 2023-02-07T10:49:48Z | An experimental micro kernel written in Zig | master | 0 | 2 | 0 | 2 | https://api.github.com/repos/gthvn1/zigos/tags | GPL-3.0 | [
"microkernel",
"x86",
"zig"
]
| 24 | false | 2023-11-22T18:05:15Z | true | false | unknown | github | []
| 404 | []
|
https://avatars.githubusercontent.com/u/571433?v=4 | znake | JustinRyanH/znake | 2022-02-19T02:25:11Z | Multiple Implementations of Snake in Zig. One with WASM 4, and one with Sokol | main | 0 | 2 | 0 | 2 | https://api.github.com/repos/JustinRyanH/znake/tags | - | [
"sokol",
"wasm",
"wasm4",
"zig"
]
| 372 | false | 2022-05-19T23:05:13Z | false | false | unknown | github | []
| Znake
Multiple Implementations of Snake using Zig
Wasm 4 Snake
Original implementation
Sokol Snake
Migrated from the Original Wasm4 version, and included an <a>ecs</a>
https://user-images.githubusercontent.com/571433/165212916-c4480257-1210-44d4-b3a9-10f182367b80.mp4 | []
|
https://avatars.githubusercontent.com/u/1678974?v=4 | mongoz | s-leroux/mongoz | 2022-04-26T18:03:26Z | A thin Zig wrapper around the MongoDB C driver | main | 2 | 2 | 2 | 2 | https://api.github.com/repos/s-leroux/mongoz/tags | MIT | [
"client-library",
"mongo",
"mongodb",
"zig",
"ziglang"
]
| 20 | false | 2024-03-17T06:34:54Z | true | false | unknown | github | []
| The goal of this project is to add a thin Zig wrapper arround the Mongo C driver to make it easier to use from Zig programs.
It is also an educatonal project while I learn the Zig languages --
don't hesitate to submit pull requests if you think I didn't do things the Idiomatic Zig way!
Run tests
Debian
<code>apt-get install libmongoc-1.0-0 libmongoc-dev
zig build test</code>
The tests are in the <code>src/main.zig</code> source file.
They assume you have a clean MongoDB instance listening on 127.0.0.1:27017
and accessible with the mongoadmin/mongopass credentials.
The easiest way to achieve that is starting a MongoDB Docker container as shown
in the <code>start-mongo.sh</code> shell script. | []
|
https://avatars.githubusercontent.com/u/128710789?v=4 | asdf-zigmod | mise-plugins/asdf-zigmod | 2022-10-31T16:00:04Z | zigmod plugin for the asdf version manager | main | 4 | 2 | 0 | 2 | https://api.github.com/repos/mise-plugins/asdf-zigmod/tags | MIT | [
"asdf",
"asdf-plugin",
"zig"
]
| 188 | false | 2024-05-06T12:41:24Z | false | false | unknown | github | []
| asdf-zigmod <a></a> <a></a> <a></a>
<a>zigmod</a> plugin for the <a>asdf version manager</a>.\
Tested also <a>mise</a>.
Contents
<ul>
<li><a>asdf-zigmod</a></li>
<li><a>Contents</a></li>
<li><a>Dependencies</a></li>
<li><a>Install</a></li>
<li><a>Contributing</a></li>
<li><a>License</a></li>
</ul>
Dependencies
<ul>
<li><code>asdf-vm</code> or <code>mise</code></li>
<li><code>bash</code>, <code>curl</code>: generic POSIX utilities.</li>
</ul>
Install
Plugin:
<code>shell
asdf plugin add zigmod https://github.com/kachick/asdf-zigmod.git</code>
<a>short-name specifier is also available</a> when you don't turn <a>disable_plugin_short_name_repository</a>
<code>shell
asdf plugin add zigmod</code>
zigmod:
```console
Show all installable versions
$ asdf list-all zigmod
Install specific version
$ asdf install zigmod latest
NOTE:
- This plugin supports zigmod versions r75 or later
- r<em> is newer prefix than v</em>
Set a version globally (on your ~/.tool-versions file)
$ asdf global zigmod latest
Now zigmod commands are available
$ zigmod version
zigmod r89 linux x86_64 musl
```
Check <a>asdf</a> readme for more instructions on how to
install & manage versions.
Contributing
Contributions of any kind welcome! See the <a>contributing guide</a>.
License
See <a>LICENSE</a> | []
|
https://avatars.githubusercontent.com/u/12962448?v=4 | ztar | star-tek-mb/ztar | 2022-10-24T12:12:01Z | Zig library for reading TAR files | master | 0 | 2 | 0 | 2 | https://api.github.com/repos/star-tek-mb/ztar/tags | - | [
"tar",
"zig",
"ziglang"
]
| 3 | false | 2022-11-02T12:35:53Z | true | false | unknown | github | []
| Overview
<strong>ztar</strong> - is a small library for reading tar files.
Features
<ul>
<li>Lightweight</li>
<li>One file</li>
<li>Non allocating</li>
<li>Simple API</li>
</ul>
Usage
Just copy <strong>ztar.zig</strong> to your project libraries/sources folder and you are ready to go.
Example
```zig
const std = @import("std");
const ztar = @import("ztar.zig");
pub fn main() !void {
var buf_stream = std.io.fixedBufferStream(@embedFile("arch.tar"));
var tar_reader = ztar.reader(buf_stream.reader());
var tar_iterator = tar_reader.iterator();
while (try tar_iterator.next()) |entry| {
std.log.debug("{s} {} {d}", .{entry.name, entry.@"type", entry.size});
// read file here for example
// tar_reader.readAll(buffer[0..entry.blockSize()]);
// or skip it
try tar_iterator.skip();
}
}
```
TODO
<ul>
<li>[ ] Add a writing API</li>
<li>[ ] Add extended reader/writer for handling long file names (with allocator)</li>
</ul> | []
|
https://avatars.githubusercontent.com/u/6128108?v=4 | zig-ptrace | micahswitzer/zig-ptrace | 2022-07-23T21:52:54Z | Linux ptrace wrappers and utilites for Zig | master | 0 | 2 | 0 | 2 | https://api.github.com/repos/micahswitzer/zig-ptrace/tags | MIT | [
"ptrace",
"zig",
"ziglang"
]
| 105 | false | 2024-05-07T14:46:32Z | true | false | unknown | github | []
| <blockquote>
NOTE: This library is still a work-in-progress, many functions are missing
and incomplete. The API will probably change significantly before the first
stable release.
</blockquote>
zig-ptrace
<code>zig-ptrace</code> is a combination <a>ptrace</a> wrapper library, and high-level
process and thread-tracing library.
Usage
Clone or copy <code>zig-ptrace</code> into a <code>deps</code> folder in your source tree and then
add the following code to your <code>build.zig</code>:
```zig
const zig_ptrace = std.build.Pkg{
.name = "ptrace",
.source = .{ .path = "deps/zig-ptrace/src/main.zig" },
};
exe.addPackage(zig_ptrace);
```
Then import it in your source files like this:
```zig
// for the low-level API
const ptrace = @import("ptrace").PTRACE;
// for the high-level API
const hl = @import("ptrace");
```
Low-level API
This should be nearly one-to-one with the C API. Constants are namespaced in
place of using underscores (e.g. <code>PTRACE.O.TRACECLONE</code> instead of
<code>PTRACE_O_TRACECLONE</code>). Each function only returns errors that are relevant to
that specific operation. Note that some operations are only available on
specific architectures. If you need to be able to compile programs consuming
this library for a broad range of architectures, consider using the high-level
API. Otherwise, you can gate the use of platform-specific functions using
<code>@hasDecl()</code>:
```zig
const ptrace = @import("ptrace").PTRACE;
if (@hasDecl(ptrace, "getRegs")) {
const regs = try ptrace.getRegs(pid);
} else {
// use a platform-independent function
try ptrace.getRegSet(pid, ...);
}
```
High-level API
<blockquote>
TODO: The high-level API is not anywhere close to being finalized. I'll start
writing this section when I have a better idea of how I want it to work. For
now see <code>src/highlevel.zig</code>.
</blockquote>
What's ptrace?
The ptrace (process trace) API allows a "tracer" process to attach to and
control a "tracee" process. The tracer can pause the tracee, observe and
manipulate its registers, memory, system calls, and signals, and then resume
the tracee. This can be used to implement a debugger, a system call tracer,
dynamic code patching, and many other things. It's an incredibly powerful API!
References
<ul>
<li><a>PTRACE(2)</a></li>
</ul> | []
|
https://avatars.githubusercontent.com/u/61155988?v=4 | surf | djtech-dev/surf | 2022-07-11T06:42:11Z | Building and mantaining projects for the 21st century. | main | 0 | 2 | 0 | 2 | https://api.github.com/repos/djtech-dev/surf/tags | MIT | [
"ada",
"build",
"build-system",
"build-systems",
"c-language",
"c-plus-plus",
"cobol",
"compliler",
"cross-compile",
"cross-platform",
"fortran",
"go",
"rust",
"rust-lang",
"swift",
"testing",
"zig"
]
| 9 | false | 2023-05-11T11:53:34Z | false | false | unknown | github | []
| surf - Building and mantaining projects for the 21st century.
Surf is a cross-platform, open-source build system made for building and mantaining projects for the 21st century.
Features
<ul>
<li>Cross-platform and open-source</li>
<li>Easy-to-use : The SURF file is a YAML file that explain itself.</li>
<li>12 programming languages supported</li>
<li>Possibility to custom commands for a project</li>
<li>AutoBuild (a system for automaticly building and testing projects while you are writing the code)</li>
<li><a>cosmopolitan</a> support : With <code>surf build ape</code>, your single output file will run natively on Linux, Mac, Windows, FreeBSD, OpenBSD, NetBSD, BIOS</li>
<li>Multi-tool chain: surf can use LLVM, GCC or both! (for example, a component for a project could be compiled using LLVM while the main program can be compiled using GCC)</li>
<li>WASM support : Ready-to-use for the web (requires LLVM)</li>
<li>Install, package and uninstall projects : Exactly like <code>make install</code> and similar.</li>
<li>HTTP(S) & GitHub integration </li>
<li>Testing System : Integrated testing system for your projects</li>
<li>IOLang : A new low-level programming langauge built on top and for Surf.
NOTE: At the moment, not all features are supported, but with v1.0 all the features will be implemented.</li>
</ul> | []
|
https://avatars.githubusercontent.com/u/107234593?v=4 | example | zig-wii/example | 2022-06-11T12:38:40Z | Example showing how to use ogc | master | 0 | 2 | 1 | 2 | https://api.github.com/repos/zig-wii/example/tags | - | [
"devkitpro",
"wii",
"zig"
]
| 68 | false | 2024-05-09T19:08:18Z | true | false | unknown | github | []
| example
This is a minimal example showing how to use <a>ogc</a>.
<code>git clone https://github.com/zig-wii/example
cd example/
zig build run</code> | []
|
https://avatars.githubusercontent.com/u/28735087?v=4 | confgen | LordMZTE/confgen | 2023-01-20T21:32:53Z | mirror of https://mzte.de/git/LordMZTE/confgen | master | 0 | 2 | 0 | 2 | https://api.github.com/repos/LordMZTE/confgen/tags | GPL-3.0 | [
"lua",
"template-engine",
"zig",
"zig-package"
]
| 225 | false | 2025-05-20T12:42:09Z | true | true | unknown | github | [
{
"commit": null,
"name": "zig_args",
"tar_url": null,
"type": "remote",
"url": "git+https://git.mzte.de/mirrors/zig-args.git#9425b94c103a031777fdd272c555ce93a7dea581"
}
]
| Confgen
Confgen is a tool to generate config files using a custom template language.
The system is backed by a Lua runtime that is used to configure the tool.
Installation
You can find binaries built on a Debian box in the releases tab, or build yourself like any other
Zig project.
Nix
This project includes a Nix flake you can depend on. Additionally, the Confgen derivation as well as
derivations of other projects of mine are automatically built and pushed to an attic cache at
<code>https://nix.mzte.de/mzte</code> on every commit.
Usage
Start by creating <code>confgen.lua</code> in your dotfiles. It should look something like this:
```lua
-- add your config files
cg.addString("my_config.cfg", [[config template here]])
cg.addFile("my_other_config.cfg")
cg.addFile("my_other_config.cfg", "out.cfg") -- with output path
cg.addPath(".config") -- add a whole path recursively
-- set options to be used in config files
cg.opt.test_option = "42"
```
Next, add some templates. confgen will detect if a file is a template by its extension and copy it otherwise.
This is what a template looks like:
<code>cfg
I'm a confgen template!
<! if some_condition then !> # any lua statement
some option: <% opt.test_option %> # a lua expression
<! end !> # close the if block
more config stuff</code>
Template files end with the <code>.cgt</code> extension. If a file that has been added has this extension, confgen will evaluate the template and put that into the output directory (without the <code>.cgt</code> extension), otherwise, it will be copied.
For example, if you want to add a file called <code>stuff.cfg</code> to the output as a template, you'd call the template file <code>stuff.cfg.cgt</code>.
With the above <code>confgen.lua</code>, this template
```
<! for i = 0,5 do !><% i %><! end !>
<% opt.test_option %>
```
would result in this output.
```
12345
42
```
Lastly, run confgen, providing the output directory as an argument:
<code>bash
confgen confgen.lua out_dir</code>
ConfgenFS
ConfgenFS provides an alternative to the <code>confgen</code> CLI tool. It takes a path to a confgen file
as well as a mountpoint:
```bash
Mount config at ~/confgenfs
confgenfs /path/to/confgen.lua ~/confgenfs
```
This mounts a FUSE3 filesystem containing all the config files. The advantage of this is that
the templates will be generated when the file is opened and not ahead of time.
Additionally, the filesystem will contain "meta-files" inside <code>_cgfs/</code>, currently only <code>_cgfs/eval</code>
and <code>_cgfs/opts.json</code>.
You can write some Lua code to the former file, and it will be evaluated in the global Lua context.
This allows for dynamic configurations, here's a practical example:
<code>.config/waybar/config.cgt</code>:
<code>json
{
"modules-left": [
<! if opt.compositor == "river" then !>
"river/tags", "river/window"
<! elseif opt.compositor == "hyprland" then !>
"hyprland/workspaces", "hyprland/window"
<! end !>
]
}</code>
Your hyprland and river configs could set the compositor option on startup:
```bash
For river:
echo 'cg.opt.compositor = "river"' >~/confgenfs/_cgfs/eval
For hyprland:
echo 'cg.opt.compositor = "hyprland"' >~/confgenfs/_cgfs/eval
```
And when waybar is started afterwards, it would work without manual configuration changes (assuming a symlink <code>~/confgenfs/.config/waybar -> ~/.config/waybar</code>).
After starting river, we can see the final config:
```bash
$ cat ~/confgenfs/.config/waybar/config
{
"modules-left": [
<code> "river/tags", "river/window"
]
</code>
}
```
Building
Linux
<ul>
<li>install the LuaJIT and FUSE3 library and the 0.12 version of Zig</li>
<li><code>zig build -Drelease-fast -p ~/.local</code></li>
</ul>
Mac
This is untested, but it should work theoretically.
Windows
no lol | []
|
https://avatars.githubusercontent.com/u/14258692?v=4 | zig-project-workflow | initdc/zig-project-workflow | 2022-10-19T08:13:33Z | Zig just need build once time! | master | 0 | 2 | 0 | 2 | https://api.github.com/repos/initdc/zig-project-workflow/tags | MPL-2.0 | [
"actions",
"build",
"docker",
"release",
"workflow",
"zig"
]
| 39 | false | 2024-04-10T14:32:05Z | true | false | unknown | github | []
| <a>Zig Project Workflow</a>
<blockquote>
Project written by zig, you just need build once time.
</blockquote>
Build on Linux Host
<ol>
<li>
deps
<ul>
<li>zig</li>
<li>ruby</li>
<li>tree</li>
<li>sha256sum</li>
<li>docker</li>
</ul>
</li>
<li>
build
<blockquote>
edit config and build CMD as you need
</blockquote>
```
build binarys
ruby build.rb
ruby build.rb --run-test
ruby build.rb v0.0.1
ruby build.rb less ## build bin for LESS_OS_ARCH
echo > version.rb 'VERSION = "fix-bug-001"'
ruby build.rb test --run-test
build docker images
ruby docker-tag.rb
ruby docker-tag.rb v0.0.1
ruby docker-tag.rb dev
ruby docker-tag.rb v$(TZ=Asia/Shanghai date +%Y.%m.%d)
```
</li>
</ol>
GitHub actions
<ul>
<li>build binarys</li>
<li>upload release files</li>
<li>build docker images</li>
</ul>
More about docker
Check https://github.com/initdc/ssh-proxy-by-caddy-l4
License
MPL 2.0 | []
|
https://avatars.githubusercontent.com/u/12962448?v=4 | dark-theme | star-tek-mb/dark-theme | 2022-11-05T14:31:07Z | Query system dark/light theme preference | master | 0 | 2 | 0 | 2 | https://api.github.com/repos/star-tek-mb/dark-theme/tags | - | [
"dark-mode",
"dark-theme",
"zig"
]
| 11 | false | 2024-06-17T02:08:51Z | true | false | unknown | github | []
| Overview
Query system dark/light theme preference.
Platform
<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> Windows (tested)
<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> Linux (tested)
<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> MacOS (tested)
API
```zig
const darktheme = @import("darktheme.zig");
// get bool value of system preference
var isDark = darktheme.isDark() catch false;
// windows only
// apply dark borders to window
darktheme.setDarkWindow(hwnd);
```
Credits
Thanks to <a>cryptocode</a> for testing out MacOS code | []
|
https://avatars.githubusercontent.com/u/2828351?v=4 | limp | bcrist/limp | 2022-03-15T00:16:25Z | Lua Inline Metaprogramming Preprocessor | main | 0 | 2 | 0 | 2 | https://api.github.com/repos/bcrist/limp/tags | MIT | [
"lua",
"metaprogramming",
"preprocessing",
"preprocessor",
"utilities",
"utility",
"utils",
"zig",
"ziglang"
]
| 928 | false | 2025-03-22T07:31:38Z | true | true | 0.14.0 | github | [
{
"commit": "40206beea0f2b3c05d2ed667bfd897b53ab0baa7",
"name": "Temp_Allocator",
"tar_url": "https://github.com/bcrist/Zig-TempAllocator/archive/40206beea0f2b3c05d2ed667bfd897b53ab0baa7.tar.gz",
"type": "remote",
"url": "https://github.com/bcrist/Zig-TempAllocator"
},
{
"commit": "1f5174abbc07cd7731613a6233fd0cfcebf134f9",
"name": "sx",
"tar_url": "https://github.com/bcrist/Zig-SX/archive/1f5174abbc07cd7731613a6233fd0cfcebf134f9.tar.gz",
"type": "remote",
"url": "https://github.com/bcrist/Zig-SX"
}
]
| LIMP
The Lua Inline Metaprogramming Preprocessor (LIMP) is a command line tool which looks for specially constructed comments in source code, executes them as Lua scripts, and inserts or replaces the results in the original source file. It can be embedded in almost any host language (as long as it has comments).
Example
<code>/*!! write 'Hello World!' !! 4 */
/* ################# !! GENERATED CODE -- DO NOT MODIFY !! ################# */
Hello World!
/* ######################### END OF GENERATED CODE ######################### */
</code>
LIMP comments begin and end with the host language's comment tokens. Immediately following the comment opener, <code>!!</code> indicates that the comment should be processed by LIMP. The rest of the comment, (or up to the next <code>!!</code> token, whichever is first), is treated as a Lua program and executed.
That program can issue write commands to build up a chunk of output text, which will be inserted after the LIMP comment. Any previously generated output will be replaced when this happens. Between the ending <code>!!</code> and comment closing tokens, the number of generated lines will be recorded (in this case, 4), so that LIMP will know how many lines to replace next time it runs. Note this does mean you need to be careful not to delete lines manually within the generated output, lest you accidentally lose lines that appear after the generated code.
Note: LIMP does not do any Lua syntax parsing when looking for the LIMP and/or comment end tokens. In particular '!!' will be found even if it is inside a Lua string literal.
Language Configuration
The sequences of characters that are treated as comment openers and closers can be customized by creating a <code>.limplangs</code> file in the directory that contains the limp executable. Blank lines and lines that begin with <code>#</code> are ignored. Otherwise, each line must have 3 or 4 tokens separated by whitespace. The first is the file extension for which the line applies (without the leading <code>.</code>). The second token denotes the start of a comment in that language, and the third token denotes the end of a comment. If there is a fourth token, it should appear at the beginning of every line of a multi-line comment (this is useful for languages that only have single-line comments). If the same extension is specified multiple times, only the last one is valid. If a line is specified for the extension <code>!!</code>, it overrides the default <code>!!</code> tokens that indicate the start and end of Lua code.
Extensions and Project-specific Libraries
LIMP will set up a new Lua environment for each file that contains LIMP comments. Before it executes any comments, it will look for a <code>.limprc</code> file in the same directory as the file to be processed, or a parent directory (it will stop at the closest one it finds). If found, it will execute that file as a Lua chunk in the environment that it has created. This means you can set up access to any additional libraries, include paths, etc. that you might want, without cluttering up individual LIMP comments or needing to repeat it in many places.
Strict Mode
<a>Strict Mode</a> is enabled by default for LIMP programs. You can disable it by setting <code>__STRICT = false</code> either in a LIMP comment or <code>.limprc</code>.
Backtick Templates
The built-in <code>template</code> function can be used to make code generation tasks easier to read and less error prone compared to individual <code>write</code> calls.
It takes a single string parameter containing the template definition. Backticks can be used to delimit text substitutions that should be made when evaluating the template. This is a little bit like the string interpolation featured in some programming languages (although usually <code>${}</code> is used for those). <code>template</code> returns a function which takes a context table. The keys of that table are then available as global variables to the interpolated sections between backticks. Each section is parsed as a separate chunk, using a metatable on the global table to delegate to either the context object or the parent global table. If the interpolated section contains no newlines, it must be a <code>return</code>-able expression. Returned values and non-interpolated sections are passed to <code>write</code>. A double backtick acts as an escape sequence to insert a single backtick, or you can use the built-in <code>backtick</code> global variable.
Template Examples
<code>/*!!
local simple = template [[`kind` is a fruit!`nl`]]
simple {kind='Banana'}
simple {kind='Apple'}
simple {kind='Orange'}
simple {kind='Kiwi'}
!! 8 */
/* ################# !! GENERATED CODE -- DO NOT MODIFY !! ################# */
Banana is a fruit!
Apple is a fruit!
Orange is a fruit!
Kiwi is a fruit!
/* ######################### END OF GENERATED CODE ######################### */
/*!!
local my_template = template [[Hello `name`!`nl, values`]]
list_item = template '<li>`it`</li>'
list = template [[<ul>`
indent()
for i,v in ipairs(table.pack(...)) do
nl()
list_item { it = v }
end
unindent()
nl()
`</ul>`
nl()
]]
my_template {
name = 'Complicated World',
values = function()
list(nil, 'b')
list(nil, 'b', 1, true, false)
end
}
!! 14 */
/* ################# !! GENERATED CODE -- DO NOT MODIFY !! ################# */
Hello Complicated World!
<ul>
<li>b</li>
</ul>
<ul>
<li>b</li>
<li>1</li>
<li>true</li>
<li>false</li>
</ul>
/* ######################### END OF GENERATED CODE ######################### */
</code>
S-Expression Parsing
An S-Expression parser is built into LIMP which provides an easy way to import human-readable data to be processed.
A parser can be constructed from an S-expression string, and provides a variety of methods to extract data from the
S-expression one piece at a time. The simplest way to use it is something like this:
<code>local source = [[
(1 2 3 (subarray 2 3 4.0))
]]
local parser = sx.parser(source)
local result = parser:array()
</code>
This will produce a table equivalent to this:
<code>result = { 1, 2, 3, { 'subarray', 2, 3, 4.0 }}
</code>
A common idiom with S-expressions is that the first value in a subexpression is treated as a property name of a key-value pair.
The <code>object()</code> method can be used to take advantage of this:
<code>parser = sx.parser(source)
result = parser:object()
</code>
This will produce a table equivalent to this:
<code>result = { 1, 2, 3, subarray = { 2, 3, 4.0 }}
</code>
Note that there is a possibility of data loss here (e.g. if there were multiple <code>subarray</code> expressions within the same outer expression)
and Lua will not retain the relative ordering for expressions with multiple properties.
Sometimes you may want more structure and control over the parsing process, so there are a range of
lower-level methods to parse more incrementally. For example:
<code>source = [[
(box 2 5 4 (color blue))
]]
parser = sx.parser(source)
parser:require_expression('box')
local width = parser:float() or 1
local height = parser:float() or 1
local depth = parser:float() or 1
local color = 'white'
if parser:expression('color') then
color = parser:require_string()
parser:close()
end
parser:close()
parser:require_done()
</code>
S-Expression Parser Methods
Methods that begin with <code>require_</code> operate the same as their unprefixed versions, except any time <code>nil</code> or <code>false</code> would
be returned, an error is generated instead.
<code>function open (parser) --> bool
function require_open (parser)
</code>
Consumes the next token from the parser if it is <code>(</code>.
<code>function close (parser) --> bool
function require_close (parser)
</code>
Consumes the next token from the parser if it is <code>)</code>.
<code>function done (parser) --> bool
function require_done (parser)
</code>
Checks if the parser has reached the end of the input.
<code>function expression (parser) --> string | nil
function expression (parser, expected) --> bool
function require_expression (parser) --> string
function require_expression (parser, expected)
</code>
Attempts to consume the next 2 tokens from the parser if they are <code>(</code> and a string. If <code>expected</code> is provided, the second token must be that exact string in order for any tokens to be consumed.
<code>function string (parser) --> string | nil
function string (parser, expected) --> bool
function require_string (parser) --> string
function require_string (parser, expected)
</code>
Attempts to consume the next token from the parser if it is a string/value. If <code>expected</code> is provided, it must be that exact string in order to be consumed.
<code>function float (parser) --> number | nil
function require_float (parser) --> float
</code>
Attempts to consume the next token from the parser if it can be parsed as a floating point number.
<code>function int (parser, radix = 10) --> integer | nil
function require_int (parser, radix = 10) --> integer
</code>
Attempts to consume the next token from the parser if it can be parsed as a signed integer.
<code>function unsigned (parser, radix = 10) --> integer | nil
function require_unsigned (parser, radix = 10) --> integer
</code>
Attempts to consume the next token from the parser if it can be parsed as an unsigned integer.
<code>function array_item (parser) --> * | nil
function require_array_item (parser) --> *
</code>
Attempts to parse a number, string, or array.
<code>function array_items (parser, array = {}) --> table
</code>
Attempts to parse as many numbers, strings, or arrays as possible, and appends them to the provided table.
<code>function array (parser) --> table | nil
function array (parser, expected) --> table | nil
function require_array (parser) --> table
function require_array (parser, expected) --> table
</code>
Attempts to consume a subexpression. If <code>expected</code> is provided, the subexpression will only be consumed if it begins with this string,
as if using <code>if expression(expected) then ... end</code>. Additional values/subexpressions will be parsed using <code>array_items</code>.
<code>function property (parser) --> key | nil, value | nil
function property (parser, expected_key) --> key | nil, value | nil
function require_property (parser) --> key, value
function require_property (parser, expected_key) --> key, value
</code>
Attempts to consume a subexpression. The first value in the subexpression is the key. If there are no additional values, the value
is assumed to be <code>true</code>. If there are more than one additional value, or if the value is a property itself, they are parsed as if by
<code>object_items</code>. If <code>expected_key</code> is provided, the subexpression will only be consumed if the key matches that string.
<code>function property (parser, table, ...) --> key | nil, value | nil
function require_property (parser, table, ...) --> key, value
</code>
Attempts to consume a subexpression. The first value in the subexpression is the key. A function will be looked up in the provided table. That
function will be called and passed the parser, key name, and any additional parameters passed into <code>property</code>, and it should parse the remainder
of the subexpression and return a value. A metatable can be used to handle/ignore unrecognized keys, otherwise such edge cases will result in an error.
<code>function object_items (parser, obj = {}) --> table
</code>
Attempts to parse as many properties, numbers, strings, or arrays as possible, inserting or appending them in the provided table.
<code>function object (parser) --> table | nil
function object (parser, expected) --> table | nil
function require_object (parser) --> table
function require_object (parser, expected) --> table
</code>
Attempts to consume a subexpression. If <code>expected</code> is provided, the subexpression will only be consumed if it begins with this string, as if using
<code>if expression(expected) then ... end</code>. Additional values/subexpressions will be parsed using <code>object_items</code>.
<code>function ignore_remaining_expression (parser)
</code>
Ignore any remaining values or subexpressions and consume the <code>)</code> token that ends this expression.
<code>function print_parse_error_context (parser)
</code>
Print (to stderr) the line number and contents of the current line being parsed, and highlight the next unconsumed token.
Built-in Functions and Variables
All functions from the <a>Lua Standard Libraries</a> are available for use.
<code>function natural_cmp (a, b)
</code>
A comparison function suitible for use with <code>sort</code> or <code>spairs</code> that compares strings using a human-alphabetical ordering:
<ul>
<li>Lowercase letters are compared as if they were uppercase, such that <code>table.sort({'Apple', 'banana', '.', '_', 'Blueberry', 'apricot'}, natural_cmp)</code> becomes <code>{'.', 'Apple', 'apricot', 'banana', 'Blueberry', '_'}</code>.</li>
<li>Subsequences of decimal digits are (conceptually) replaced with a single numeric atom whose value is the same (when interpretted in base 10) such that <code>table.sort({'x1', 'x10', 'x2', 'x20'}, natural_cmp)</code> becomes <code>{'x1', 'x2', 'x10', 'x20'}</code>.</li>
<li>If two strings are considered equal using the rules above, they are compared lexicographically.</li>
</ul>
<code>function spairs (table)
function spairs (table, comparator)</code>
Iterator generator like <code>pairs</code>, except keys are visited in sorted order. The second parameter behaves as in <code>table.sort</code>.
<code>function nl ()
</code>
Writes a newline character or characters and any indentation/comment characters as necessary.
<code>function write (...)
</code>
Converts each each parameter to a string and writes it to the output in sequence, with no separators. Tables with no <code>__tostring</code> metamethod will be
recursively dumped as key-value pairs. Functions will be called with no parameters and any returned results will be recursively written. Other
non-string values will be converted using <code>tostring()</code>.
<code>function writeln (...)
</code>
Equivalent to <code>write(...) nl()</code>.
<code>function write_lines (...)
</code>
Same as <code>write (...)</code> except <code>nl()</code> will be called after each parameter is written.
<code>function write_file (path)
</code>
Loads the contents of the specified path, marking it as a dependency, writing it with normalized newlines and the current indentation level.
<code>function write_proc (cmd)
</code>
Executes the provided shell command via <code>io.popen</code>, writing the output with normalized newlines and the current indentation level.
<code>function template (source)
</code>
Defines a new backtick template function (see above for details).
<code>function begin_comment ()
function end_comment ()
</code>
Writes <code>comment_begin</code>/<code>comment_end</code> as necessary and causes any <code>nl()</code> within the comment to output <code>comment_line_prefix</code> after any indentation.
<code>function indent (count = 1)
function unindent (count = 1)
function set_indent (count)
function reset_indent ()
</code>
Changes the indentation level for any subsequent lines written.
<code>function get_indent ()
</code>
Returns a string composed of <code>base_indent</code> and <code>indent_char</code> repeated as necessary to achieve the current indent level.
<code>function write_indent ()
</code>
Equivalent to <code>write(get_indent())</code>. Normally you don't need to call this directly, as <code>nl()</code> will call it automatically.
<code>function indent_newlines (str)
</code>
Returns a copy of <code>str</code> with newlines normalized, and each new line having <code>get_indent()</code> prepended.
<code>function sx.parser (str)
</code>
Returns a new parser to process the provided S-expression string. See above for discussion of the methods available on this type of userdata object.
<code>function fs.absolute_path (path)
</code>
If <code>path</code> is already an absolute path, it is returned unchanged, otherwise an absolute path is constructed as if by calling <code>fs.compose_path(fs.cwd(), path)</code>.
This function does not access the filesystem.
<code>function fs.canonical_path (path)
</code>
Converts <code>path</code> to an absolute path (if necessary) and resolves any <code>..</code>, <code>.</code>, or symlink segments. An error is thrown if the path does not exist or can't be accessed.
<code>function fs.compose_path (...)
</code>
Joins each of the provided path parts into a single path, using a directory separator appropriate for the current platform (including converting any directory
separators inside the path strings). Only the first parameter may be an absolute path (but isn't required to be). This function does not access the filesystem.
<code>function fs.compose_path_slash (...)
</code>
Same as <code>fs.compose_path(...)</code> but always uses <code>/</code> as a separator, even on Windows.
<code>function fs.parent_path (path)
</code>
Removes the filename or final directory name from a path. If the path is a root path, an empty string is returned. This function does not access the filesystem.
<code>function fs.ancestor_relative_path (child, ancestor)
</code>
Returns a path to <code>child</code> relative to the <code>ancestor</code> path, if the <code>child</code> path's starting segments are identical to <code>ancestor</code>. Otherwise, returns <code>child</code>
unchanged. If both paths are the same, <code>.</code> is returned. If one path contains <code>..</code>, symlinks, etc. that do not appear in the other path, yet they are actually
equivalent, this function will not be able to generate a relative path. This function does not access the filesystem.
<code>function fs.resolve_path (path, search, include_cwd = false)
</code>
Looks for an existing path in one or more directories and returns the first one it finds. If <code>search</code> is a path, that directory is searched. If <code>search</code> is
a table, each value contained in it is searched. Use integer keys to ensure a consistent search order. Finally if no match has been found yet and <code>include_cwd</code>
is true, the current directory is searched.
<code>function fs.path_stem (path)
</code>
Extracts the base filename from <code>path</code>, removing any file extension, parent directories, or path separators. This function does not access the filesystem.
<code>function fs.path_filename (path)
</code>
Extracts the base filename from <code>path</code>, removeing parent directories or path separators. This function does not access the filesystem.
<code>function fs.path_extension (path)
</code>
Extracts the file extension from <code>path</code>, including the preceeding <code>.</code>, or the empty string if the filename has no <code>.</code> characters. This function does not access the filesystem.
<code>function fs.replace_extension (path, new_ext)
</code>
Removes the current extension (if any) from <code>path</code> and then adds on <code>new_ext</code>. This function does not access the filesystem.
<code>function fs.cwd ()
</code>
Returns the current working directory (generally the path containing the file being processed, unless <code>set_cwd()</code> has been used).
<code>function fs.set_cwd (path)
</code>
Sets the current working directory to a new path. Note this will be reset each time a new file is processed.
<code>function fs.stat (path)
</code>
Returns an object containing size, timestamps, type, kind, and mode/permissions for a file or directory. If the file/directory does not exist, the kind will be
an empty string, and all other properties will be 0.
<code>function fs.get_file_contents (path)
</code>
Fully reads the contents of a file into a string.
<code>function fs.put_file_contents (path, data)
</code>
Writes a string to a file. If the file already exists, it will be replaced.
<code>function fs.move (src, dest, force = false)
</code>
Renames a file or directory. If <code>dest</code> already exists it will only be overwritten if it is the same kind as <code>src</code> (i.e. both files or directories) and <code>force</code> is true.
<code>function fs.copy (src, dest, force = false)
</code>
Copies a file or directory. If <code>dest</code> already exists it will only be overwritten if it is the same kind as <code>src</code> (i.e. both files or directories) and <code>force</code> is true.
When "overwriting" a directory, files in the old directory will only be replaced if they also exist in the source directory.
<code>function fs.delete (path, recursive = false)
</code>
Deletes a file or directory. If <code>recursive</code> is true, a directory can be deleted even if it is not empty.
<code>function fs.ensure_dir_exists (path)
</code>
Creates any directories necessary to ensure that <code>path</code> exists and is a directory. Throws an error if not possible due to a file existing with a conflicting name.
<code>function fs.visit (path, func, recursive, no_follow)
</code>
Calls <code>func</code> once for each entry in the directory specified by <code>path</code>. If the 3rd parameter is true, subdirectories will be recursed.
If the 4th parameter is true, symlinks will not be treated as directories. The visitor function will be passed the file name and a
string indicating the kind of file (e.g. <code>File</code>, <code>Directory</code>, <code>SymLink</code>, etc.)
<code>function util.deflate (uncompressed, level = 8, encode_length = false)
</code>
Returns a zlib-compressed version of the <code>uncompressed</code> string. If <code>encode_length</code> is true, an extra 8 bytes are prepended indicating the original uncompressed
length of <code>data</code>, which is needed for <code>util.inflate()</code>.
<code>function util.inflate (compressed, uncompressed_length = nil)
</code>
Decompresses zlib-compressed data. If <code>uncompressed_length</code> is not provided, the compressed data must have been generated by <code>util.deflate(?, ?, true)</code>.
<code>function trim_trailing_ws (str)
</code>
Returns a copy of <code>str</code> with any spaces or tabs removed from the end of each line.
<code>function normalize_newlines (str)
</code>
Returns a copy of <code>str</code> with all newlines normalized to <code>nl_style</code>
<code>function postprocess (str)
</code>
Called with the string containing the new output data just before it's inserted back into the file. By default it just calls <code>trim_trailing_ws(str)</code>, but it
can be replaced with another function or removed if desired.
<code>function write_prefix ()
</code>
Called just before the first output is generated for each LIMP. It can be replaced to hook in custom logic.
<code>function write_postfix ()
</code>
Called at the end of each LIMP just before <code>postprocess</code> is called. It can be replaced to hook in custom logic.
<code>prefix
postfix
</code>
If set, these will be written automatically by <code>write_prefix</code>/<code>write_postfix</code> instead of the default <code>GENERATED CODE -- DO NOT MODIFY</code> warning.
<code>function quiet ()
</code>
Sets <code>prefix</code> and <code>postfix</code> to the empty string, disabling the generated code warning.
<code>file_path
</code>
The path to the file containing the LIMP being processed.
<code>limprc_path
</code>
The path to the <code>.limprc</code> file that was executed. If multiple <code>.limprc</code> files have been run (due to <code>import_limprc</code> being called again), only the most
recent path is reflected here.
<code>comment_begin
comment_end
comment_line_prefix
</code>
Strings corresponding to the detected comment tokens used in this file (e.g. from <code>.limplangs</code>).
<code>last_generated_data
</code>
A string containing the data from the file that will be replaced by the output currently being generated.
<code>base_indent
</code>
Any characters at the start of the line containing the start of the LIMP comment are placed here. It will automatically be inserted after a call to <code>nl()</code>.
<code>indent_size
indent_char
</code>
Configures the characters to use for automatic indentation.
<code>nl_style
</code>
The detected character(s) that should be used to indicate a new line; <code>\n</code>, <code>\r</code>, or <code>\r\n</code>. The last newline before the start of the LIMP comment
will be used, unless it begins on the first line of the file, in which case it will look at the first ~50 lines and pick whichever ending is most
frequently used. If there are no newlines at all, <code>\r\n</code> will be used on Windows, and <code>\n</code> on any other platform.
<code>backtick
</code>
A string containing a single backtick character.
<code>function dependency (path)
function get_depfile_target ()
function write_depfile ()
</code>
Not yet implemented.
<code>function load_file (path, chunk_name)
</code>
Similar to the Lua built-in <code>loadfile(path)</code> but the loaded file is marked as a dependency of the currently processing file.
<code>function get_file_contents (path)
</code>
Identical to <code>fs.get_file_contents (path)</code> but the file is marked as a dependency of the currently processing file.
<code>function include (include_name)
</code>
Searches all currently registered include paths and the current directory for a <code>.lua</code> file with the specified name and executes it. The name
provided does not need to include the <code>.lua</code> extension.
<code>function register_include_dir (path)
</code>
Adds a new path to search for <code>.lua</code> files when attempting to resolve <code>include(...)</code> calls. Normally this would be used in a <code>.limprc</code> file to set up
<code>function get_include (include_name)
</code>
Same as <code>include(...)</code> except instead of running the included chunk, it is returned as a function.
<code>function resolve_include_path (path)
</code>
Searches for the provided path among all current include paths, using <code>fs.resolve_path()</code>. This can be useful to find other types of files
that live "next to" an included Lua script.
<code>function import_limprc (path)
</code>
Searches for a <code>.limprc</code> file in the provided path, or a parent of that path, and executes it. This will be called automatically when processing
a new file, but you can chain <code>.limprc</code> files together by putting <code>import_limprc(fs.parent_path(limprc_path))</code> inside a <code>.limprc</code> file in a
subdirectory of the project's root. | [
"https://github.com/bcrist/Zig-LC4k"
]
|
https://avatars.githubusercontent.com/u/3307207?v=4 | zig-sc2-template | spudde123/zig-sc2-template | 2022-08-22T17:17:07Z | Starter Starcraft 2 bot made in Zig to compete on the sc2ai ladder | master | 0 | 2 | 0 | 2 | https://api.github.com/repos/spudde123/zig-sc2-template/tags | MIT | [
"starcraft2",
"zig"
]
| 80 | false | 2025-05-21T18:26:22Z | true | false | unknown | github | []
| Zig-sc2-template
Template for a Starcraft 2 bot for competing on <a>sc2ai.net</a>, written in Zig 0.14.0.
Running
<ol>
<li>Install <a>Zig</a>.</li>
<li>Download the template including the submodule.</li>
<li>In the folder write <code>zig build run</code>. If you are using VS Code,
you can build and launch using the configs in the .vscode folder.
Debugging also works, for example with the VS Code configs or
with RemedyBG. Note that you need maps
placed in the correct folder inside your SC2 installation folder.
Make a folder called <code>Maps</code> there if it doesn't exist, and download
some maps from
<a>here</a>.
To run a game on a specific map, you can write for example
<code>zig build run -- --Map StargazersAIE</code>.</li>
<li>To build a release build write <code>zig build -Doptimize=ReleaseSafe</code></li>
<li>To build an executable that works on the sc2ai ladder write
<code>zig build -Dtarget=x86_64-linux -Doptimize=ReleaseSafe</code>. There is also a python script
that builds the executable and takes the files in the <code>config</code> folder to the same zip
file, just in case you want to include some other files that your bot relies on.</li>
</ol>
Examples
The examples folder includes some bots, one of which competes on the
sc2ai ladder. To quickly run for example the bot <code>one_base_terran</code> you
can write <code>zig build run -Dexample=one_base_terran</code>. <code>zig build</code>
builds your bot in <code>src/main.zig</code> if you don't give it an example as a parameter.
CLI
Everything works on the SC2AI ladder without any customization, but
locally you can change what the program does through command line parameters:
- --SC2 "C:/My_Folder/StarCraft II"
- Path to your SC2 folder. This needs to be set if it does not match with
the defaults. Defaults are <code>"C:/Program Files (x86)/StarCraft II"</code> for Windows,
<code>"/Applications/StarCraft II"</code> for Mac and <code>"~/StarCraftII"</code> for Linux.
- --Map StargazersAIE
- Select the map. Can be whatever you have in your Maps folder
- --CompRace terran
- Race for ingame AI. Options: <code>terran</code>, <code>zerg</code>, <code>protoss</code>, <code>random</code>.
- --CompDifficulty very_hard
- Difficulty for ingame AI. Options: <code>very_easy</code>, <code>easy</code>, <code>medium</code>,
<code>medium_hard</code>, <code>hard</code>, <code>harder</code>, <code>very_hard</code>, <code>cheat_vision</code>,
<code>cheat_money</code>, <code>cheat_insane</code>.
- --CompBuild macro
- Build for ingame AI. Options: <code>random</code>, <code>rush</code>, <code>timing</code>, <code>power</code>,
<code>macro</code>, <code>air</code>.
- --RealTime
- Play in real time instead of step mode.
- --Human
- Play against your bot yourself. Two windows will open up, one for you and one
for the bot.
- --GamePort
- Decide the port your game is using locally to communicate with the program.
Status
Should have everything you need to start making a bot. Some things may still evolve but
the data the user bot uses should remain stable. If you encounter some problems,
you can join the SC2AI Discord and ask for help. Link is on the front page of
<a>sc2ai.net</a>. | []
|
https://avatars.githubusercontent.com/u/50093633?v=4 | ziggo-test | mazrean/ziggo-test | 2022-09-15T16:35:26Z | A simple example of calling a library written in Zig from Go by CGO. | main | 0 | 2 | 0 | 2 | https://api.github.com/repos/mazrean/ziggo-test/tags | - | [
"cgo",
"go",
"golang",
"zig"
]
| 1 | false | 2025-01-11T12:06:07Z | false | false | unknown | github | []
| ziggo-test
A simple example of calling a library written in Zig from Go by CGO.
<code>bash
$ make main
$ ./main
3</code> | []
|
https://avatars.githubusercontent.com/u/978183?v=4 | zig-master.nix | jessestricker/zig-master.nix | 2022-05-24T21:33:24Z | ⚡ A Nix flake providing pre-built master releases of the Zig language and toolchain. | main | 2 | 2 | 0 | 2 | https://api.github.com/repos/jessestricker/zig-master.nix/tags | MIT | [
"master",
"nix",
"nix-flake",
"zig"
]
| 539 | false | 2024-01-12T18:31:00Z | false | false | unknown | github | []
| zig-master.nix
<blockquote>
<strong>Warning</strong>
This project has been deprecated! If you are looking for an alternative, I recommend <a>zig-overlay</a>.
</blockquote>
Description
A Nix flake providing pre-built master releases of the Zig programming language
and toolchain.
The packaged version of Zig tracks the master version as given in the
<a>download index</a> and is updated
automatically by a <a>GitHub Actions workflow</a>.
Usage
Add this flake to your flake's inputs and use the <code>zig</code> package provided by this flake at <code>zig-master.packages.${system}.zig</code>.
If you want, you can also use this flake's template to create a Zig development environment for your Zig project:
```console
$ mkdir zig-project/
$ cd zig-project/
$ nix flake init -t 'github:jessestricker/zig-master.nix'
wrote: .../zig-project/flake.nix
$ nix develop -c zig version
warning: creating lock file '.../zig-project/flake.lock'
0.10.0-dev.3659+e5e6eb983
$ nix develop -c zig init-exe
info: Created build.zig
info: Created src/main.zig
info: Next, try <code>zig build --help</code> or <code>zig build run</code>
$ nix develop -c zig build run
All your codebase are belong to us.
Run <code>zig build test</code> to run the tests.
``` | []
|
https://avatars.githubusercontent.com/u/13280758?v=4 | shell-prompt | magiruuvelvet/shell-prompt | 2023-02-02T21:58:51Z | a fast and feature-rich dynamic shell prompt implementation in a single binary written in the Zig programming language | master | 3 | 2 | 0 | 2 | https://api.github.com/repos/magiruuvelvet/shell-prompt/tags | BSD-3-Clause | [
"shell-prompt",
"zig"
]
| 178 | false | 2024-08-16T03:34:50Z | true | false | unknown | github | []
| shell-prompt
a fast and feature-rich dynamic shell prompt implementation in a single binary written in the Zig programming language
intended to be used as fish shell prompt together with <a>magiruuvelvet/fish-shell-config</a>
Features
<ul>
<li>
reduces most of the work to a single process,
instead of spawning multiple processes each time the
prompt is displayed, which makes this prompt render noticeable faster than hundreds of lines of fish shell script
</li>
<li>
fast and modular shell prompt implementation which is easy to extend
</li>
<li>
context- and directory-aware features
</li>
<li>
support for git repositories, displays the current status of a git repository (commit hash, branch name, file changes, remote changes, the last commit message)
</li>
<li>
detects build systems in a directory and displays their name
</li>
<li>
displays a hint whenever the current shell is connected via ssh
</li>
</ul>
Building
You need the latest tagged release of the Zig compiler (0.10.1). The master branch of the compiler is not supported.
<ul>
<li>run <code>zig build</code></li>
<li>binaries can be found in the <code>zig-out/bin/</code> directory</li>
<li>for optimized release builds execute <code>./build-release.sh</code></li>
</ul>
Testing
There are 2 type of unit tests:
<ul>
<li>end user tests: <code>zig-out/bin/shell-prompt-tests</code></li>
<li>internal platform-specific tests: <code>zig build test</code> (runs tests for private functions not visible outside of the relevant source files)</li>
</ul> | []
|
https://avatars.githubusercontent.com/u/46534306?v=4 | viletech-2022 | jerome-trc/viletech-2022 | 2022-07-18T06:25:41Z | Doom source port and related technologies | master | 0 | 2 | 1 | 2 | https://api.github.com/repos/jerome-trc/viletech-2022/tags | GPL-3.0 | [
"doom",
"doom-2",
"game",
"game-engine",
"wad",
"zig",
"zig-package"
]
| 24,782 | false | 2025-02-19T17:03:21Z | true | true | 0.13.0 | github | [
{
"commit": null,
"name": "zbcx",
"tar_url": null,
"type": "relative",
"url": "depend/zbcx.ln"
},
{
"commit": null,
"name": "zdfs",
"tar_url": null,
"type": "relative",
"url": "depend/zdfs.ln"
},
{
"commit": null,
"name": "zmsx",
"tar_url": null,
"type": "relative",
"url": "depend/zmsx.ln"
},
{
"commit": null,
"name": "znbx",
"tar_url": null,
"type": "relative",
"url": "depend/znbx.ln"
},
{
"commit": "03af1b6c5bfda9646a562c861055024daed5b238",
"name": "zig-args",
"tar_url": "https://github.com/ikskuh/zig-args/archive/03af1b6c5bfda9646a562c861055024daed5b238.tar.gz",
"type": "remote",
"url": "https://github.com/ikskuh/zig-args"
},
{
"commit": "fac81ec499cfd64da7b846de27f6db4a0d4943bf",
"name": "sdl",
"tar_url": "https://github.com/ikskuh/SDL.zig/archive/fac81ec499cfd64da7b846de27f6db4a0d4943bf.tar.gz",
"type": "remote",
"url": "https://github.com/ikskuh/SDL.zig"
},
{
"commit": "dd4199bcb37426326e0e31419e99c10701e96c58",
"name": "bgfx",
"tar_url": "https://github.com/bkaradzic/bgfx/archive/dd4199bcb37426326e0e31419e99c10701e96c58.tar.gz",
"type": "remote",
"url": "https://github.com/bkaradzic/bgfx"
}
]
| VileTech
About
VileTech is a collection of Doom-related Rust technologies, oriented towards the building of new tools, game engines, and games descending from id Software's id Tech 1 engine.
The goals of the VileTech "project" are as follows, in descending order of priority:
1. <a></a>
2. Build a new Doom source port that fulfills all my specific needs.
3. Publicly expose the technologies developed in service of 2., especially where some functionality did not already have an implementation in an available library.
Beware that this project:
- is deep in development. You should not assume that any of the code herein is even sound.
- is strictly a solo hobby project. The code within this repository is going to be deeply disorganized for the foreseeable future.
Contents
<ul>
<li><code>/assets</code> contains non-code resources used by executable artifacts at runtime.</li>
<li><code>/c</code> contains the C component of the VileTech Engine - inherited from <a>dsda-doom</a> - pending translation to Zig.</li>
<li><code>/client</code> contains the code for the VileTech engine's Zig executable.</li>
<li><code>/crates</code> contains Rust libraries associated with this project.</li>
<li><code>/demotest</code> is a suite of integration tests for ensuring that the VileTech Engine is capable of running <a>demos</a> with perfect accuracy.</li>
<li><code>/depend</code> contains files, Git subtrees and submodules from other projects.</li>
<li><code>/doc</code> contains documentation for developers.</li>
<li><code>/legal</code> contains license information for outside code.</li>
<li><code>/libs</code> contains Zig libraries associated with this project.</li>
<li><code>/sample</code> contains data used for automated testing.</li>
</ul>
Licensing, Attribution
A complete list of attributions and other third-party licensing information can be found <a>here</a>.
All VileTech-original source - i.e., that which is no way covered by the terms of the document provided above - is provided under either of
<ul>
<li>Apache License, Version 2.0, (<a>LICENSE-APACHE</a> or https://www.apache.org/licenses/LICENSE-2.0)</li>
<li>MIT license (<a>LICENSE-MIT</a> or https://opensource.org/licenses/MIT)</li>
</ul>
at your option. | []
|
https://avatars.githubusercontent.com/u/797939?v=4 | jzero | omgtehlion/jzero | 2023-01-27T13:04:21Z | A command-line JSON viewer that can handle gigabytes of JSON data | master | 0 | 2 | 0 | 2 | https://api.github.com/repos/omgtehlion/jzero/tags | MIT | [
"cli",
"json",
"zig"
]
| 34 | false | 2023-08-05T14:27:01Z | true | false | unknown | github | []
| 404 | []
|
https://avatars.githubusercontent.com/u/3236?v=4 | ztd | mikea/ztd | 2022-11-13T18:33:33Z | Zig Tower Defense | master | 0 | 2 | 0 | 2 | https://api.github.com/repos/mikea/ztd/tags | GPL-3.0 | [
"data-oriented-design",
"game",
"game-engine-2d",
"tower-defense",
"zig",
"ziglang"
]
| 3,723 | false | 2023-02-26T21:29:40Z | true | false | unknown | github | []
| ZTD
Zig Tower Defense
Status: Technological demo
About
This game was written by me during fall 2022 holidays to learn Zig and Data Oriented Design approach.
It contains a highly optimized 2D sprite engine with custom OpenGL-based renderer.
To let the DOD shine, this project's goal was to push performance boundaries of the number of
units present in the simulation.
Currently on <code>Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz</code> the engine achieves up to
10*10^6 units/sec of single-threaded performance.
Runtime Requirements
<ul>
<li>Linux with following packages: <code>libglfw3-dev</code></li>
<li>Windows 64</li>
</ul>
Usage
Start: <code>./ztd</code> or <code>./ztd <level></code>.
Available levels: <code>level1</code>, <code>level2</code>, <code>level3</code>, <code>stress1</code>
Keys:
<ul>
<li>PgUp/PgDn, Mouse Wheel - zoom</li>
<li>B - build mode</li>
<li>ESC - exit build mode, clear selection</li>
<li>q - quit</li>
</ul>
Development
Requirements:
<ul>
<li>linux, <code>libglfw3-dev</code> package</li>
<li>Zig 0.11 (I use <a>zigup</a> to fetch master version)</li>
</ul>
Commands:
<ul>
<li><code>zig build</code></li>
<li><code>zig build run</code></li>
<li><code>zig build run -Drelease-fast=true -- [<level>]</code></li>
</ul>
Docker multiplatform build
<code>./dev.sh dist</code> will build linux and win64 release .zip archives.
Code Organization
Underlying data structures:
<ul>
<li><a>src/geom.zig</a> - 2d geometry primitives</li>
<li><a>src/sparse_set.zig</a> - sparse set implementation</li>
<li><a>src/denset_set.zig</a> - denset set implementation</li>
<li><a>src/r_tree.zig</a> - R Tree</li>
<li><a>src/table.zig</a> - fast table of records and table of bounds</li>
<li><a>src/rects.zig</a> - SIMD-friendly columnar []Rect</li>
</ul>
Game engine:
<ul>
<li><a>src/gl.zig</a> - OpenGL interface code</li>
<li><a>src/imgui.zig</a> - imgui interface code</li>
<li><a>src/shaders.zig</a> - opengl shaders utilities</li>
<li><a>src/rendering.zig</a> - different shader renderers</li>
<li><a>src/sprites.zig</a> - sprite atlas building and rendering</li>
<li><a>src/viewport.zig</a> - viewport calculations and update</li>
<li><a>src/engine.zig</a> - game engine</li>
<li><a>src/engine_testbed.zig</a> - simple testbed to debug the engine</li>
</ul>
Game:
<ul>
<li><a>src/model.zig</a> - model objects stored in table</li>
<li><a>src/game.zig</a> - game logic</li>
<li><a>src/resources.zig</a> - game resources</li>
<li><a>src/levels.zig</a> - game levels</li>
<li><a>src/ui.zig</a> - game UI and user interaction</li>
<li><a>src/data.zig</a> - units and buildings data (hp, damage, etc)</li>
<li><a>src/main.zig</a> - main entry poitn and game loop</li>
</ul>
License
<ul>
<li>code in <code>src/</code> is licensed under GPL3.</li>
<li>code in <code>lib/</code> is licensed under respective original licenses.</li>
<li><a>mini world sprites</a> are licensed under CC0</li>
<li><a>rubik font</a> is licensed under Open Font License</li>
</ul>
Screenshot
| []
|
https://avatars.githubusercontent.com/u/15616419?v=4 | ZoopZoopAdventuresSeven | Gertkeno/ZoopZoopAdventuresSeven | 2022-09-22T01:52:29Z | Join Zoop, Berry, Pemdas, and Jonathan in Zoop Zoop's Bee Adventures 7 | main | 0 | 2 | 0 | 2 | https://api.github.com/repos/Gertkeno/ZoopZoopAdventuresSeven/tags | GPL-3.0 | [
"wasm4",
"zig"
]
| 11,364 | false | 2024-12-03T02:57:14Z | true | false | unknown | github | []
| ZoopZoopAdventuresSeven
Join Zoop, Berry, Pemdas, and Jonathan in Zoop Zoop's Bee Adventures 7
<a>Play here!</a>
Made by: Garrett and June 💗
Building
Made with <a>Zig</a> 0.11.0 for <a>Wasm4</a>
To build and run, use these commands
<code>shell
zig build -Drelease-small=true
w4 run zig-out/lib/cart.wasm</code> | []
|
https://avatars.githubusercontent.com/u/88108711?v=4 | zvip | 4cecoder/zvip | 2023-01-31T01:50:20Z | watch vipstream.tv from terminal but in zig | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/4cecoder/zvip/tags | MIT | [
"cli",
"movies",
"vipstream",
"zig"
]
| 7 | false | 2023-03-30T07:38:55Z | true | false | unknown | github | []
| zvip
watch vipstream.tv from terminal but in zig
Build from source
clone:
<code>git clone https://github.com/4cecoder/zvip</code>
<code>cd zvip</code>
install <a>zig language compiler</a>
build and run the program
<code>zig build run</code> | []
|
https://avatars.githubusercontent.com/u/50309138?v=4 | mcc_zig | r-mutax/mcc_zig | 2022-12-08T16:23:57Z | Minimal C-Compiler for my practice about zig. | main | 2 | 1 | 0 | 1 | https://api.github.com/repos/r-mutax/mcc_zig/tags | MIT | [
"c",
"compiler",
"zig"
]
| 56 | false | 2023-02-28T03:37:14Z | true | false | unknown | github | []
| mcc_zig
This is mini C-Compiler by ziglang.
It's my practice projct for ziglang.
<a></a> | []
|
https://avatars.githubusercontent.com/u/121678877?v=4 | zig-gir-ffi | paveloom-z/zig-gir-ffi | 2023-01-24T13:31:31Z | Generate FFI bindings for Zig using GObject Introspection | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/paveloom-z/zig-gir-ffi/tags | MIT | [
"ffi",
"gobject-introspection",
"zig"
]
| 81 | false | 2023-04-10T18:59:04Z | true | false | unknown | github | []
| Notices
Mirrors
Repository:
- <a>Codeberg</a>
- <a>GitHub</a>
- <a>GitLab</a>
Prerequisites
Make sure you have installed:
<ul>
<li>Development libraries for</li>
<li><code>gobject-introspection</code></li>
<li><code>libxml2</code></li>
<li><a>Zig</a> (<code>v0.10.1</code>)</li>
<li><a>Zigmod</a></li>
</ul>
Alternatively, you can use the <a>Nix flake</a> via <code>nix develop</code>.
Build
First, fetch the dependencies by running <code>zigmod fetch</code>.
To build the binary, run <code>zig build</code>. To run it, run <code>zig build run</code>.
See <code>zig build --help</code> for more build options.
Related
Similar projects:
- <a>DerryAlex/zig-gir-ffi</a> | []
|
https://avatars.githubusercontent.com/u/68287637?v=4 | zig-cmdline-sample | SaicharanKandukuri/zig-cmdline-sample | 2023-02-08T06:15:34Z | null | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/SaicharanKandukuri/zig-cmdline-sample/tags | - | [
"sample",
"sample-code",
"zig",
"ziglang"
]
| 9,929 | false | 2023-06-06T11:03:28Z | true | false | unknown | github | []
| Zig cmdline arguments
This repo contains sample code to scan command line arguments and a way to process them for argument specific executions
with the help of
<code>zig
std.process.args();</code>
Testing
<code>bash
bash test-args.sh</code> | []
|
https://avatars.githubusercontent.com/u/72746829?v=4 | zic | slamko/zic | 2022-05-06T21:39:37Z | A set of Zig-inspired macros for type-based error handling in C | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/slamko/zic/tags | GPL-3.0 | [
"error-handling",
"framework",
"header-only",
"macros",
"preprocessor",
"programming-language",
"typesystem",
"zig"
]
| 199 | false | 2023-12-03T21:30:17Z | false | false | unknown | github | []
| Zic (Zig + C)
Convenient macro-wrappers library for error handling in C without <code>longjmp</code> and any other non fancy stuff. | []
|
https://avatars.githubusercontent.com/u/62475953?v=4 | Advent-Of-Code-2022 | Jomy10/Advent-Of-Code-2022 | 2022-12-01T20:06:02Z | My solutions for Advent Of Code 2022. Every day is written in another language, chosen randomly. | master | 6 | 1 | 2 | 1 | https://api.github.com/repos/Jomy10/Advent-Of-Code-2022/tags | - | [
"advent-of-code",
"advent-of-code-2022",
"c3",
"go",
"java",
"javascript",
"rust",
"shell-script",
"zig"
]
| 1,617 | false | 2023-11-01T17:25:16Z | false | false | unknown | github | []
| Advent Of Code 2022
This year for Advent of Code, I will randomly pick another language each day to
solve the puzzles. This is a combination of languages I know and languages I'd
like to learn (Crystal and C3). As the days progressed, I also added some languages
categorized as "langauges I've used like one before" to the list, because I was
running out of languages.
Days
<ol>
<li><a>ShellScript</a></li>
<li><a>Java</a></li>
<li><a>Rust</a></li>
<li><a>C3</a></li>
<li><a>Zig</a></li>
<li><a>JavaScript</a></li>
<li><a>Go</a></li>
<li><a>C</a></li>
<li><a>Swift</a></li>
<li><a>PHP</a></li>
<li><a>Haskell</a> (part1)
12.</li>
<li><a>Dart</a></li>
<li><a>TypeScript</a>
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.</li>
</ol>
Languages
The list of languages:
Languages I know
I've excluded some language like WASM and brainfuck, because NO.
<ul>
<li>C</li>
<li>Zig</li>
<li>Rust</li>
<li>Swift</li>
<li>JavaScript</li>
<li>TypeScript</li>
<li>Java</li>
<li>ShellScript</li>
<li>Go</li>
<li>Ruby</li>
</ul>
Languages I'd like to learn
<ul>
<li>C3</li>
<li>Crystal</li>
<li>Lua</li>
<li>Nelua</li>
<li>Haskell</li>
</ul>
Languages I've used like once before
<ul>
<li>PHP</li>
<li>Perl</li>
<li>Python</li>
</ul>
Languages I've got installed on my computer but I don't remember where they came from
<ul>
<li>Dart</li>
</ul>
License
MIT | []
|
https://avatars.githubusercontent.com/u/52354694?v=4 | iro-zig | d-mironov/iro-zig | 2022-04-21T11:10:29Z | Zig Terminal color library - WIP | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/d-mironov/iro-zig/tags | MIT | [
"cli",
"color",
"fmt",
"formatting",
"library",
"terminal",
"zig"
]
| 2 | false | 2022-04-21T11:36:29Z | false | false | unknown | github | []
| IRO-zig
Just started coding in Zig and thought maybe it would be nice to create a terminal color library
for Zig.
There are functions for the default colors of your terminal to correspond with your colorscheme.
And there are also functions where you can color the text with RGB values, if your terminal supports it.
Please give me your opinion on the lib and how I could improve it. You are also very welcome to contribute
p.s.: "iro" is japanese and means "color"
Usage
```zig
// Red colored text
const red = iro.red("This text will be red", .{});
// Green colored text
const green = iro.green("This text will be green", .{});
// and more colors like: yellow, magenta, cyan, blue, white, black
// You can also color the background the same way
const red_bg = iro.red_bg("This text's background will be red", .{});
const green_bg = iro.green_bg("This text's background will be green", .{});
// also all the above colors with: {color}_bg(...)
// There is also functionallity for RGB color, if your terminal supports it
// You put it into the first arguments to format the text
const rgb = iro.color("This text will be colored how you like it", .{255, 30, 255});
// You can also color the background RGB
const rgb = iro.color_bg("This text's background will be colored how you like it", .{255, 30, 255});
// Formatting is also supported
const red_fmt = iro.red("This text and format will be red: {d}", .{255});
const rgb_fmt = iro.color("This text and format will be colored how you like it: {s}", .{255, 255, 0, "This is text"});
// you can also chain them
const red_green_chain = iro.red("Hello, {s}", .{iro.green("world!", .{})});
```
Credits
Big credit to this article: <a>Terminal Colors</a> | []
|
https://avatars.githubusercontent.com/u/1892046?v=4 | rrl | nsmryan/rrl | 2022-06-12T18:48:27Z | See https://codeberg.org/tuplestruct/rrl for active development | master | 5 | 1 | 0 | 1 | https://api.github.com/repos/nsmryan/rrl/tags | - | [
"roguelike",
"rust",
"sdl2",
"zig"
]
| 1,899 | false | 2023-11-30T17:21:48Z | true | false | unknown | github | []
| == Rust Roguelike, Zig Version ==
This repository contains an incomplete re-write of the <a>Rust Roguelike</a> project in Zig.
This is an attempt to rebuild the entire game logic and visuals.
== Some Zig/Rust Notes ==
Iterator is much simpler and smaller. There is weirdness to it, like the whole generics-are-functions thing,
but its not nearly as baroque as Rust as it does not use lifetime parameters.
My Zig ended up being more lines for Comp because of all the unit tests. Without them it was a little smaller.
One concern in Haskell and Rust is always using the correct derives, especially with Rust's
orphan rule.
In Zig so far this is mostly about comptime- std.meta.eql gives equality for basic types at least,
and formatting appears to be able to print these types as well.
How this will work for TCL style printing and parsing I do not yet know. Also, if you want to
implement equality specially for a type, you simply implement your own function (perhaps there
is a standard way to do this or an interface for it?) and user's have to know to use this instead
of comptime eql. However, this is in line with the Zig no-hidden-control-flow concept.
Zig does not restrict floats the same. It also provides clamp, which I did in Rust.
Also I believe I will be able to use Zig's random numebr generation, which I couldn't in Rust
due to orphan rule serde support.
Zig ability to get enum/union tags and to use an enum for union tags is much better then my experience
with Rust.
I do have memory use issues in Zig which I would not have in Rust. Mostly found by simple tests.
The main problems are pointers to memory that it realloced like ArrayList.
Zig standard library has a fixed array datastructure, which Rust does not have. Rust in general
led me to allocate a lot with a global allocator, while in Zig allocation is much more controlled.
The Rust version seems to create a number of threads which I did not spawn myself, which does not make
me feel like I control my codebase. The Zig does not do this.
Zig would allow a very controlled Map and Tile type - currently maps are a simple array, unlike Rust where
I have a vector of vectors, but that is not completely Rusts fault.
However, with packed structs a tile could be a u16, making the map quite manageable. This is not done
because of zigtcl not supporting bit offset pointers, and this data is not reflected in TypeInfo anyway
at the moment.
=== Next Steps ===
AI
Level generation
Skills and talents
Game as a sequence of levels
Maybe extras - system level testing, do/undo/redo, console, tcl interface. | []
|
https://avatars.githubusercontent.com/u/85593302?v=4 | zailfish | svelterust/zailfish | 2022-04-15T02:32:52Z | Template engine for Zig | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/svelterust/zailfish/tags | - | [
"html",
"template",
"zig"
]
| 3 | false | 2022-04-15T02:37:39Z | true | false | unknown | github | []
| zailfish
Compile time templating engine for Zig. Based on <code>sailfish</code> from Rust. | []
|
https://avatars.githubusercontent.com/u/153401?v=4 | picolisp-zig | aw/picolisp-zig | 2023-01-08T14:43:05Z | Examples for using PicoLisp FFI with Zig | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/aw/picolisp-zig/tags | 0BSD | [
"bindings",
"ffi",
"picolisp",
"zig"
]
| 5 | false | 2024-10-27T07:34:34Z | false | false | unknown | github | []
| PicoLisp FFI with Zig
This repo provides a simple example of how to use <a>PicoLisp</a> with <a>Zig</a> using PicoLisp's FFI <code>(native)</code> functionality.
This is similar to <a>picolisp-rust</a> except written for <em>Zig</em>.
Requirements
<ul>
<li>Zig <code>v0.6+</code></li>
<li>PicoLisp 64-bit <code>v17.12+</code> or <code>pil21</code></li>
</ul>
Getting started
Once you've setup <em>PicoLisp</em> and <em>Zig</em>, simply type <code>make</code> to build and test the shared library.
Output
Before I explain what's going on, here's what the output should look like:
<code>Received struct: pil.PilStruct{ .byte1 = 32, .byte2 = 33, .character1 = 67, .character2 = 68, .int = -1, .long = 1, .string = u8@4847464544434241, .array = { 1, 2, 3, 4, 5, 6, 7, 8 } }
Result code: 0
Extracted struct:
(de Extracted (42 43)
("A" "B")
65535
9223372036854775807
"pilzig"
(80 105 99 111 76 105 115 112) )</code>
Explain
The code can be found in <a>extract.l</a> and <a>pil.zig</a>. The <em>Zig</em> code is designed as a <strong>shared library</strong> and can be called by PicoLisp's <strong>(native)</strong> function to pass data to/from between both languages.
PicoLisp code explanation
First, the code allocates 32 bytes of memory, which will be used to store data in a <a>struct</a>.
It then creates a struct named <code>P</code> with the following specification:
<ul>
<li>2 arbitrary bytes</li>
<li>2-bytes containing valid UTF-8 characters</li>
<li>1x 32-bit (4 bytes) signed integer</li>
<li>1x 64-bit (8 bytes) signed long</li>
<li>1x 8-byte null-terminated string</li>
<li>1x 8-byte arbitrary bytes array</li>
</ul>
Then the following <a>native</a> call is made and its result is stored in the <code>Res</code> variable:
<code>picolisp
(native "./libpil.so" "extract" 'I P)</code>
This calls the <code>extract</code> function from the <em>Zig</em> library, with the <code>P</code> struct as its only parameter. It expects a 32-bit signed integer <code>I</code> as the return value (it will be either <code>0</code> or <code>-1</code>).
Next, the code will extract the <code>P</code> structure using the specification described above:
<code>(struct P '((B . 2) (C . 2) I N S (B . 8)))</code>
Finally, the code will free the previously allocated memory and print the result of the <code>P</code> structure.
Some tests run at the end to ensure the data received from <em>Zig</em> is what we expected.
Note
<ul>
<li>The values sent to the <em>Zig</em> library will be printed by <em>Zig</em> as <code>Received struct:</code>.</li>
<li>The values received from the <em>Zig</em> library will be printed by <em>PicoLisp</em> as <code>Extracted struct:</code>.</li>
</ul>
Zig code explanation
The <em>Zig</em> code defines the struct for the received data; it is named <code>PilStruct</code> and contains the exact same specification as the <code>P</code> struct in the <em>PicoLisp code explanation</em>.
The <code>extract()</code> function creates a new struct in the variable <code>newstruct</code> which contains some new values, different from what was received by <em>PicoLisp</em>.
Luckily, the <em>Zig</em> pointers <a>cannot be <strong>null</strong></a> so there's no need to check for that.
The code then dereferences the pointer and prints what it received (the entire struct) from <em>PicoLisp</em> as <code>Received struct:</code> (mentioned earlier).
Finally, it writes the <code>newstruct</code> struct to the pointer and returns <code>0</code>. <em>PicoLisp</em> can then read the return code and the new struct data.
Thoughts
There isn't much to this code, but I thought it would be fun to create a working FFI library that's <em>not</em> written in <em>C</em> or <em>Rust</em> and which works perfectly with <em>PicoLisp</em>.
Enjoy!
Contributing
<ul>
<li>For bugs, issues, or feature requests, please <a>create an issue</a>.</li>
</ul>
License
<a>0BSD License</a>
Copyright (c) 2023 Alexander Williams, On-Prem <a>license@on-premises.com</a> | []
|
https://avatars.githubusercontent.com/u/49297668?v=4 | zig-agora-example | crosstyan/zig-agora-example | 2022-08-20T11:22:37Z | an example using agora and gstreamer with zig | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/crosstyan/zig-agora-example/tags | - | [
"agora",
"agora-rtc",
"agora-sdk",
"agoraio",
"zig"
]
| 444 | false | 2024-02-26T10:31:27Z | true | false | unknown | github | []
| Zig Agora RTSA example
An example stream to Agora by GStreamer with <a><code>videotestsrc</code></a>
and H264. I tried H265 but no luck.
I will say it's kind of crazy experience with zig. It will tell you when the allocator will kick in,
which is good? Its C interop should be good in theory...but <a><code>[*c]</code></a> is the big
problem for interop. You SHOULD rewrite every function with C pointer.
Zig will translate C files (header or source) to <code>.zig</code>. I wish I can write type annotation in another folder and Zig can
apply to the translated Zig code. <code>cImport</code> is also confusing. If you want to edit your generated zig file, the best way
is to utilize <code>build.zig</code> with <code>addTranslateC</code>, then import it.
By the way the <a>Zig Language Server</a> often crashes when parsing large files, which means
I have to look for documentation by myself.
Usage
This repo should have <a>Agora SDK</a> <code>aarch64-linux-gnu</code>. <code>x86_64</code> is not included
and you should install by yourself and modify <code>addLibraryPath</code> in <code>build.zig</code>
<code>build.zig</code> is actually a build script (may not the conventional script) which will call <code>zig build-exe</code> or <code>zig translate-c</code>
or anything else. In theory you can complete that with python script.
The config file will be stored in your local configuration folder, which should be <code>~/.config</code> in Linux. | []
|
https://avatars.githubusercontent.com/u/463136?v=4 | zipper | guidoschmidt/zipper | 2023-01-26T09:41:51Z | Experimental ziglang image sequence collection server | main | 1 | 1 | 0 | 1 | https://api.github.com/repos/guidoschmidt/zipper/tags | - | [
"creativecode",
"p5",
"threejs",
"tool",
"tooling",
"zig",
"ziglang"
]
| 48 | false | 2024-10-07T18:56:50Z | true | true | unknown | github | [
{
"commit": "refs",
"name": "zap",
"tar_url": "https://github.com/zigzap/zap/archive/refs.tar.gz",
"type": "remote",
"url": "https://github.com/zigzap/zap"
}
]
| zipper
<blockquote>
zig REST api server to store image data requests,
e.g. for saving web canvas data
</blockquote>
Rationale
Working with <a>Web canvas
API</a> it's often
tedious to export animations as movies right from the browser. Usually one ends
up using a screen recording software (OBS, Quicktime, ...) or the browsers
download feature (resulting in thousand of download prompts opening up).
This is a quick and dirty image request handler for storing images & image
sequences right from canvas API animations.
Build & Run
<code>bash
git clone [email protected]:guidoschmidt/zipper.git
cd zipper
git submodule update --recursive --init
zig build
zig build run</code>
Sending image data from the browser
Add the following Javascript/Typescript code and call it from your animation loop:
<code>typescript
function saveCanvasToBackend(selector: string, sequence: string, frame: number) {
const canvas: HTMLCanvasElement | null = document.querySelector(
selector || "canvas"
);
if (canvas === null) {
throw new Error(`No canvas element with ${selector} found`);
}
const dataUrl = canvas!
.toDataURL("image/png")
?.replace("image/png", "image/octet-stream");
const data = {
imageData: dataUrl,
foldername: `${sequence}`,
filename: `${frame}`,
ext: "png",
};
fetch("http://localhost:3000", {
method: "POST",
body: JSON.stringify(data),
});
}</code>
Implement any user interaction (button press, key press, etc) to set
<code>isRecording</code> to <code>true</code> and call <code>saveCanvasToBackend</code> in the animation loop function:
```Typescript
let frame = 0;
let isRecording = false;
function draw() {
if (isRecording) {
saveCanvasToBackend("canvas", "Sequence-1", frame);
frame++;
}
}
```
TODO
<ul>
<li>Error handling</li>
<li>p5.js example</li>
<li>three.js example</li>
</ul> | []
|
https://avatars.githubusercontent.com/u/1291012?v=4 | zig-raylib-template | charles-l/zig-raylib-template | 2022-11-05T22:11:15Z | A zig template for building games with raylib that compiles to a native exe or an emscripten app. | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/charles-l/zig-raylib-template/tags | MIT | [
"raylib",
"template-repository",
"zig"
]
| 9 | false | 2024-10-17T12:51:14Z | true | false | unknown | github | []
| zig-raylib-template
A zig template for building games with raylib that compiles to a native exe or an emscripten app.
To build for desktop:
<code>$ zig build
</code>
To build for web:
<code>$ zig build -Dtarget=wasm32-wasi --sysroot ~/src/emsdk/upstream/emscripten/
$ python -m http.server
</code>
Then navigate to <code>http://localhost:8000/game.html</code> in a web browser.
<code>$ zig version
0.11.0</code> | []
|
https://avatars.githubusercontent.com/u/49621563?v=4 | edsm-in-zig-demo-1 | dee0xeed/edsm-in-zig-demo-1 | 2022-09-27T09:07:41Z | null | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/dee0xeed/edsm-in-zig-demo-1/tags | NOASSERTION | [
"epoll",
"event-driven",
"linux",
"signals",
"state-machines",
"timers",
"zig"
]
| 23 | false | 2023-08-04T15:50:26Z | false | false | unknown | github | []
| Event driven state machines example
Timers, signals, reading from stdin
<ul>
<li>compile with <code>zig build-exe test.zig -fsingle-threaded -O ReleaseSmall</code></li>
<li>run <code>./test</code></li>
<li>type something (end with <code>Enter</code>) while it's running and see what will happen</li>
</ul>
```
Hi! I am 'TEST-SM'. Press ^C to stop me.
You can also type something and press Enter
tick #1 (nexp = 1)
tick #2 (nexp = 1)
tick #3 (nexp = 1)
tick #4 (nexp = 1)
tick #5 (nexp = 1)
435t45
have 7 bytes
you entered '435t45'
tick #6 (nexp = 1)
tick #7 (nexp = 1)
345ttick #8 (nexp = 1)
45t
have 8 bytes
you entered '345t45t'
tick #9 (nexp = 1)
tick #10 (nexp = 1)
tick #11 (nexp = 1)
```
<ul>
<li>now switch to another terminal and send <code>SIGTERM</code> to the <code>./test</code></li>
</ul>
<code>got signal #15 from PID 1597 after 26 ticks
Bye! It was 'TEST-SM'.</code> | []
|
https://avatars.githubusercontent.com/u/7715855?v=4 | er_zig_driver | borgoat/er_zig_driver | 2022-10-22T08:42:14Z | Erlang Port Driver written in Zig | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/borgoat/er_zig_driver/tags | MIT | [
"erlang",
"erlang-port-driver",
"zig"
]
| 14 | false | 2024-10-27T23:57:48Z | true | false | unknown | github | []
| Experimental
Erlang Port Driver written in Zig.
Reference
<ul>
<li>https://www.erlang.org/doc/tutorial/c_portdriver.html</li>
<li>https://www.erlang.org/doc/man/erl_driver.html</li>
<li>https://www.erlang.org/doc/man/driver_entry.html</li>
</ul> | []
|
https://avatars.githubusercontent.com/u/6756180?v=4 | cppfront-zigbuild | kassane/cppfront-zigbuild | 2022-09-24T18:32:51Z | Build Cppfront w/ zig build | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/kassane/cppfront-zigbuild/tags | MIT | [
"clang",
"cpp",
"cpp2",
"cppfront",
"zig"
]
| 34 | false | 2025-05-08T16:35:58Z | true | true | unknown | github | [
{
"commit": "b2d40209e694f74458ffaf15d8b884300fc405cc",
"name": "cppfront",
"tar_url": "https://github.com/hsutter/cppfront/archive/b2d40209e694f74458ffaf15d8b884300fc405cc.tar.gz",
"type": "remote",
"url": "https://github.com/hsutter/cppfront"
}
]
| cppfront-zigbuild
Simple demonstration of Herb Sutter cppfront <a>https://github.com/hsutter/cppfront</a> use with Zig Build-System
Requires
<ul>
<li><a>zig</a> v0.14.0 or master</li>
</ul>
How to use
```bash
<blockquote>
git clone https://github.com/kassane/cppfront-zigbuild.git
cd cppfront-zigbuild
zig build cppfront # to run the cppfront and generate example/hello.cpp
zig build run # to run C++ example
```
</blockquote> | []
|
https://avatars.githubusercontent.com/u/14120644?v=4 | raylib_zig | tato/raylib_zig | 2022-08-11T15:12:55Z | raylib bindings for zig | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/tato/raylib_zig/tags | 0BSD | [
"gamedev",
"raylib",
"zig"
]
| 167 | false | 2022-10-31T23:04:39Z | true | false | unknown | github | []
| <code>git submodule add https://github.com/tato/raylib_zig raylib
git submodule update --init --recursive</code>
<code>zig
const raylib = @import("raylib/build.zig");
exe.addPackage(raylib.raylib_pkg);
exe.linkLibrary(raylib.getRaylib(b, mode, target));</code> | [
"https://github.com/CarlOlson/gbzig",
"https://github.com/Frost-Phoenix/BytePusher",
"https://github.com/JamzOJamz/pvz-bloomiverse",
"https://github.com/KennethChilds/zig-revolution",
"https://github.com/Miou-zora/Zaytracer",
"https://github.com/SnoopyPlayz/zigCraft",
"https://github.com/asynched/sandsim",
"https://github.com/cjRem44x/ZiggyPongz",
"https://github.com/cowboy8625/raylib-zig-template",
"https://github.com/diicellman/chipz-8",
"https://github.com/h2cone/platformer",
"https://github.com/insolor/game-of-life.zig",
"https://github.com/zewenn/fyr"
]
|
https://avatars.githubusercontent.com/u/6756180?v=4 | wireguard-zig-test | kassane/wireguard-zig-test | 2023-01-13T17:20:56Z | Experimental wg-library with Zig | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/kassane/wireguard-zig-test/tags | Unlicense | [
"linux",
"testing",
"vpn",
"wireguard",
"zig"
]
| 72 | false | 2023-05-30T13:32:45Z | true | false | unknown | github | []
| wireguard-zig
This project is experimental on the possibility to use zig (toolchain and language) with Wireguard VPN.
Requirements
<ul>
<li><a>Zig v0.11 or master</a></li>
<li><a>Wireguard</a></li>
</ul>
How to Run
See CI test
<code>bash
$> zig build
$> sudo zig-out/bin/wireguard-zig
info(wireguard): wg_test0 has public key +oQRkWKK/fdi5JoLah7R9JIPI6Hg1TsaPHA2DkGjSQw=
info(wireguard): - peer vEtCZE5RZDDZseZLXJaR6q7yVqRfb0/VjijDZpikWwY=</code>
More Information
WireGuard® was created and developed by Jason A. Donenfeld. "WireGuard" and the "WireGuard" logo are registered trademarks of Jason A. Donenfeld [@zx2c4]. See https://www.wireguard.com/ for more information
This project is not approved, sponsored or affiliated with WireGuard or with the community.
<ul>
<li>The whitepaper https://www.wireguard.com/papers/wireguard.pdf</li>
<li>The Wikipedia page https://en.wikipedia.org/wiki/WireGuard </li>
</ul> | []
|
https://avatars.githubusercontent.com/u/4376947?v=4 | pcd68 | jrsharp/pcd68 | 2022-03-30T05:03:53Z | PCD-68: a 68000-based virtual retro computer (inspired by the Macintosh, Canon Cat, etc.) | main | 10 | 1 | 0 | 1 | https://api.github.com/repos/jrsharp/pcd68/tags | MIT | [
"68000",
"c",
"cpp",
"emscripten",
"emulator",
"wasm",
"webassembly",
"zig"
]
| 27,434 | false | 2023-01-11T17:29:02Z | true | false | unknown | github | []
| PCD-68
PCD-68 is a Motorola 68000-based (m68k) virtual retro computer -- that is, it is a
new computer personal computer specification implemented in software that emulates
real hardware from the past. It resembles familiar, real hardware from the late
80s/early 90s, as it draws inspiration from the original Macintosh and Canon Cat,
as well as more modern 68k-based homebrew machines.
<em>In time, it will also power the hardware pictured above.</em>
<em>An initial demo is live on <a>JonSharp.net</a> now</em>
Project Brief
<ul>
<li>68000 emulation provided by <a>Moira</a></li>
<li>400x300 B/W Framebuffer/Display</li>
<li>"Text Display Adapter" - provides text-based graphics modes:<ul>
<li>80-column mode: Uses custom 5x13 font (80x23 chars)</li>
<li>50-column mode: Uses IBM CGA font (50x33 chars)</li>
</ul>
</li>
<li>4MB RAM</li>
<li>64k ROM</li>
<li>Dual UART</li>
<li>Keyboard I/O</li>
<li>Interrupt-driven</li>
</ul>
Zig
<ul>
<li>Selected for convenient and flexible target selection</li>
<li>No native zig code (yet)</li>
</ul>
Targets
Zig native targets
Zig build is used to conveniently target supported native targets. (Supported
by the LLVM toolchain provided with Zig)
Active development and testing is taking place on both Ubuntu Linux and macOS.
SDL2 is currently the only external library dependency.
Emscripten
A web target has been a goal of this project from the start, and while this
would ideally be implemented using the zig wasm32 target, this is currently
being provided by the Emscripten toolchain, primarily for its convenient SDL2
port. The zig build script will invoke Emscripten (em++) externally if the
"BUILD_WEB" environment variable. (Emscripten must be installed and in the
shell's PATH.
<blockquote>
BUILD_WEB=true zig build
</blockquote>
Emscripten will compile pcd68-cpp, placing the output in <code>zig-out/web</code>.
A convenient python script is provided for testing:
<blockquote>
python3 ./src/emscripten/serve2.py
</blockquote>
TODO / Issues
<ul>
<li>UART (Based on Zilog SCC? Another UART? How closely conforming?)</li>
<li>68k software libraries/routines for graphics/UI/input processing?</li>
</ul>
E-Ink emulation
(In progress) E-Ink emulation is now on by default and can be turned off like:
<blockquote>
./zig-out/bin/pcd68 text_demo.bin -nf
</blockquote> | []
|
https://avatars.githubusercontent.com/u/7283681?v=4 | expiring-hash-map.zig | lun-4/expiring-hash-map.zig | 2022-07-28T01:20:33Z | need a cache or you're limited by memory in your long-lived zig code, well fear no more! | mistress | 0 | 1 | 0 | 1 | https://api.github.com/repos/lun-4/expiring-hash-map.zig/tags | MIT | [
"zig"
]
| 8 | false | 2024-05-12T20:28:25Z | true | true | 0.11.0 | github | []
| expiring-hash-map.zig
need a cache or you're limited by memory in your long-lived zig code, well fear no more!
this doesn't implement all of the HashMap API, but it is good enough
for my usecases (https://github.com/lun-4/awtfdb).
basically, it goes like this
```zig
// This hash map will hold at most 100 items, and if any of the items
// life for longer than a second, they will be removed
// to do so, get() and put() return more than just the value type, so that
// the caller can determine when to free the given memory (if the value
// has pointers that are heap allocated).
const EHM = ExpiringHashMap(1 * std.time.ns_per_s, 100, usize, usize);
var ehm = EHM.init(std.testing.allocator);
defer ehm.deinit();
// returns null
ehm.get(123);
// since we didn't have anything in the map, ignore the list of things to remove
_ = try ehm.put(123, 456);
// returns a wrapper type (?MaybeV) containing 456 as a non-expired value
var maybe_value = ehm.get(123);
maybe_value.has_value; // assert that there's a value
// sneaky sleep
std.time.sleep(1 * std.time.ns_per_s);
// now the value is expired.
var maybe_value = ehm.get(123);
maybe_value.has_value; // will error
maybe_value.expired; // returns the value, 456
// now, if i add a value, wait, and add another, the first one should be expired
_ = try ehm.put(123, 456);
std.time.sleep(1 * std.time.ns_per_s);
var to_remove = try ehm.put(127, 457);
for (to_remove) |value| do_something_to_free_this(value);
``` | []
|
https://avatars.githubusercontent.com/u/11492844?v=4 | zigFITSIO | fjebaker/zigFITSIO | 2022-10-21T16:06:21Z | Zig wrapper for CFITSIO. | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/fjebaker/zigFITSIO/tags | MIT | [
"astronomy",
"astrophysics",
"cfitsio",
"fits",
"zig"
]
| 1,437 | false | 2025-03-10T00:34:55Z | true | true | unknown | github | [
{
"commit": "master.tar.gz",
"name": "zlib",
"tar_url": "https://github.com/fjebaker/libz/archive/master.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/fjebaker/libz"
}
]
| zigFITSIO
<em>Work in progress</em>
Zig wrapper around <a>NASA's CFITSIO</a> for manipulating the FITS image/table format. | []
|
https://avatars.githubusercontent.com/u/16590917?v=4 | zls | llogick/zls | 2022-08-24T23:07:20Z | My dev fork of the Zig Language Server | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/llogick/zls/tags | MIT | [
"language-server",
"zig"
]
| 5,422 | true | 2024-10-16T09:57:19Z | true | true | 0.14.0-dev.1517+900753455 | github | [
{
"commit": "47076c6b11214a218e9244471d8762310820911a.tar.gz",
"name": "known_folders",
"tar_url": "https://github.com/ziglibs/known-folders/archive/47076c6b11214a218e9244471d8762310820911a.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/ziglibs/known-folders"
},
{
"commit": "ef45c00d655e5e40faf35afbbde81a1fa5ed7ffb.tar.gz",
"name": "diffz",
"tar_url": "https://github.com/ziglibs/diffz/archive/ef45c00d655e5e40faf35afbbde81a1fa5ed7ffb.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/ziglibs/diffz"
},
{
"commit": "6b34887189def7c859307f4a9fc436bc5f2f04c9.tar.gz",
"name": "lsp-codegen",
"tar_url": "https://github.com/zigtools/zig-lsp-codegen/archive/6b34887189def7c859307f4a9fc436bc5f2f04c9.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/zigtools/zig-lsp-codegen"
},
{
"commit": "refs",
"name": "tracy",
"tar_url": "https://github.com/wolfpld/tracy/archive/refs.tar.gz",
"type": "remote",
"url": "https://github.com/wolfpld/tracy"
}
]
|
<a></a>
<a></a>
<a></a>
<strong>Need support? Wanna help out? Join our <a>Discord server</a>!</strong>
ZLS is a non-official implementation of the <a>Language Server Protocol</a> for <a>Zig</a> in Zig. It provides developers with IDE <a>features</a> in their editor.
Installation
See the <a>Installation Guide</a> for editor and binary installation instructions.
From Source
Building ZLS requires <a>a build of Zig master</a>.
<code>bash
git clone https://github.com/zigtools/zls
cd zls
zig build -Doptimize=ReleaseSafe</code>
Features
ZLS supports most language features, including simple type function support, using namespace, payload capture type resolution, custom packages, cImport and others. Support for comptime and semantic analysis is Work-in-Progress.
The following LSP features are supported:
<ul>
<li>Completions</li>
<li>Hover</li>
<li>Goto definition/declaration</li>
<li>Document symbols</li>
<li>Find references</li>
<li>Rename symbol</li>
<li>Formatting using <code>zig fmt</code></li>
<li>Semantic token highlighting</li>
<li>Inlay hints</li>
<li>Code actions</li>
<li>Selection ranges</li>
<li>Folding regions</li>
</ul>
Related Projects
<ul>
<li><a><code>sublime-zig-language</code> by @prime31</a></li>
<li>Supports basic language features</li>
<li>Uses data provided by <code>src/data</code> to perform builtin autocompletion</li>
<li><a><code>zig-lsp</code> by @xackus</a></li>
<li>Inspiration for ZLS</li>
<li><a><code>known-folders</code> by @ziglibs</a></li>
<li>Provides API to access known folders on Linux, Windows and Mac OS</li>
<li><a><code>zls</code> by @zigtools</a></li>
<li>Used by many ZLS developers to more efficiently work on ZLS</li>
</ul>
Quick Thanks :)
We'd like to take a second to thank all our awesome <a>contributors</a> and donators/backers/sponsors; if you have time or money to spare, consider partaking in either of these options - they help keep ZLS awesome for everyone!
<a></a> | []
|
https://avatars.githubusercontent.com/u/1892046?v=4 | zig_tcl | nsmryan/zig_tcl | 2022-07-30T18:57:42Z | Zig TCL wrapper and convenience functions for writing TCL extensions in Zig | master | 4 | 1 | 0 | 1 | https://api.github.com/repos/nsmryan/zig_tcl/tags | - | [
"extension",
"tcl",
"wip",
"zig"
]
| 383 | false | 2024-07-22T23:21:56Z | true | false | unknown | github | []
| 404 | []
|
https://avatars.githubusercontent.com/u/62779291?v=4 | zig-fft | shimamura-sakura/zig-fft | 2022-12-13T10:20:06Z | Simple FFT in Zig. A port of https://github.com/lloydroc/arduino_fft, added IFFT. | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/shimamura-sakura/zig-fft/tags | MIT | [
"fft",
"zig"
]
| 4 | false | 2025-03-08T14:08:53Z | false | false | unknown | github | []
| zig-fft
Simple FFT in Zig. A port of https://github.com/lloydroc/arduino_fft, added IFFT.
Usage
```zig
pub fn main() !void {
var real = [8]f32{ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0 };
var imag = [8]f32{ -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 };
std.debug.print("IN:\n", .{});
std.debug.print("real: {d:7.3}\n", .{real});
std.debug.print("imag: {d:7.3}\n", .{imag});
<code>try fft(f32, &real, &imag);
std.debug.print("FFT:\n", .{});
std.debug.print("real: {d:7.3}\n", .{real});
std.debug.print("imag: {d:7.3}\n", .{imag});
try ifft(f32, &real, &imag);
std.debug.print("IFFT:\n", .{});
std.debug.print("real: {d:7.3}\n", .{real});
std.debug.print("imag: {d:7.3}\n", .{imag});
</code>
}
``` | []
|
https://avatars.githubusercontent.com/u/16469272?v=4 | Impuls | MKuranowski/Impuls | 2022-08-02T16:08:15Z | Python framework for processing static public transportation data | main | 3 | 1 | 0 | 1 | https://api.github.com/repos/MKuranowski/Impuls/tags | GPL-3.0 | [
"framework",
"gtfs",
"public-transport",
"python",
"zig"
]
| 9,240 | false | 2025-04-29T06:49:22Z | false | false | unknown | github | []
| Impuls
<a>GitHub</a> |
<a>Documentation</a> |
<a>Issue Tracker</a> |
<a>PyPI</a>
Impuls is a framework for processing static public transportation data.
The internal model used is very close to GTFS.
The core entity for processing is called a <em>pipeline</em>, which is composed of multiple
<em>tasks</em> that do the actual processing work.
The data is stored in an sqlite3 database with a very lightweight
wrapper to map Impuls's internal model into SQL and GTFS.
Impuls has first-class support for pulling in data from external sources, using its
<em>resource</em> mechanism. Resources are cached before the data is processed, which saves
bandwidth if some of the input data has not changed, or even allows to stop the
processing early if none of the resources have been modified.
A module for dealing with versioned, or <em>multi-file</em> sources is also provided. It allows
for easy and very flexible processing of schedules provided in discrete versions into
a single coherent file.
Installation and compilation
Impuls is mainly written in python, however a performance-critical part of this library is written
in zig and bundled alongside the shared library. To compile and install the library,
first ensure that <a>zig</a> is installed, then
run the following, preferably inside of a
<a>virtual environment</a>:
Impuls is mainly written in python, however a performance-critical part of this library is written
in zig and bundled alongside the shared library. To install the library run the following,
preferably inside of a <a>virtual environment</a>:
<code>pip install impuls</code>
Pre-built binaries are available for most platforms. To build from source
<a>zig</a> needs to be installed.
The <code>LoadBusManMDB</code> task additionally requires <a>mdbtools</a>
to be installed. This package is available in most package managers.
Examples
See <a>https://impuls.readthedocs.io/en/stable/example.html</a> for a tutorial and a more detailed
walkthrough over Impuls features.
The <code>examples</code> directory contains 4 example configurations, processing data
from four sources into a GTFS file. If you wish to run them, consult with the
<a>Development</a> section of the readme to set up the environment correctly.
Kraków
Kraków provides decent GTFS files on <a>https://gtfs.ztp.krakow.pl</a>.
The example pipeline removes unnecessary, confusing trip data and fixes
several user-facing strings.
Run with <code>python -m examples.krakow tram</code> or <code>python -m examples.krakow bus</code>.
The result GTFS will be created in <code>_workspace_krakow/krakow.tram.out.zip</code> or
<code>_workspace_krakow/krakow.bus.out.zip</code>, accordingly.
PKP IC (PKP Intercity)
PKP Intercity provides their schedules in a single CSV table at <a>ftp://ftps.intercity.pl</a>.
Unfortunately, the source data is not openly available. One needs to email PKP Intercity
through the contact provided in the <a>Polish MMTIS NAP</a>
in order to get the credentials.
The Pipeline starts by manually creating an Agency, loading the CSV data,
pulling station data from <a>https://github.com/MKuranowski/PLRailMap</a>,
adjusting some user-facing data - most importantly extracting trip legs operated by buses.
Run with <code>python -m examples.pkpic FTP_USERNAME FTP_PASSWORD</code>. The result GTFS
will be created at <code>_workspace_pkpic/pkpic.zip</code>
Radom
MZDiK Radom provides schedules in a MDB database at <a>http://mzdik.pl/index.php?id=145</a>.
It is the first example to use the <em>multi-file</em> pipeline support, as the source files
are published in discrete versions.
Multi-file pipelines consist of four distinct parts:
- an <em>intermediate provider</em>, which figures out the relevant input ("intermediate") feeds
- a <em>intermediate tasks factory</em>, which returns the tasks necessary to load
an intermediate feed into the SQLite database
- a <em>final tasks factory</em>, which returns the tasks to perform after merging intermediate feeds
- any additional <em>resources</em>, required by the intermediate or final tasks
Caching is even more involved - not only the input feeds are kept across runs,
but the databases resulting from running intermediate pipelines are also preserved.
If 3 of 4 feeds requested by the intermediate provider have already been processed -
the intermediate pipeline will run only for the single new file, but the final (merging)
pipeline will be run on all of the 4 feeds.
The intermediate provider for Radom scrapes the aforementioned website to find
available databases.
Pipeline for processing intermediate feeds is a bit more complex: it involved
loading the MDB database, cleaning up the data (removing virtual stops, generating and
cleaning calendars) and pulling stop positions from <a>http://rkm.mzdik.radom.pl/</a>.
The final pipeline simply dumps the merged dataset into a GTFS.
Run with <code>python -m examples.radom</code>, the result GTFS will
be created at <code>_workspace_radom/radom.zip</code>.
Warsaw
Warsaw is another city which requires multi-file pipelines.
ZTM Warsaw publishes distinct input files for pretty much every other day
at <a>ftp://rozklady.ztm.waw.pl</a>. The input datasets are in a completely custom
text format, requiring quite involved parsing. More details are available at
<a>https://www.ztm.waw.pl/pliki-do-pobrania/dane-rozkladowe/</a> (in Polish).
The intermediate provider picks out relevant files from the aforementioned FTP server.
Processing of intermediate feeds starts with the import of the text file into
the database. Rather uniquely, this step also prettifies stop names - as this
would be hard to do in a separate task, due to the presence of indicators
(two-digit codes uniquely identifying a stop around an intersection) in the name field.
The pipeline continues by adding version meta-data, merging railway stations into a single
stops.txt entry (ZTM separates railway departures into virtual stops) and attribute
prettifying (namely trip_headsign and stop_lat,stop_lon - not all stops have positions
in the input file). Last steps involve cleaning up unused entities from the database.
The final pipeline simply dumps the merged dataset into a GTFS, yet again.
Additional data for stop positions and edge-cases for prettifying stop names
comes from <a>https://github.com/MKuranowski/WarsawGTFS/blob/master/data_curated/stop_names.json</a>.
Run with <code>python -m examples.warsaw</code>, the result GTFS will
be created at <code>_workspace_warsaw/warsaw.zip</code>.
License
Impuls is distributed under GNU GPL v3 (or any later version).
<blockquote>
© Copyright 2022-2025 Mikołaj Kuranowski
Impuls is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Impuls is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Impuls. If not, see <a>http://www.gnu.org/licenses/</a>.
</blockquote>
Impuls source code and pre-built binaries come with <a>sqlite3</a>,
which <a>is placed in the public domain</a>.
Development
Impuls uses <a>meson-python</a>. The
project layout is quite unorthodox, as Impuls in neither a pure-python module, nor a project
with a bog-standard C/C++ extension. Instead, the zig code is compiled into a shared library
which is bundled alongside the python module.
Zig allows super easy cross-compilation, while using a shared library allows a single wheel
to be used across multiple python versions and implementations.
Development requires <a>python</a>, <a>zig</a>
and <a>mdbtools</a> (usually all 3 will be available in your
package manager repositories) to be installed. To set up the environment on Linux, run:
<code>terminal
$ python -m venv --upgrade-deps .venv
$ . .venv/bin/activate
$ pip install -Ur requirements.dev.txt
$ pip install --no-build-isolation -Cbuild-dir=builddir --editable .
$ ln -s ../../builddir/libextern.so impuls/extern</code>
On MacOS, change the shared library file extension to <code>.dylib</code>. On Windows, change the extension
of the shared library to <code>.dll</code>.
To run python tests, simply execute <code>pytest</code>. To run zig tests, run <code>meson test -C builddir</code>.
To run the examples, install their dependencies first (<code>pip install -Ur requirements.examples.txt</code>),
then execute the example module, e.g. <code>python -m examples.krakow</code>.
meson-python will automatically recompile the zig library whenever an editable impuls install is
imported; set the <code>MESONPY_EDITABLE_VERBOSE</code> environment variable to <code>1</code> to see meson logs for build
details.
By default, the extern zig library will be built in debug mode. To change that, run
<code>meson configure --buildtype=debugoptimized builddir</code> (buildtype can also be set to <code>debug</code> or
<code>release</code>). To recompile the library, run <code>meson compile -C builddir</code>.
Unfortunately, meson-python requires all python and zig source files in meson.build. Python
files need to be listed for packaging to work, while zig source files need to be listed for
the build backend to properly detect whether libextern needs to be recompiled.
Building wheels
Zig has been chosen for its excellent cross-compilation support. Thanks to this, building
all wheels for a release does not require tools like <a>cibuildwheel</a>,
virtual machines, or even any containers. As long as Zig is installed, all wheels can be
build on that machine.
Before building wheels, install a few extra dependencies in the virtual environment:
<code>pip install -U build wheel</code>.
To build the wheels, simply run <code>python build_wheels.py</code>.
See <code>python build_wheels.py --help</code> for all available options. To debug failed builds, run
<code>python build_wheels.py --verbose --jobs 1 FAILED_CONFIG_NAME</code>.
See <a>CONFIGURATION in build_wheels.py</a> for available configurations.
To build the source distribution, run <code>python -m build -so dist</code>. | []
|
https://avatars.githubusercontent.com/u/26842759?v=4 | Zoids | Demonstrandum/Zoids | 2022-09-15T19:24:23Z | Boids in Zig (GLFW+NanoVG / WASM+WebGL). | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/Demonstrandum/Zoids/tags | GPL-3.0 | [
"boids",
"glfw",
"opengl",
"wasm",
"webgl",
"zig"
]
| 48 | false | 2022-10-31T23:07:56Z | true | false | unknown | github | []
| Zoids
Boids, in OpenGL+GLFW using NanoVG. Written in Zig.
Just for trying out the language and tools.
WASM Web Version
See the boids compiled to WASM online here: <a>demonstrandum.github.io/Zoids</a>.
Dependencies
You must have <code>glfw</code> and <code>nanovg</code> installed as system packages.
Clone with
<code>sh
git clone --recurse-submodules -j8 https://github.com/Demonstrandum/Zoids.git</code>
Run
<code>sh
zig build run</code>
Build WASM
Build <code>zoids.wasm</code> and construct a website to <code>deployment/</code>.
Must run web-server to serve local files, using Python <code>http.server</code>, for example.
<code>sh
zig build website -Dtarget=wasm32-freestanding
python3 -m http.server 8080 --directory ./deployment/
open http://localhost:8080/</code>
| []
|
https://avatars.githubusercontent.com/u/56469224?v=4 | simple-tcp-zig | rubenkristian/simple-tcp-zig | 2022-08-06T14:24:13Z | simple tcp server written in zig | main | 0 | 1 | 1 | 1 | https://api.github.com/repos/rubenkristian/simple-tcp-zig/tags | - | [
"tcp",
"zig"
]
| 41 | false | 2022-09-10T02:53:57Z | true | false | unknown | github | []
| simple-tcp-zig
simple tcp server written in zig
EXAMPLE
| []
|
https://avatars.githubusercontent.com/u/46655455?v=4 | zignc | 4zv4l/zignc | 2022-04-30T10:29:34Z | a simple tcp client/server in zig | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/4zv4l/zignc/tags | - | [
"network",
"socket",
"tcp",
"tcp-client",
"zig"
]
| 282 | false | 2024-06-08T14:57:43Z | true | false | unknown | github | []
| zignc
a simple tcp client/server in zig
Build
To compile the code simply :
<code>zig build</code>
Usage
```
Usage : ./zig-out/bin/socket [OPTION] [ip] [port]
OPTION:
-l to start as server
``` | []
|
https://avatars.githubusercontent.com/u/198515398?v=4 | algotree | oldlegacycode/algotree | 2022-12-15T23:35:45Z | Algorithmically grow trees using love2d, raylib or pixijs | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/oldlegacycode/algotree/tags | CC0-1.0 | [
"algorithmically",
"algotree",
"javascript",
"love2d",
"lua",
"nature",
"pixijs",
"raylib",
"zig"
]
| 1,334 | false | 2025-04-13T07:56:05Z | false | false | unknown | github | []
| Algotree
Algorithmicaly generated growing trees
there are currently three versions made with different tools and languages
<a>Zig</a> + <a>Raylib</a> | <a>PixiJS</a> - 2022
<ul>
<li><a>zig source</a></li>
<li><a>pixijs source</a></li>
</ul>
Lua + <a>LÖVE</a> - 2021
<a>source</a> | []
|
https://avatars.githubusercontent.com/u/107726195?v=4 | zig-wii | zig-homebrew/zig-wii | 2022-06-19T11:29:13Z | Starter pack for developing Wii games/applications with Zig | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/zig-homebrew/zig-wii/tags | - | [
"devkitpro",
"wii",
"zig"
]
| 3 | false | 2022-06-19T11:30:17Z | true | false | unknown | github | []
| zig-wii
Getting started
<ul>
<li><a>zig</a></li>
<li><a>devkitPro</a></li>
</ul>
<code>pacman -S wii-dev
git clone https://github.com/zig-homebrew/zig-wii
cd zig-wii/
zig build # then run zig-out/zig-wii.dol with dolphin-emu</code>
Resources
<ul>
<li><a>wii-examples</a></li>
<li><a>libogc repository</a></li>
<li><a>libogc documentation</a></li>
</ul> | []
|
https://avatars.githubusercontent.com/u/74600205?v=4 | stm32f103rb-template-project-zig | JungerBoyo/stm32f103rb-template-project-zig | 2022-08-26T11:38:46Z | stm32f103rb mcu ziglang template project with microzig | main | 0 | 1 | 1 | 1 | https://api.github.com/repos/JungerBoyo/stm32f103rb-template-project-zig/tags | MIT | [
"embedded-zig",
"microzig",
"stm32f103rb",
"zig",
"ziglang"
]
| 365 | false | 2022-12-09T05:20:32Z | true | false | unknown | github | []
| stm32f103rb-template-project-zig
stm32f103rb mcu ziglang template project with microzig. To use you will need zig >=0.10.0 compiler, st-flash and st-util.
Building
Build steps:
* Build to elf and binary, run <code>zig build -fstage1 install.</code>
* Flash binary using st-flash tool, run <code>zig build -fstage1 flash</code>
Debugging
Steps:
* switch build mode to <code>.Debug</code>
* <code>run gdb</code> and <code>st-util</code>
* (in gdb) <code>target extended:4242</code>
* (in gdb) <code>file zig-out/bin/<project_name>.elf</code> | []
|
https://avatars.githubusercontent.com/u/1892046?v=4 | zig_shadowcasting | nsmryan/zig_shadowcasting | 2022-08-07T16:13:06Z | A Zig translation of the algorithm found here: https://www.albertford.com/shadowcasting/ | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/nsmryan/zig_shadowcasting/tags | - | [
"roguelike",
"shadowcasting",
"zig",
"ziglang"
]
| 21 | false | 2023-05-01T12:07:04Z | true | false | unknown | github | []
| Zig Symmetric Shadow Casting
This repository contains a Zig translation of the <a>Rust translation</a>
of this <a>Python algorithm</a>.
The best source for information on this algorithm is the Python blog post
by Albert Ford, which is a really beautiful post and worth reading.
The algorithm itself is a very nice field of view algorithm that can be used
in a roguelike for determining visiblity, with the nice properties described
in the original post. I have found this algorithm to give good results, and
I use it with additional laying on top in my <a>own roguelike</a>.
The Zig version is slightly different from the Rust and Python. I tried a series of
different designs before landing on a simplification of the other implementations which
is less generic but easier to use in Zig.
Example Use
This repository defines a simple Pos (position) type which is just a pair of 'isize's. This can be
converted to an from user types if you already have a position type in use.
To use this field of view function, simply call 'compute_fov' with the starting location, the generic map structure,
an ArrayList which will be used to mark visible locations, and a function pointer which takes a position and the map,
and returns a boolean indicating whether the given position is blocked on the map.
This keeps the map type and the concept of 'blocking' tiles in the user's control. However, the return type (the visible tiles)
is always an ArrayList(Pos), unlike the Rust and Python where these are generic.
```zig
// The user must define a function which takes a Pos and the user's map type, and returns
// whether the given position is blocked in the map.
fn is_blocking_fn(pos: Pos, tiles: []const []const isize) bool {
return !inside_map(pos, tiles) or tiles[@intCast(usize, pos.y)][@intCast(usize, pos.x)] == 1;
}
<code>// This 'use_fov' function is an example of using 'compute_fov'.
fn use_fov() void {
const origin = Pos.new(3, 0);
// The map, in this case an array of slices, each containing an isize. If the isize is 1, the tile
// is blocked. If the isize is 0 it is not blocked.
const tiles = [_][]const isize{ &.{ 0, 0, 0, 0, 0, 0, 0 }, &.{ 1, 1, 1, 1, 0, 0, 0 }, &.{ 0, 0, 0, 1, 0, 0, 0 }, &.{ 0, 0, 0, 1, 0, 0, 0 } };
// Create the arraylist to store visible tiles.
var allocator = std.heap.GeneralPurposeAllocator(.{}){};
var visible = ArrayList(Pos).init(allocator.allocator());
visible.deinit();
// Compute FoV using the symmetric shadow casting algorithm.
try compute_fov(origin, tiles[0..], &visible, is_blocking_fn);
// Now the 'visible' array list contains a series of Pos values indicating which positions were
// visible.
}
</code>
```
Note that the 'compute_fov' function takes a pointer to an ArrayList instead of creating the ArrayList
itself in order to allow the user to re-use an existing ArrayList, avoiding additional allocations. | []
|
https://avatars.githubusercontent.com/u/825?v=4 | zia | wunki/zia | 2023-01-25T05:48:15Z | Zia is a minimal command line tool which makes you learn Zig 10% faster. | main | 2 | 1 | 0 | 1 | https://api.github.com/repos/wunki/zia/tags | - | [
"zig"
]
| 126 | false | 2024-12-28T20:29:50Z | true | false | unknown | github | []
| Zia (/seeya:/)
Zia is a minimal command line tool which makes you learn Zig 10% faster.
That is, if you add it to your Shell at startup. If you do that, every time your shell starts you will get a new random buildin function from Zig and its documentation.
Since we have all the functions and documentation built into the binary, it's <em>blazingly</em> fast.
This is all you get:
Licensing
Zia is released under the MIT license. | []
|
https://avatars.githubusercontent.com/u/74600205?v=4 | zi-status | JungerBoyo/zi-status | 2023-02-05T22:39:06Z | Xorg status bar written in zig. | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/JungerBoyo/zi-status/tags | MIT | [
"alsa",
"dwmstatus",
"xorg",
"zig"
]
| 95 | false | 2023-06-24T12:21:31Z | true | false | unknown | github | []
| zi-status
Currently shows
<ul>
<li>internet connection state (ip+mask+speed+type{wifi,ethernet}+SSID(only wifi)+signal strength(only wifi)</li>
<li>date and time info</li>
<li>battery info</li>
<li>sound level info (ALSA)</li>
<li>ram memory usage in MB (Total mem - Available mem)</li>
<li>weather info (temp+humidity+sunset)</li>
</ul>
Configuration instructions
Under src/ there is config.zig file. In there you can adjust available config parameters that are mostly self-explanatory. Config argument <code>WEATHER_X_API_KEY</code> is a string that you get after making an account at https://api-ninjas.com. There you get 50k free API requests per month.
After adjusting the config enter the project directory and:
<code>zig build -Drelease-fast=true</code>
It will build the project and ouput the executable under <code>$PROJ_DIR/zig-out/bin</code>
Running instructions
<code>zi-status</code> takes one optional* <code>timezone</code> parameter in format (+/-)NN00 where N is a digit. For example for timezone UTC+1 the argument should be +0100. Format is based on one that <code>timedatectl</code> command returns. Example of how to extract it from timedatectl output:
<code>timedatectl | grep zone | awk '{print$5}' | tr -d "\)"</code>
*if no timezone arg is passed timezone +0000 is assumed | []
|
https://avatars.githubusercontent.com/u/6756180?v=4 | riscv64-hello-linux | kassane/riscv64-hello-linux | 2022-08-21T16:28:25Z | A simple program for Linux on RISC-V 64, written in Rust and Zig | hello-zig | 0 | 1 | 0 | 1 | https://api.github.com/repos/kassane/riscv64-hello-linux/tags | GPL-2.0 | [
"cross-platform",
"risc-v",
"riscv",
"rust",
"zig"
]
| 35 | true | 2024-08-24T19:45:10Z | true | false | unknown | github | []
| Hello Linux RISC-V 64
This tiny tool lets you print some information from <code>/proc</code> and <code>uname</code> from
Linux on RISC-V 64.
Build
Rust Version
You will need <a>Rust</a> and the linker from
<code>riscv64-linux-gnu-gcc</code>.
<code>sh
cargo build --release</code>
or <code>zig</code> linker:
```sh
cargo install cargo-zigbuild
cargo zigbuild --release
```
Zig version
You will need <a>Zig</a>
```sh
zig version v0.11 or higher (default self-hosting compiler [stage3])
zig build -Doptimize= -Dtarget=arch-os-libc
mode = ReleaseSafe|ReleaseFast|ReleaseSmall
specific target
zig build -Doptimize= -Dtarget=riscv64-linux -Dcpu=baseline_rv64+v # Allwinner D1
more features RISC-V: https://github.com/lupyuen/zig-bl602-nuttx/issues/1
Execute (after builded)
./zig-out/bin/hello-zig
or run directly (default: host target)
zig build run -Doptimize= -Dtarget=riscv64-linux
all targets
zig targets | jq .libc
```
Run via <a><code>cpu</code></a>
<code>sh
cpu -key ~/.ssh/cpu_rsa -timeout9p 2000ms target-host \
./target/riscv64gc-unknown-linux-gnu/release/hello-rust
or
./zig-out/bin/hello-zig</code> | []
|
https://avatars.githubusercontent.com/u/337093?v=4 | tftp_client | tetsu-koba/tftp_client | 2023-01-06T07:36:41Z | tftp client written in Zig language | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/tetsu-koba/tftp_client/tags | MIT | [
"zig"
]
| 66 | false | 2024-06-17T01:48:59Z | true | false | unknown | github | []
| tftp_client
<a>tftp</a> client written in Zig language
How to build
<code>shell-session
$ zig build
$ ls -l zig-out/bin/tftp_client
-rwxrwxr-x 1 koba koba 1705368 Jan 9 16:32 zig-out/bin/tftp_client</code>
Usage
<code>shell-session
$ ./zig-out/bin/tftp_client
Usage: ./zig-out/bin/tftp_client get|put host remote_filename [local_filename]</code>
<code>shell-session
$ ./zig-out/bin/tftp_client get localhost hello.txt
1673249781311:send_bytes=18, "\0\1hello.txt\0octet\0", a=127.0.0.1:69
1673249781314:recv_bytes=18, [00 03 00 01 ...], os.linux.sockaddr{ .family = 2, .data = { 169, 222, 127, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } }
1673249781314:send_bytes=4, [00 04 00 01 ]</code>
Now verbose mode is hard coded to be true. | []
|
https://avatars.githubusercontent.com/u/107234593?v=4 | zig-wii.github.io | zig-wii/zig-wii.github.io | 2022-06-14T16:50:10Z | Website for zig-wii | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/zig-wii/zig-wii.github.io/tags | - | [
"website",
"wii",
"zig"
]
| 34 | false | 2022-06-14T17:05:12Z | false | false | unknown | github | []
| 404 | []
|
https://avatars.githubusercontent.com/u/635049?v=4 | zig-playdate | chances/zig-playdate | 2022-05-17T23:40:24Z | Zig template for building Playdate games & apps | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/chances/zig-playdate/tags | MIT | [
"playdate",
"zig"
]
| 12 | false | 2022-12-07T04:47:38Z | true | false | unknown | github | []
| zig-playdate
Zig template for building Playdate games & apps | []
|
https://avatars.githubusercontent.com/u/8497012?v=4 | zig-cli-color | apple-x-co/zig-cli-color | 2022-08-14T06:21:53Z | for learning | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/apple-x-co/zig-cli-color/tags | - | [
"zig"
]
| 82 | false | 2023-11-01T17:25:33Z | true | false | unknown | github | []
| zig-cli-color
Build
<code>bash
zig build -Doptimize=ReleaseFast</code>
Run
<code>bash
zig build run</code>
Usage
```zig
const std = @import("std");
const Color = @import("color.zig").Color;
var allocator = std.heap.page_allocator;
var color = Color.init(allocator);
defer color.deinit();
std.debug.print("{s}{s}\n", .{ color.fgBlack("Foreground BLACK"), color.reset() });
``` | []
|
https://avatars.githubusercontent.com/u/3477132?v=4 | advent-of-code | anthonycorletti/advent-of-code | 2022-12-21T22:06:52Z | https://adventofcode.com/ | main | 0 | 1 | 1 | 1 | https://api.github.com/repos/anthonycorletti/advent-of-code/tags | - | [
"advent-of-code",
"ruby",
"rust",
"zig"
]
| 189 | false | 2024-12-07T01:25:04Z | false | false | unknown | github | []
| advent-of-code
<ul>
<li><a>2024</a> zig 🦎</li>
<li><a>2023</a> ruby 💎</li>
<li><a>2022</a> rust ⚙️</li>
</ul> | []
|
https://avatars.githubusercontent.com/u/1892046?v=4 | zig_astar | nsmryan/zig_astar | 2022-09-04T18:07:37Z | Simple implementation of the A-Star algorithm in Zig | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/nsmryan/zig_astar/tags | - | [
"astar",
"library",
"zig",
"ziglang"
]
| 4 | false | 2024-12-28T19:39:24Z | true | false | unknown | github | []
| Zig AStar
This repository contains a simple implementation of the A-Star algorithm in Zig.
This is not intended to be fancy. However, it does take a user-defined
position type and distance function, and does not assume anything about the
space that the pathfinding takes place in.
Instead the algorithm expects the user to drive it, tracking paths and asking the user
for the neighbors of a particular location. When the algorithm finds a path to the end
location it will report that it is done. This is similar to an iterator, and avoids
requiring any kind of user defined map type or "neighbors" function to be provided.
The implementation uses the std.ArrayList and std.PriorityQueue, and takes an allocator
from the user.
See below for an example use. Notice that the user code drives the search by
calling 'step', and feeding back the requested slice of neighbor positions.
```zig
const SimplePos = struct {
x: isize,
y: isize,
<code>pub fn init(x: isize, y: isize) SimplePos {
return SimplePos{ .x = x, .y = y };
}
</code>
};
fn simple_distance(start: SimplePos, end: SimplePos) usize {
const x_dist = std.math.absInt(start.x - end.x) catch unreachable;
const y_dist = std.math.absInt(start.y - end.y) catch unreachable;
return @intCast(usize, std.math.min(x_dist, y_dist));
}
pub main() void {
const allocator = std.heap.page_allocator;
<code>const PathFinder = Astar(SimplePos, simple_distance);
var neighbors = ArrayList(SimplePos).init(allocator);
defer neighbors.deinit();
const start = SimplePos.init(0, 0);
const end = SimplePos.init(4, 4);
var result = try finder.pathFind(start, end);
while (result == .neighbors) {
const pos = result.neighbors;
neighbors.clearRetainingCapacity();
const offsets: [3]isize = .{ -1, 0, 1 };
for (offsets) |offset_x| {
for (offsets) |offset_y| {
const new_x = pos.x + offset_x;
const new_y = pos.y + offset_y;
// User defined validity function 'IsValid' not shown.
if (!IsValid(new_x, new_y)) {
continue;
}
const next_pos = SimplePos.init(new_x, new_y);
try neighbors.append(next_pos);
}
}
result = try finder.step(neighbors.items);
}
// The 'result' variable is now either .done, with the Path structure containing the
// path from start to end, or .no_path indicating that there is no valid path.
switch (result) {
.no_path => {
// Error
},
.done => |path| {
// Path from start to end of type Path(SimplePos).
},
.neighbors => {
unreachable
},
}
</code>
}
``` | []
|
https://avatars.githubusercontent.com/u/5464072?v=4 | s3cmd | nektro/s3cmd | 2022-11-15T22:17:10Z | A drop-in replacement for s3tools/s3cmd written in Ziglang for better performance and bootstrappability. | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/nektro/s3cmd/tags | GPL-2.0 | [
"zig"
]
| 14 | false | 2024-06-22T18:27:32Z | true | false | unknown | github | []
| s3cmd
A drop-in replacement for https://github.com/s3tools/s3cmd written in Ziglang for better performance and bootstrappability.
<blockquote>
Command line tool for querying and managing Amazon S3 services.
</blockquote>
What is Amazon S3
Amazon Simple Storage Service (Amazon S3) provides a managed internet-accessible storage service where anyone can store any amount of data and retrieve it later again.
S3 is a paid service operated by Amazon. Before storing anything into S3 you must sign up for an "AWS" account (where AWS = Amazon Web Services) to obtain a pair of identifiers: Access Key and Secret Key. You will need to give these keys to S3cmd. Think of them as if they were a username and password for your S3 account.
Built With
<ul>
<li>Zig 0.10.0</li>
<li>See <a><code>zigmod.yml</code></a> and <a><code>zigmod.lock</code></a></li>
</ul>
Supported Commands
<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> <code>s3cmd mb</code>
<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> <code>s3cmd rb</code>
<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> <code>s3cmd ls</code>
<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> <code>s3cmd la</code>
<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> <code>s3cmd put</code>
<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> <code>s3cmd get</code>
<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> <code>s3cmd del</code>
<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> <code>s3cmd rm</code>
<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> <code>s3cmd restore</code>
<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> <code>s3cmd sync</code>
<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> <code>s3cmd du</code>
<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> <code>s3cmd info</code>
<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> <code>s3cmd cp</code>
<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> <code>s3cmd modify</code>
<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> <code>s3cmd mv</code>
<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> <code>s3cmd setacl</code>
<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> <code>s3cmd setpolicy</code>
<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> <code>s3cmd delpolicy</code>
<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> <code>s3cmd setcors</code>
<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> <code>s3cmd delcors</code>
<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> <code>s3cmd payer</code>
<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> <code>s3cmd multipart</code>
<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> <code>s3cmd abortmp</code>
<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> <code>s3cmd listmp</code>
<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> <code>s3cmd accesslog</code>
<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> <code>s3cmd sign</code>
<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> <code>s3cmd signurl</code>
<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> <code>s3cmd fixbucket</code>
<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> <code>s3cmd ws-create</code>
<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> <code>s3cmd ws-delete</code>
<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> <code>s3cmd ws-info</code>
<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> <code>s3cmd expire</code>
<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> <code>s3cmd setlifecycle</code>
<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> <code>s3cmd getlifecycle</code>
<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> <code>s3cmd dellifecycle</code> | []
|
https://avatars.githubusercontent.com/u/2828351?v=4 | Zig-LC4k | bcrist/Zig-LC4k | 2022-11-25T19:45:28Z | Generate ispMach4000 CPLD bitstreams directly from Zig code | main | 7 | 1 | 0 | 1 | https://api.github.com/repos/bcrist/Zig-LC4k/tags | MIT | [
"cpld",
"cplds",
"lattice",
"zig",
"zig-library",
"zig-package",
"ziglang"
]
| 894 | false | 2025-04-23T13:57:08Z | true | true | 0.14.0 | github | [
{
"commit": "32b5e5e57554cdf549da81e7808a5fb37fd12154",
"name": "console_helper",
"tar_url": "https://github.com/bcrist/Zig-ConsoleHelper/archive/32b5e5e57554cdf549da81e7808a5fb37fd12154.tar.gz",
"type": "remote",
"url": "https://github.com/bcrist/Zig-ConsoleHelper"
},
{
"commit": "00416cf2cb4681c23533e0e804dc13c573a6eb28",
"name": "limp",
"tar_url": "https://github.com/bcrist/limp/archive/00416cf2cb4681c23533e0e804dc13c573a6eb28.tar.gz",
"type": "remote",
"url": "https://github.com/bcrist/limp"
},
{
"commit": "ff0a3dc2d0887cddd4076adf85e55a1fedc6feff",
"name": "re4k",
"tar_url": "https://github.com/bcrist/RE4k/archive/ff0a3dc2d0887cddd4076adf85e55a1fedc6feff.tar.gz",
"type": "remote",
"url": "https://github.com/bcrist/RE4k"
}
]
| Lattice ispMach4000 CPLD configuration in Zig
A library for creating and manipulating configuration bitstreams for LC4k CPLDs, using Zig code.
This project uses reverse-engineered fuse maps from the <a>RE4k</a> project.
Device Support
All LC4032, LC4064, and LC4128 device variants are supported, including -V, -B, -C, -ZC, and -ZE variants.
LC4256 and larger devices are not supported at this time.
Automotive (LA4xxx) variants may or may not use the same fusemaps as their LC counterparts, but please don't use this project for any automotive or other safety-critical applications.
Usage
Add the library to your project through the Zig package manager:
<code>zig fetch --save git+https://github.com/bcrist/zig-lc4k</code>
In your <code>build.zig</code>, you can then add an import for the <code>lc4k</code> module:
<code>zig
my_exe.root_module.addImport("lc4k", b.dependency("LC4k", .{}).module("lc4k"));</code>
Workflow
To use the library, you first need to construct one of the device configuration structs defined in the <code>lc4k</code> module (e.g. <code>lc4k.LC4032ZE_TQFP48</code>). Usually this is done manually, initializing the macrocells and other configuration necessary to define your design, using Zig code as a low-level pseudo-HDL. Check the examples directory for more details. You can also load an existing bitstream/JEDEC file, e.g. for reverse engineering:
<code>zig
const file_contents = try std.fs.cwd().readFileAlloc(allocator, "path/to/bitstream_file.jed", 1000000);
const bitstream = try lc4k.LC4032ZE_TQFP48.parse_jed(allocator, file_contents);
const results = try lc4k.LC4032ZE_TQFP48.disassemble(allocator, bitstream);
const chip = results.config;</code>
Note that while this library includes a basic expression parser, it does not and will not support synthesizing a design from Verilog, VHDL, ABEL, or any other HDL. It is my opinion that such workflows often don't allow sufficient control over how the limited hardware resources are utilized, and designs that will fit in 32-128 macrocell CPLDs are rarely complex enough where such an abstracted representation is necessary.
Once you have your in-memory representation of the design, you can do a number of things with it:
<ul>
<li>Generate an HTML report detailing the design, including timing information.</li>
<li>Export the design as a JEDEC or SVF file for programming devices.</li>
<li>Simulate your design or write tests to verify its functionality.</li>
<li>Write your own Zig code that does whatever you want.</li>
</ul>
Logic Parser
An expression parser is included as a more convenient way to define the logic to assign to a particular macrocell, compared to manually defining product terms with, e.g. <code>signal.when_high().pt().and_factor(...)</code> which can quickly become hard to read. To use the logic parser, you will need three things:
* A general purpose allocator used for temporary data needed while parsing (does not retain any allocations between calls to the parser).
* An arena used to allocate the final results of parsing (arrays of product terms and factors).
* A <code>*const Names</code> used to map identifiers within expressions to device signals.
For examples of initializing a parser, check the <a>examples</a>.
Once you have a parser, there are several ways to parse an expression:
* <code>Logic_Parser.pt(equation, options)</code>: Generates a single product term, suitable for assignment to a GLB config's <code>shared_pt_enable</code>, etc.
* <code>Logic_Parser.pt_with_polarity(equation, options)</code>: Generates a single product term, suitable for assignment to a GLB config's <code>shared_pt_clock</code>, etc, where the product term can be inverted to support sum expressions.
* <code>Logic_Parser.sum(equation, options)</code>: Generates an array of product terms, for use when you want to process the results more before using them
* <code>Logic_Parser.sum_with_polarity(equation, options)</code>: Generates an array of product terms suitable for assignment to <code>five_pt_fast_bypass</code>, etc, where the result can be inverted to support product-of-sums expressions.
* <code>Logic_Parser.logic(equation, options)</code>: Suitable for assignment to a macrocell config's <code>logic</code> field.
* <code>Logic_Parser.assign_logic(chip, mc_signals, equation, options)</code>: Unlike all the previous functions, this form allows the final result of the equation to have multiple bits. Rather than returning the parsed logic, it will automatically assign each bit of the result to the macrocell logic field corresponding to the same bit in the <code>mc_signals</code> array.
When the <code>logic</code> or <code>assign_logic</code> forms are used, it will attempt to use the logic mode which uses the fewest resources:
* If the equation or its complement use only one product term, then <code>pt0</code> or <code>pt0_inverted</code> will be used so that the macrocell's other PTs can be routed to another cluster.
* If the "top level" operation in the equation is an XOR, and one side of it (or its complement) uses only one PT, then <code>sum_xor_pt0</code> or <code>sum_xor_pt0_inverted</code> will be used, unless <code>sum</code> or <code>sum_inverted</code> would use fewer total PTs.
* Otherwise <code>sum</code> or <code>sum_inverted</code> will be used (whichever uses fewer total PTs).
Note: the <code>input_buffer</code> and <code>sum_xor_input_buffer</code> modes will never be generated.
Parser Options
<ul>
<li><code>Options.max_product_terms</code>: Allows limiting the number of product terms that can be produced before an error will be generated. By default, up to 80 PTs can be generated (the maximum that exist in each GLB)</li>
<li><code>Options.optimize</code>: When enabled, expressions will be optimized using the Quine-McCluskey-Petrick method. This optimization is exponential in time and space complexity, so it is not enabled by default. When disabled, expressions will be normalized if they are not in sum-of-products form, and many symbolic simplifications will be performed if possible, but there is no guarantee that the minimum number of product terms will be used.</li>
<li><code>Options.dont_care</code>: When optimization is enabled, a secondary equation can be provided here to indicate conditions where the result does not matter. The optimizer may then be able to use fewer product terms.</li>
</ul>
Options are passed to the the <code>Logic_Parser</code> through an <code>anytype</code> parameter. Arbitrary additional names can be defined in this struct and they can be used in the expression as if they had been defined in the <code>Names</code> struct.
See the <a>gray code counter</a> example for a demonstration of this.
Parser Syntax
```
;;;; Basics ;;;;
; Anything between a semicolon and the next LF (\n) character is considered a comment.
abcd ; Identifiers represent named signals or buses, defined by the Names struct.
a123 ; Identifiers may contain ASCII letters, digits, "_", ".", or "$" but may not start with a digit.
0 ; Literals are numeric constants representing specific bit patterns.
123 ; Decimal literals are considered to have the minimum number of bits required to store their value.
8'0 ; You can specify the number of bits before the literal value by separating them with the
; single-quote ('), similar to Verilog.
0xFF ; You can specify hex literals with the "0x" or "0h" prefixes (they are all equivalent).
FF ; You can also use the "#" character prefix to indicate a hex literal.
0o77 ; Octal literals can be specified with "0o".
0b11 ; And binary literals with "0b".
'hFF ; Just "h", "x", "o", or "b" works, as long as it's not the very first character of the literal.
; All literals must start with a digit, "'", "-", or "#".
8'xF ; Hex/octal/binary literal bits = log2(base) * num_digits, but this can be overridden.
(expr) ; Parentheses can be used to group subexpressions.
;;;; Operations ;;;;
; Listed in order of increasing binding power.
A | B ; Bitwise OR. A and B must have the same bit width or one of them must have width of 1 bit.
A + B ; Bitwise OR (alternate style)
A ^ B ; Bitwise XOR. A and B must have the same bit width or one of them must have width of 1 bit.
; When mixed, OR and XOR operations are performed from left to right.
A & B ; Bitwise AND. A and B must have the same bit width or one of them must have width of 1 bit.
A * B ; Bitwise AND (alternate style)
A == B ; Syntactic sugar for &~(A^B). A and B must have same width; the result will always be 1 bit.
A != B ; Syntactic sugar for |(A^B). A and B must have same width; the result will always be 1 bit.
~ A ; Ones' complement. The result will have the same bit width as A.
! A ; Ones' complement (alternate style)
| A ; Condensing OR. A may have any bit width; the result will always be 1 bit.
+ A ; Condensing OR (alternate style)
^ A ; Condensing XOR (even parity generator). A may have any width; the result will always be 1 bit.
& A ; Condensing AND. A may have any bit width; the result will always be 1 bit.
* A ; Condensing AND (alternate style)
@pad A ; Converts any macrocell feedback signals in A to the corresponding macrocell's I/O pad signal.
@fb A ; Converts any macrocell I/O signals in A to the corresponding macrocell's feedback signal.
; Extraction operator:
A[0] ; Extract bit 0. The LSB has index 0.
A[7 5 3] ; Extract and concatenate bits 7, 5, and 3. Bit 3 will be the LSB of the result.
A[3 5 7] ; Illegal; indices must be listed in big-endian order to avoid accidentally swapping signals.
A[>7 5 3] ; Same as above; explicitly calls out big-endian ordering of concatenation.
A[7>5>3] ; Same as above; > can be duplicated and placed anywhere within [ ].
A[<3 5 7] ; Same as above; using little-endian ordering.
A[<7 5 3] ; Swapping relative order of bits is allowed when endianness is explicit.
A[7:4] ; Extract bits 4-7, both endpoints inclusive. Bit 4 will be the LSB of the result.
A[>7:4] ; Same as above; explicitly big-endian.
A[<4:7] ; Same as above; explicitly little-endian.
A[<7:4] ; Extract bits 4-7, reversed. Bit 7 will be the LSB and bit 4 the MSB.
A[>4:7] ; Same as above; using big-endian ordering.
A[4:7] ; Illegal; endianness must be explicit when extracting a reversed range.
A[:] ; Endpoints that are omitted are assumed to be either 0 or bits(A)-1.
A[7 3 1:0] ; Individual bits and ranges can be mixed and matched.
A[B] ; Define a mux by using an identifier instead of a constant. bits(A) must == 2^bits(B).
A[B C] ; Illegal; only a single non-constant expression is allowed for muxes.
; Concatenation operator:
{A B} ; Concatenate A and B. B[0] will be the LSB of the result.
{>A B} ; Same as above; explicitly calls out big-endian ordering.
{<A B} ; Concatenate A and B; little-endian. A[0] will be the LSB of the result.
{A B C} ; Any number of expressions can be concatenated at once.
``` | []
|
https://avatars.githubusercontent.com/u/62678643?v=4 | ZigBook | C-BJ/ZigBook | 2022-07-11T08:59:01Z | A book for learning Zig language and toolchain. | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/C-BJ/ZigBook/tags | CC0-1.0 | [
"zig"
]
| 26 | false | 2023-11-24T09:02:53Z | false | false | unknown | github | []
| ZigBook
<strong>README:</strong> <a>English</a> <a>简体中文</a> <a>繁體中文</a><a></a><a></a> | []
|
https://avatars.githubusercontent.com/u/110142614?v=4 | zleep | gajirou/zleep | 2022-10-11T10:01:29Z | zig で sleep 時にプログレスバーを表示するだけのコマンド | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/gajirou/zleep/tags | - | [
"zig"
]
| 4 | false | 2022-10-20T01:23:07Z | false | false | unknown | github | []
| zleep
zig で sleep 時にプログレスバーを表示するだけのコマンド。
利用方法
```
ビルド
zig build-exe -Drelease-small zleep.zig
sleep する秒数を引数で入力
./zleep 5
ファイル指定で実行
zig run zleep.zig -- 5
```
実行イメージ
| []
|
https://avatars.githubusercontent.com/u/351529?v=4 | zig-soroban-sdk | leighmcculloch/zig-soroban-sdk | 2023-01-06T19:33:02Z | A Soroban SDK for smart contracts written in Zig. Unreleased. Unfit for use. Experimental. Use at your own risk. | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/leighmcculloch/zig-soroban-sdk/tags | - | [
"smart-contracts",
"soroban",
"stellar",
"zig",
"ziglang"
]
| 34 | false | 2024-09-03T07:10:30Z | true | true | 0.13.0 | github | []
| zig-soroban-sdk
| <a>Docs</a> | <a>Examples</a> |
| --- | --- |
A <a>Soroban</a> SDK for smart contracts written in <a>Zig</a>. Unreleased. Unfit for use. Experimental. Use at your own risk.
| []
|
https://avatars.githubusercontent.com/u/85593302?v=4 | knarkzel.github.io | svelterust/knarkzel.github.io | 2022-10-18T12:53:31Z | Personal website in org-mode | master | 0 | 1 | 1 | 1 | https://api.github.com/repos/svelterust/knarkzel.github.io/tags | - | [
"emacs",
"rust",
"zig"
]
| 3,278 | false | 2023-01-20T20:10:36Z | false | false | unknown | github | []
| 404 | []
|
https://avatars.githubusercontent.com/u/107519028?v=4 | annotated-zig | better-zig/annotated-zig | 2022-07-27T20:16:08Z | zig 知名项目源码分析 | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/better-zig/annotated-zig/tags | MIT | [
"zig",
"ziglang"
]
| 1 | false | 2022-09-08T15:40:27Z | false | false | unknown | github | []
| annotated-zig
zig 知名项目源码分析 | []
|
https://avatars.githubusercontent.com/u/85593302?v=4 | oddos | svelterust/oddos | 2022-10-07T23:41:35Z | OddOS, made in Zig | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/svelterust/oddos/tags | - | [
"os",
"zig"
]
| 42 | false | 2022-10-07T23:42:20Z | true | false | unknown | github | []
| oddos
<code>shell
git clone https://github.com/knarkzel/oddos
cd oddos
nix develop
zig build run</code>
Debug with gdb
Start <code>qemu</code> first, then do following:
<code>zig build gdb
(gdb) target remote localhost:1234</code> | []
|
https://avatars.githubusercontent.com/u/337093?v=4 | hexdump | tetsu-koba/hexdump | 2023-01-02T11:42:41Z | A hexdump utility written in zig language. | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/tetsu-koba/hexdump/tags | Unlicense | [
"zig"
]
| 12 | false | 2024-09-06T10:05:33Z | true | false | unknown | github | []
| hexdump
A hexdump utility written in zig language.
Usage
<code>shell-session
$ ./hexdump
Usage: ./hexdump input_file
$ ./hexdump ./hexdump |head -5
00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 b7 00 01 00 00 00 7c e9 21 00 00 00 00 00 |........|.!.....|
00000020 40 00 00 00 00 00 00 00 00 83 12 00 00 00 00 00 |@...............|
00000030 00 00 00 00 40 00 38 00 08 00 40 00 13 00 11 00 |[email protected]...@.....|
00000040 06 00 00 00 04 00 00 00 40 00 00 00 00 00 00 00 |........@.......|
$</code> | []
|
https://avatars.githubusercontent.com/u/121067143?v=4 | we4k | ONE-RANDOM-HUMAN/we4k | 2022-12-19T23:43:35Z | A chess engine designed to fit into 4096 bytes. | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/ONE-RANDOM-HUMAN/we4k/tags | GPL-3.0 | [
"ai",
"assembly",
"chess",
"chess-ai",
"chess-engine",
"zig"
]
| 1,671 | false | 2025-04-03T18:21:36Z | true | false | unknown | github | []
| we4k
we4k is no longer in development. New development is focused on <a>STRO4K</a>
we4k is a chess engine designed to fit into 4096 bytes.
Building
we4k requires nasm and the latest Zig compiler. Only Linux and cpus with AVX2 and BMI2 are supported.
<code>cd src/asm
nasm -f elf64 combined.asm
cd ../..
zig build install -Drelease-small -Dcpu=skylake-vzeroupper</code>
The binary could be made to fit into 4096 bytes using <code>sstrip</code>, <code>vondehi</code>, and mrbdzz's decompression script. However, this is no longer possible with newer versions of the Zig compiler.
<code>build4k.sh</code> attempts to build we4k and pack it into 4096 bytes.
<code>./build4k.sh we4k</code>
Questions
Why is it called we4k?
<code>Score of we4k-86762f9 vs 4ku-9eea311: 3 - 95 - 2 [0.040] 100
... we4k-86762f9 playing White: 0 - 50 - 0 [0.000] 50
... we4k-86762f9 playing Black: 3 - 45 - 2 [0.080] 50
... White vs Black: 45 - 53 - 2 [0.460] 100
Elo difference: -552.1 +/- 257.1, LOS: 0.0 %, DrawRatio: 2.0 %
Finished match</code>
Where was there claimed to be only one Zig function?
After compilation, only one Zig function remains after inlining and dead code elimination.
Thanks
we4k was developed with contributions from many others. In particular
* The Stockfish Team - we4k was tuned using a large number Fishtest games.
* sqrmax - for dedicating a large amount of time to reading the assembly and providing suggestions.
* mrbdzz - for creating the decompression script used.
* kanchess - for creating and donating the logo | []
|
https://avatars.githubusercontent.com/u/99076655?v=4 | ziglearn | coderonion/ziglearn | 2022-12-05T10:59:51Z | Repo for https://ziglearn.org content. Get up to speed with Zig quickly. | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/coderonion/ziglearn/tags | MIT | [
"learn",
"learning",
"zig",
"ziglang"
]
| 176 | true | 2023-06-03T13:32:29Z | false | false | unknown | github | []
| ziglearn
Repo for https://ziglearn.org content. Feedback and PRs welcome.
How to run the tests
<ol>
<li><code>zig run test-out.zig</code></li>
<li><code>zig test do_tests.zig</code></li>
</ol> | []
|
https://avatars.githubusercontent.com/u/3249887?v=4 | zig_lazy_updater | mariogt/zig_lazy_updater | 2022-07-16T23:58:00Z | Script to update/install the latest dev build of Zig into your $HOME folder | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/mariogt/zig_lazy_updater/tags | AGPL-3.0 | [
"bash",
"zig",
"zig-lang"
]
| 1,128 | false | 2025-03-18T01:39:28Z | false | false | unknown | github | []
| zig_lazy_updater
Script to update/install Zig's latest Linux dev build into your $HOME folder.
If you don't have a zig installation in your $HOME, then this script will install
the latest Zig dev release (from https://ziglang.org/download/) in a folder called
"zig" in your $HOME directory.
If you have already installed Zig in the $HOME/zig folder (and added it to your
$PATH), then this script will check the versions of the local installation vs the
latest official dev release, and will update the local installation if needed.
Beware that this script will delete the old zig folder present in your $HOME
Feel free to fork and mod this script to fit your needs.
| []
|
https://avatars.githubusercontent.com/u/43040593?v=4 | OpenCSE | dantecatalfamo/OpenCSE | 2022-08-18T06:20:32Z | Free implementation of the Can't Stop Express dice game. | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/dantecatalfamo/OpenCSE/tags | GPL-3.0 | [
"dice",
"game",
"zig"
]
| 25 | false | 2023-05-25T13:50:05Z | true | false | unknown | github | []
| Open Can't Stop Express
Free implementation of the <a>Can't Stop Express</a> dice game.
<code>+----------------------------------------------------------------------+
| A | B | C | D | 5th |
|-----+----+-------------------------+------------+--------------------+
| 100 | 2 | □ □ □ □ | □ | □ □ □ □ □ | | | □ □ □ □ □ □ □ □ |
| 70 | 3 | □ □ □ □ | □ | □ □ □ □ □ | | | □ □ □ □ □ □ □ □ |
| 60 | 4 | □ □ □ □ | □ | □ □ □ □ □ | | | □ □ □ □ □ □ □ □ |
| 50 | 5 | □ □ □ □ | □ | □ □ □ □ □ | | +--------------------+
| 40 | 6 | □ □ □ □ | □ | □ □ □ □ □ | | |
| 30 | 7 | □ □ □ □ | □ | □ □ □ □ □ | | |
| 40 | 8 | □ □ □ □ | □ | □ □ □ □ □ | | |
| 50 | 9 | □ □ □ □ | □ | □ □ □ □ □ | | |
| 60 | 10 | □ □ □ □ | □ | □ □ □ □ □ | | |
| 70 | 11 | □ □ □ □ | □ | □ □ □ □ □ | | +---------+
| 100 | 12 | □ □ □ □ | □ | □ □ □ □ □ | | | Total |
+----------+-------------------------+------------+---------+
| -200 | 0 | + + + + + | + 0 | = +0 |
+------------------------------------------------+</code>
Dice pairs are entered separated by a space. For example <code>3 5</code>. | []
|
https://avatars.githubusercontent.com/u/9960133?v=4 | zig-pinephone-mach | lupyuen/zig-pinephone-mach | 2022-07-24T06:04:29Z | (Experimental) Mach Zig Game Engine on PinePhone | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/lupyuen/zig-pinephone-mach/tags | Apache-2.0 | [
"gamedev",
"graphics-engine",
"mach",
"opengles",
"pinephone",
"webgpu",
"zig"
]
| 76 | false | 2022-07-24T06:45:24Z | false | false | unknown | github | []
| (Experimental) Mach Zig Game Engine on PinePhone
Can we run the Mach Game Engine (in Zig) on PinePhone?
https://machengine.org/
https://github.com/hexops/mach
Let's find out! (With Manjaro Phosh)
<code>text
██████████████████ ████████ manjaro@manjaro-arm
██████████████████ ████████ -------------------
██████████████████ ████████ OS: Manjaro ARM Linux aarch64
██████████████████ ████████ Host: Pine64 PinePhone (1.2)
████████ ████████ Kernel: 5.18.3-1-MANJARO-ARM
████████ ████████ ████████ Uptime: 1 hour, 48 mins
████████ ████████ ████████ Packages: 806 (pacman)
████████ ████████ ████████ Shell: bash 5.1.16
████████ ████████ ████████ Resolution: 720x1440
████████ ████████ ████████ Terminal: node
████████ ████████ ████████ CPU: (4) @ 1.152GHz
████████ ████████ ████████ Memory: 507MiB / 1991MiB
████████ ████████ ████████
████████ ████████ ████████</code>
Build Mach
Follow these steps to download Zig, download Mach and build Mach on PinePhone...
<code>bash
$ curl -O -L https://ziglang.org/builds/zig-linux-aarch64-0.10.0-dev.3080+eb1b2f5c5.tar.xz
$ tar xf zig-linux-aarch64-0.10.0-dev.3080+eb1b2f5c5.tar.xz
$ export PATH="$HOME/zig-linux-aarch64-0.10.0-dev.3080+eb1b2f5c5:$PATH"
$ git clone https://github.com/hexops/mach
$ cd mach
$ zig build example-rotating-cube -Ddawn-from-source=true</code>
<a>(See the complete log)</a>
Be patient, it takes roughly 1.5 hours for the first build. Subsequent builds will complete in seconds.
Missing Arm64 Atomics
Mach fails to build on PinePhone due to Missing Arm64 Atomics...
<code>bash
$ zig build example-rotating-cube -Ddawn-from-source=true
LLD Link...
ld.lld: error: undefined symbol: __aarch64_ldadd8_relax
ld.lld: error: undefined symbol: __aarch64_ldadd8_acq
ld.lld: error: undefined symbol: __aarch64_ldadd8_rel
ld.lld: error: undefined symbol: __aarch64_ldadd8_acq_rel
ld.lld: error: undefined symbol: __aarch64_ldadd4_relax
ld.lld: error: undefined symbol: __aarch64_ldadd4_acq
ld.lld: error: undefined symbol: __aarch64_ldadd4_rel
ld.lld: error: undefined symbol: __aarch64_ldadd4_acq_rel
ld.lld: error: undefined symbol: __aarch64_swp8_acq_rel
ld.lld: error: undefined symbol: __aarch64_cas8_acq_rel</code>
<a>(See the complete log)</a>
This is caused by Zig's incomplete support for LLVM and Atomics...
https://github.com/ziglang/zig/issues/10086
So we copy the Arm64 Atomics from this Rust Implementation...
https://github.com/suptalentdev/mustang/blob/master/c-scape/aarch64_outline_atomics/aarch64_outline_atomics/src/lib.rs
https://docs.rs/atomic/latest/atomic/struct.Atomic.html
Fix Missing Arm64 Atomics
To build Mach correctly on PinePhone, apply this fix for the Missing Arm64 Atomics...
```zig
//// TODO: To fix the Missing Atomics for Mach Zig Game Engine on PinePhone Manjaro Phosh,
//// Insert these lines at the bottom of mach/examples/rotating-cube/main.zig
////
//// Here are the Linker Errors for the Missing Atomics:
//// https://gist.github.com/lupyuen/ff77c494b0589371b44b6c96f8491e31
////
//// Refer to this issue: https://github.com/ziglang/zig/issues/10086
//// Rust Implementation: https://github.com/suptalentdev/mustang/blob/master/c-scape/aarch64_outline_atomics/aarch64_outline_atomics/src/lib.rs
//// Rust Atomic Struct: https://docs.rs/atomic/latest/atomic/struct.Atomic.html
pub export fn __aarch64_ldadd4_relax() c_int { _ = puts("TODO: __aarch64_ldadd4_relax"); return 0; }
pub export fn __aarch64_ldadd4_acq() c_int { _ = puts("TODO: __aarch64_ldadd4_acq"); return 0; }
pub export fn __aarch64_ldadd4_rel() c_int { _ = puts("TODO: __aarch64_ldadd4_rel"); return 0; }
pub export fn __aarch64_ldadd4_acq_rel(x: u32, p: [<em>c]u32) u32 {
// (</em>p).fetch_add(x, AcqRel)
// Add to the current value, returning the previous value.
// AcqRel: For loads it uses Acquire ordering. For stores it uses the Release ordering.
const ret = p.<em>;
_ = printf("__aarch64_ldadd4_acq_rel: x=%d, p=%p, ret=%d\n", x, p, ret);
p.</em> +%= x;
return ret;
}
pub export fn __aarch64_ldadd8_relax(x: u32, p: [<em>c]u32) u32 {
// (</em>p).fetch_add(x, Relaxed)
// Add to the current value, returning the previous value.
// Relaxed: No ordering constraints, only atomic operation
const ret = p.<em>;
_ = printf("__aarch64_ldadd8_relax: x=%d, p=%p, ret=%d\n", x, p, ret);
p.</em> +%= x;
return ret;
}
pub export fn __aarch64_ldadd8_acq() c_int { _ = puts("TODO: __aarch64_ldadd8_acq"); return 0; }
pub export fn __aarch64_ldadd8_rel(x: u64, p: [<em>c]u64) u64 {
// (</em>p).fetch_add(x, AcqRel)
// Add to the current value, returning the previous value.
const ret = p.<em>;
_ = printf("__aarch64_ldadd8_rel: x=%d, p=%p, ret=%d\n", x, p, ret);
p.</em> +%= x;
return ret;
}
pub export fn __aarch64_ldadd8_acq_rel(x: u64, p: [<em>c]u64) u64 {
// (</em>p).fetch_add(x, AcqRel)
// Add to the current value, returning the previous value.
// AcqRel: For loads it uses Acquire ordering. For stores it uses the Release ordering.
const ret = p.<em>;
_ = printf("__aarch64_ldadd8_acq_rel: x=%d, p=%p, ret=%d\n", x, p, ret);
p.</em> +%= x;
return ret;
}
pub export fn __aarch64_swp8_acq_rel() c_int { _ = puts("TODO: __aarch64_swp8_acq_rel"); return 0; }
pub export fn __aarch64_cas8_acq_rel() c_int { _ = puts("TODO: __aarch64_cas8_acq_rel"); return 0; }
extern fn printf(format: [<em>:0]const u8, ...) c_int;
extern fn puts(str: [</em>:0]const u8) c_int;
```
After fixing, Mach builds OK on PinePhone...
<code>bash
$ zig build example-rotating-cube -Ddawn-from-source=true</code>
GLFW Error
When we run Mach on PinePhone, it fails with a GLFW Error...
```bash
$ zig build example-rotating-cube -Ddawn-from-source=true
$ export GPU_BACKEND=opengl
$ zig-out/bin/example-rotating-cube
glfw: error.VersionUnavailable: GLX: Failed to create context: GLXBadFBConfig
$ export GPU_BACKEND=opengles
$ zig-out/bin/example-rotating-cube
glfw: error.VersionUnavailable: EGL: Failed to create context: An EGLConfig argument does not name a valid EGL frame buffer configuration
```
<a>(See complete log)</a>
Which might be caused by the OpenGL Version on PinePhone...
OpenGL Version
PinePhone supports OpenGL version 2.1, which might be too old for Mach...
<code>text
$ glxinfo | grep "OpenGL version"
OpenGL version string: 2.1 Mesa 22.1.3</code>
When we set <code>MESA_GL_VERSION_OVERRIDE</code>, Mach fails with a GLSL Error ...
```bash
$ zig build example-rotating-cube -Ddawn-from-source=true
$ export GPU_BACKEND=opengl
$ export MESA_GL_VERSION_OVERRIDE=4.5
$ glxinfo | grep 'OpenGL version'
OpenGL version string: 4.5 (Compatibility Profile) Mesa 22.1.3
$ zig-out/bin/example-rotating-cube
mach: found OpenGL backend on Unknown adapter: Mali400, OpenGL version 4.5 (Core Profile) Mesa 22.1.3
gpu: validation error: #version 450
Program compilation failed:
0:1(10): error: GLSL 4.50 is not supported. Supported versions are: 1.10, 1.20, and 1.00 ES
- While calling [Device].CreateRenderPipeline([RenderPipelineDescriptor]).
```
<a>(See the complete log)</a>
This says that Mach failed to create the GPU Render Pipeline...
```zig
const vs_module = core.device.createShaderModule(&.{
.label = "my vertex shader",
.code = .{ .wgsl = @embedFile("vert.wgsl") },
});
const pipeline_descriptor = gpu.RenderPipeline.Descriptor{
.fragment = &fragment,
.layout = pipeline_layout,
.depth_stencil = null,
.vertex = .{
.module = vs_module,
.entry_point = "main",
.buffers = &.{vertex_buffer_layout},
```
<a>(Source)</a>
Because PinePhone failed to load the <a>OpenGL Shading Language</a> (GLSL) file <a>vert.wgsl</a>.
This GLSL Error appears when we set <code>MESA_GL_VERSION_OVERRIDE</code> to 4.4 or above.
The GLFW Error appears when we set <code>MESA_GL_VERSION_OVERRIDE</code> to 4.3 or below.
So it seems Mach only works with OpenGL / GLSL version 4.4 and above. Which isn't supported on PinePhone.
Perhaps PinePhone Pro (with Vulkan) will support Mach.
Pinebook Pro
Will Mach run on Pinebook Pro?
<code>text
██████████████████ ████████ luppy@pinebook
██████████████████ ████████ --------------
██████████████████ ████████ OS: Manjaro ARM Linux aarch64
██████████████████ ████████ Host: Pine64 Pinebook Pro
████████ ████████ Kernel: 5.18.5-1-MANJARO-ARM
████████ ████████ ████████ Uptime: 53 mins
████████ ████████ ████████ Packages: 1006 (pacman)
████████ ████████ ████████ Shell: bash 5.1.16
████████ ████████ ████████ Resolution: 1920x1080
████████ ████████ ████████ Terminal: node
████████ ████████ ████████ CPU: (6) @ 1.416GHz
████████ ████████ ████████ Memory: 914MiB / 3868MiB
████████ ████████ ████████
████████ ████████ ████████</code>
We run the same steps to build Mach on Pinebook Pro (Manjaro Xfce)...
https://github.com/lupyuen/zig-pinephone-mach#build-mach
And apply the fix for Missing Arm64 Atomics...
https://github.com/lupyuen/zig-pinephone-mach#missing-arm64-atomics
<a>(See the build log)</a>
(Mach builds on Pinebook Pro in roughly half an hour)
Mach fails with the same GLFW Error on Pinebook Pro even though it supports OpenGL 3.1...
```bash
$ zig build example-rotating-cube -Ddawn-from-source=true
$ export GPU_BACKEND=opengl
$ glxinfo | grep 'OpenGL version'
OpenGL version string: 3.1 Mesa 22.1.3
$ zig-out/bin/example-rotating-cube
glfw: error.VersionUnavailable: GLX: Failed to create context: GLXBadFBConfig
```
<a>(See the complete log)</a>
When we set <code>MESA_GL_VERSION_OVERRIDE</code>, Mach fails with the same GLSL Error...
```bash
$ zig build example-rotating-cube -Ddawn-from-source=true
$ export GPU_BACKEND=opengl
$ export MESA_GL_VERSION_OVERRIDE=4.5
$ glxinfo | grep 'OpenGL version'
OpenGL version string: 4.5 (Compatibility Profile) Mesa 22.1.3
$ zig-out/bin/example-rotating-cube
mach: found OpenGL backend on Unknown adapter: Mali-T860 (Panfrost), OpenGL version 4.5 (Core Profile) Mesa 22.1.3
gpu: validation error: #version 450
Program compilation failed:
0:1(10): error: GLSL 4.50 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.00 ES, and 3.00 ES
- While calling [Device].CreateRenderPipeline([RenderPipelineDescriptor]).
```
<a>(See the complete log)</a>
So it seems Mach won't run on Pinebook Pro because it doesn't support OpenGL / GLSL version 4.4 or later. | []
|
https://avatars.githubusercontent.com/u/52897699?v=4 | sha3 | cod1r/sha3 | 2022-08-10T08:11:20Z | Secure Hashing Algorithm 3 implementation | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/cod1r/sha3/tags | - | [
"crypto",
"implementation",
"sha3",
"zig"
]
| 25 | false | 2023-03-08T01:30:29Z | false | false | unknown | github | []
| Implementation of the SHA-3 hashing algorithm
Resources used
<ul>
<li><a>SHA-3 Spec</a></li>
<li><a>Keccak Spec</a></li>
<li><a>Keccak Website</a></li>
<li><a>Python Implementation</a></li>
</ul> | []
|
https://avatars.githubusercontent.com/u/107234593?v=4 | rogue | zig-wii/rogue | 2022-06-10T12:22:44Z | 2D platformer/rpg game made with ogc | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/zig-wii/rogue/tags | - | [
"devkitpro",
"wii",
"zig"
]
| 672 | false | 2022-06-11T12:39:17Z | true | false | unknown | github | []
| rogue
2D platformer/rpg game made with <a>ogc</a>.
<code>git clone https://github.com/zig-wii/rogue
cd rogue/
zig build run</code> | []
|
https://avatars.githubusercontent.com/u/45139213?v=4 | compare-compiled-languages-size | brainwo/compare-compiled-languages-size | 2022-10-27T19:08:57Z | Compare size of compiled languages | main | 1 | 1 | 0 | 1 | https://api.github.com/repos/brainwo/compare-compiled-languages-size/tags | Unlicense | [
"ada",
"c",
"crystal",
"d",
"dart",
"go",
"haskell",
"jakt",
"koka",
"kotlin",
"nasm",
"nelua",
"nim",
"ocaml",
"odin",
"rust",
"swift",
"v",
"vala",
"zig"
]
| 1,283 | false | 2024-07-21T11:36:46Z | false | false | unknown | github | []
|
Compare size of compiled languages.
Chart
Linear scale:
Logarithmic scale:
Table
| language | compiler | version | linking | size (in bytes) |
| -------- | -------- | ------- | ------- | --------------- |
|c|zigcc|clang version 15.0.3 ([email protected]:ziglang/zig-bootstrap.git 0ce789d0f7a4d89fdc4d9571209b6874d3e260c9)|dynamically linked|3,688|
|zig|zig|0.10.0-dev.4707+209a0d2a8|statically linked|5,344|
|swift|swiftc|Swift version 5.6 (swift-5.6-RELEASE)|dynamically linked|7,784|
|asm|nasm|NASM version 2.15.05 compiled on Sep 24 2020|statically linked|8,488|
|c|gcc|gcc (GCC) 12.2.0|dynamically linked|14,384|
|vala|valac|Vala 0.56.3|dynamically linked|14,384|
|nelua|nelua|Nelua 0.2.0-dev|dynamically linked|14,400|
|fortran|gfortran|GNU Fortran (GCC) 12.2.0|dynamically linked|14,424|
|c|clang|clang version 14.0.6|dynamically linked|14,472|
|nim|nim|Nim Compiler Version 1.6.8 [Linux: amd64]|dynamically linked|14,552|
|d|ldc|LDC - the LLVM D compiler (1.30.0):|dynamically linked|18,864|
|go|tinygo|tinygo version 0.26.0 linux/amd64 (using go version go1.19.2 and LLVM version 14.0.0)|statically linked|20,120|
|basic|fbc|FreeBASIC Compiler - Version 1.09.0 (2022-02-16), built for linux-x86_64 (64bit)|dynamically linked|34,864|
|jakt|jakt1|None|dynamically linked|75,920|
|jakt|jakt2|None|dynamically linked|75,920|
|pony|ponyc|0.43.1- [release]|dynamically linked|123,008|
|hare|hare|Hare dev+b00d4a6f-arch|statically linked|127,888|
|odin|odin|odin version dev-2022-10:2cd895c5|dynamically linked|170,440|
|v|v|V 0.3.1 f2f6ea5|dynamically linked|179,504|
|pascal|fpc|Free Pascal Compiler version 3.2.2 [2022/08/31] for x86_64|statically linked|191,056|
|kotlin|kotlinc|Kotlin/Native: 1.7.10|dynamically linked|208,376|
|crystal|crystal|Crystal 1.6.1 (2022-10-24)|dynamically linked|216,016|
|rust|rustc|rustc 1.66.0-nightly (db0597f56 2022-10-11)|dynamically linked|272,688|
|ada|gnatmake|GNATMAKE 12.2.0|dynamically linked|292,408|
|ocaml|ocamlopt|4.14.0|dynamically linked|318,608|
|koka|koka|Koka 2.3.8, 10:27:37 Dec 27 2021 (ghc release version)|dynamically linked|427,552|
|d|dmd|DMD64 D Compiler v2.100.2|dynamically linked|712,504|
|d|gdc|gdc (GCC) 12.2.0|dynamically linked|826,520|
|go|go|go version go1.19.2 linux/amd64|statically linked|1,213,272|
|dart|dart|Dart SDK version: 2.18.3 (stable) (Mon Oct 17 13:23:20 2022 +0000) on "linux_x64"|dynamically linked|5,010,152|
|haskell|ghc|The Glorious Glasgow Haskell Compilation System, version 9.0.2|dynamically linked|5,942,344| | []
|
https://avatars.githubusercontent.com/u/13280758?v=4 | zig-experiments | magiruuvelvet/zig-experiments | 2023-01-08T17:42:19Z | experimenting with zig | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/magiruuvelvet/zig-experiments/tags | - | [
"zig",
"ziglang"
]
| 9 | false | 2023-01-08T17:42:52Z | true | false | unknown | github | []
| experimenting with <a>zig</a>
https://ziglang.org/documentation/master/
Notes:
- works with lldb debugger out of the box (readable symbol names, breakpoints, jumping...)
- allows trailing commas :)
Compile:
- <code>zig build</code> | []
|
https://avatars.githubusercontent.com/u/508672?v=4 | zig-scratchpad | bburrier/zig-scratchpad | 2022-12-30T23:53:23Z | Exploring basic Zig concepts. | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/bburrier/zig-scratchpad/tags | - | [
"zig"
]
| 7 | false | 2023-01-03T22:04:42Z | false | false | unknown | github | []
| Zig Scratchpad
<a>Zig</a> is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software.
Exploring basic Zig concepts here.
Fibonacci
Development
<ul>
<li>Install zig (<a>options</a>) <code>brew install zig</code></li>
<li>Build and run <code>zig run src/fib.zig -- 10</code></li>
</ul>
Production
<ul>
<li>Build executable <code>zig build-exe src/fib.zig</code></li>
<li>Run executable <code>./fib 10</code></li>
</ul> | []
|
https://avatars.githubusercontent.com/u/8497012?v=4 | awesome-zig | apple-x-co/awesome-zig | 2022-12-16T08:07:42Z | null | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/apple-x-co/awesome-zig/tags | - | [
"zig"
]
| 1 | false | 2022-12-16T08:26:13Z | false | false | unknown | github | []
| awesome-zig
TLS
<ul>
<li><a>shiguredo/tls13-zig</a> - The first TLS1.3 implementation in Zig(master/HEAD) only with std. </li>
</ul>
PDF
<ul>
<li><a>libharu/libharu</a> - libharu - free PDF library</li>
</ul> | []
|
https://avatars.githubusercontent.com/u/121678877?v=4 | zig-girepository | paveloom-z/zig-girepository | 2023-01-20T09:56:00Z | Zig bindings for the `girepository` library | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/paveloom-z/zig-girepository/tags | MIT | [
"girepository",
"zig"
]
| 23 | false | 2023-01-20T10:14:29Z | true | false | unknown | github | []
| Notices
Mirrors
Repository:
- <a>Codeberg</a>
- <a>GitHub</a>
- <a>GitLab</a>
Prerequisites
Make sure you have installed:
<ul>
<li>A development library for <code>gobject-introspection</code></li>
<li><a>Zig</a> (<code>v0.10.1</code>)</li>
</ul>
Build
To build and install the library, run <code>zig build install</code>.
To run unit tests, run <code>zig build test</code>.
See <code>zig build --help</code> for more build options.
Integrate
To integrate the bindings into your project:
1) Add this repository as a dependency in <code>zigmod.yml</code>:
<code>```yml
# <...>
root_dependencies:
- src: git https://github.com/paveloom-z/zig-girepository
```
</code>
2) Make sure you have added the dependencies in your build script:
<code>```zig
// <...>
const deps = @import("deps.zig");
const girepository_pkg = deps.pkgs.girepository.pkg.?;
// <...>
pub fn build(b: *std.build.Builder) !void {
// <...>
// For each step
inline for (steps) |step| {
// Add the library package
step.addPackage(girepository_pkg);
// Link the libraries
step.linkLibC();
step.linkSystemLibrary("gobject-introspection-1.0");
// Use the `stage1` compiler
step.use_stage1 = true;
}
// <...>
}
```
</code> | []
|
https://avatars.githubusercontent.com/u/15616419?v=4 | sphagetti_adventure | Gertkeno/sphagetti_adventure | 2022-12-26T21:33:29Z | christmas present for helena | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/Gertkeno/sphagetti_adventure/tags | - | [
"wasm4",
"zig"
]
| 94 | false | 2023-11-01T17:25:56Z | true | false | unknown | github | []
| Sphagetti Adventure
A game for Helena, Christmas 2022.
Written in <a>Zig 0.11.0</a> for the
<a>WASM-4</a> fantasy console.
Building
Build the cart by running:
<code>shell
zig build -Drelease-small=true</code>
Then run it with:
<code>shell
w4 run zig-out/lib/cart.wasm</code> | []
|
https://avatars.githubusercontent.com/u/5955225?v=4 | advent-of-code-2022 | JamesErrington/advent-of-code-2022 | 2022-12-09T21:33:34Z | Advent of Code 2022 - Go + Zig | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/JamesErrington/advent-of-code-2022/tags | - | [
"advent-of-code-2022",
"golang",
"zig"
]
| 42 | false | 2023-11-01T17:11:20Z | false | false | unknown | github | []
| <a>Advent of Code 2022</a>
Orginally in Go, now in Zig and OCaml too. | []
|
https://avatars.githubusercontent.com/u/4605603?v=4 | advent-of-code-2022 | tiehuis/advent-of-code-2022 | 2022-12-03T02:08:53Z | https://adventofcode.com/2022 | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/tiehuis/advent-of-code-2022/tags | - | [
"advent-of-code",
"zig"
]
| 24 | false | 2022-12-03T02:17:56Z | false | false | unknown | github | []
| Solutions for https://adventofcode.com/2022.
<code>$ zig version
0.11.0-dev.449+665eba93c</code>
Run individual solutions with
<code>zig run 1.zig</code>
Test cases can be verified using
<code>zig test 1.zig</code> | []
|
https://avatars.githubusercontent.com/u/2906836?v=4 | zig-stm32f7-blink | artronics/zig-stm32f7-blink | 2022-12-18T22:31:59Z | A blink project using nucleo-f767zi board with build and debug configuration | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/artronics/zig-stm32f7-blink/tags | MIT | [
"blinking-leds",
"embedded",
"nucleo-f767zi",
"zig"
]
| 5,587 | false | 2022-12-20T20:41:23Z | true | false | unknown | github | []
| Project
A blinking LED project using the Zig programming language. With the use of OpenOCD, you can program the chip and debug your project using the provided Visual Studio Code configurations. These configurations include both launch and task configurations, allowing you to run and test your code.
Building the project
To build and program the board run:
<code>zig build flash</code>
Setup
This project is using NUCLEO-F767ZI board but, if you have a different board, you can still use these instructions to create your own project. Simply follow the steps outlined below to build and program your board:
Dependencies:
<ul>
<li>Zig programming language</li>
<li><code>arm-none-eabi</code> toolchain. We use Zig to cross-compile our code, but the toolchain comes with other useful tools including <code>gdb</code>.</li>
<li>OpenOCD to program the chip and running debugger server</li>
<li>STM32CubeMX to generate the startup and linker files</li>
</ul>
Steps
<ul>
<li>Use STM32CubeMX program to generator a project.</li>
<li>Copy the <code>startup_<chip>.s</code> and <code><ship>.ld</code> files.</li>
<li>Download the chip's <code>SVD</code> file from ST website. <ul>
<li>Use (regz)[https://github.com/ZigEmbeddedGroup/regz] project from zig-embedded team to generate a registers file.</li>
<li>This step is optional. The debugger settings in the <code>launch.json</code> references this file. This will allow you to search for registers by name and check their values during debugging.</li>
</ul>
</li>
</ul>
Credits:
I used source code from:
- https://github.com/rbino/zig-stm32-blink | []
|
https://avatars.githubusercontent.com/u/107519028?v=4 | annotated-tigerbeetle | better-zig/annotated-tigerbeetle | 2022-08-01T12:21:02Z | tigerbeetle 源码分析 | annotated-v2022-08-01 | 0 | 0 | 0 | 0 | https://api.github.com/repos/better-zig/annotated-tigerbeetle/tags | Apache-2.0 | [
"zig",
"ziglang"
]
| 19,867 | true | 2022-08-01T14:08:22Z | true | false | unknown | github | []
| tigerbeetle 源码分析:
源码分析笔记:
<ul>
<li><a>.annotated/</a></li>
</ul>
<blockquote>
分支:
</blockquote>
<ul>
<li><code>annotated-v2022-08-01</code>, 当前<code>打 tag</code> 的版本, 很老, 代码已经过时. 故在 <code>main 分支</code>分析.</li>
</ul>
tigerbeetle
<em>TigerBeetle is a financial accounting database designed for mission critical safety and performance to power the future of financial services.</em>
<strong>Take part in TigerBeetle's \$20k consensus challenge: <a>Viewstamped Replication Made Famous</a></strong>
Watch an introduction to TigerBeetle on <a>Zig SHOWTIME</a> for our design decisions regarding performance, safety, and financial accounting primitives:
<a></a>
The Problem - Realtime Processing of Balance Updates
Processing events that impact the balance of an account must be done serially, in the correct order and reliably. For this reason, despite the trend to scale modern applications by distributing work across parallel threads/processes/machines, it remains difficult to scale a ledger or accounting system without sacrificing performance or safety.
For example, processing a balance update event involves:
<ol>
<li>validating the event,</li>
<li>processing any business rules that must consider the current balance before processing the event and the new balance after the event,</li>
<li>updating the balance</li>
<li>persisting the updated balance, and</li>
<li>notifying subscribers of the updated balance and that the event has been processed.</li>
</ol>
While investigating a few existing systems it became clear that the majority of architectures cobble together generic databases (relational or NoSQL, on-disk or in-memory) with business logic enforced in the application code. This separation between data and code, persistence and logic, invites the worst of distributed system problems: network delays, multiple roundtrips for a single balance update, clock skew, or cache incoherency etc.
Furthermore, these systems may achieve performance but at the expense of reliability, especially in the face of hardware failure, corruption and misdirected writes, a compromise that is unacceptable for a system-of-record for financial accounts.
The Solution - A Purpose-Built Financial Accounting Database
Our survey led us to conclude that, while there are mechanisms available to shard account balances to parallelize updates and improve performance, there are still significant performance gains to be had in designing a database that is purpose built for storing balances and processing updates in a reliable manner.
ProtoBeetle - 400,000 Transfers per Second
In the month of July 2020, we developed a prototype of TigerBeetle in Node as a performance sketch to measure the basic components of the design (batching, TCP protocol, cryptographic checksums everywhere, fsync journalling, in-memory business logic and hash table operations). <strong>ProtoBeetle ran at 200,000 two-phase transfers per second on our office laptops</strong>, supporting our back-of-the-envelope numbers.
We then integrated ProtoBeetle into <a>Mojaloop</a> and our reference minimum deployment cluster of <strong>Mojaloop went from 76 TPS on MySQL to 1757 TPS on ProtoBeetle</strong>. A single stateless Mojaloop pod was unable to saturate ProtoBeetle. Most of the throughput was spent converting Mojaloop's individual HTTP requests into TCP batches.
<strong><a>Watch a 10-minute talk introducing ProtoBeetle.</a></strong>
AlphaBeetle - 800,000 Transfers per Second
After ProtoBeetle, from September through October 2020, we knuckled down and rewrote TigerBeetle in C/Zig to create the alpha version of TigerBeetle, using <a>io_uring</a> as a foundation for fast I/O.
TigerBeetle's Zig implementation of io_uring was <a>submitted</a> for addition to the Zig standard library.
<strong><a>Watch a presentation of TigerBeetle given to the Interledger community on 25 November 2020.</a></strong>
BetaBeetle - High Availability
BetaBeetle, the beta distributed version of TigerBeetle, was developed from January 2021 through August 2021, for strict serializability, fault tolerance and automated leader election with the pioneering <a>Viewstamped Replication</a> and consensus protocol, plus the CTRL protocol from <a>Protocol-Aware Recovery for Consensus-Based Storage</a>.
TigerBeetle (under active development)
The production version of <strong>TigerBeetle is now under active development</strong>. Our <a>DESIGN doc</a> provides an overview of TigerBeetle's data structures and our <a>project board</a> provides a glimpse of where we want to go.
QuickStart
<strong>Prerequisites:</strong> The current beta version of TigerBeetle targets macOS and Linux and takes advantage of the latest asynchronous IO capabilities of the Linux kernel v5.6 and newer, via <a>io_uring</a>. As such it can only be used on macOS or on recent versions of Linux with an updated kernel.
<code>bash
git clone https://github.com/coilhq/tigerbeetle.git
cd tigerbeetle
scripts/install.sh</code>
Benchmark
With TigerBeetle installed, you are ready to benchmark!
<code>bash
scripts/benchmark.sh</code>
<em>If you encounter any benchmark errors, please send us the resulting <code>benchmark.log</code>.</em>
Tests
Unit Tests
To run the unit tests:
<code>bash
zig/zig build test</code>
The <a>QuickStart</a> step above will install Zig for you to the root of the <code>tigerbeetle</code> directory.
Simulation Tests
To run TigerBeetle's long-running simulation, called <em>The VOPR</em>:
<code>bash
scripts/vopr.sh</code>
<em>The VOPR</em> stands for <em>The Viewstamped Operation Replicator</em> and was inspired by the movie WarGames, by our love of fuzzing over the years, by <a>Dropbox's Nucleus testing</a>, and by <a>FoundationDB's deterministic simulation testing</a>.
<em>The VOPR</em> is <a>a deterministic simulator</a> that can fuzz many clusters of TigerBeetle servers and clients interacting through TigerBeetle's Viewstamped Replication consensus protocol, but all within a single developer machine process, with <a>a network simulator</a> to simulate all kinds of network faults, and with an in-memory <a>storage simulator</a> to simulate all kinds of storage faults, to explore and test TigerBeetle against huge state spaces in a short amount of time, by literally speeding up the passing of time within the simulation itself.
Beyond being a deterministic simulator, <em>The VOPR</em> also features <a>a state checker</a> that can hook into all the replicas, and check all their state transitions the instant they take place, using cryptographic hash chaining to prove causality and check that all interim state transitions are valid, based on any of the set of inflight client requests at the time, without divergent states, and then check for convergence to the highest state at the end of the simulation, to distinguish between correctness or liveness bugs.
Check out TigerBeetle's <a>Viewstamped Replication Made Famous</a> bug bounty challenge repository for more details on how to run <em>The VOPR</em> and interpret its output.
Launch a Local Cluster
Launch a TigerBeetle cluster on your local machine by running each of these commands in a new terminal tab:
```
./tigerbeetle init --cluster=0 --replica=0 --directory=.
./tigerbeetle init --cluster=0 --replica=1 --directory=.
./tigerbeetle init --cluster=0 --replica=2 --directory=.
./tigerbeetle start --cluster=0 --replica=0 --directory=. --addresses=3001,3002,3003
./tigerbeetle start --cluster=0 --replica=1 --directory=. --addresses=3001,3002,3003
./tigerbeetle start --cluster=0 --replica=2 --directory=. --addresses=3001,3002,3003
```
Run the TigerBeetle binary to see all command line arguments:
<code>bash
./tigerbeetle --help</code>
Clients
<ul>
<li>
<a>tigerbeetle-node</a> is a TigerBeetle Node.js client written in TypeScript (and Zig with <a>Node's N-API</a> for ABI stability).
</li>
<li>
<a>client.zig</a> is a TigerBeetle Zig client.
</li>
<li>
<a>demo.zig</a> is a lightweight TigerBeetle client for demonstration purposes only, which we used to create <a>six demos you can work your way through and modify</a> to explore TigerBeetle's commands.
</li>
</ul>
Community
<a>Join the TigerBeetle community in Discord.</a>
Performance Demos
Along the way, we also put together a series of performance demos and sketches to get you comfortable building TigerBeetle, show how low-level code can sometimes be easier than high-level code, help you understand some of the key components within TigerBeetle, and enable back-of-the-envelope calculations to motivate design decisions.
You may be interested in:
<ul>
<li><a>demos/protobeetle</a>, how batching changes everything.</li>
<li><a>demos/bitcast</a>, how Zig makes zero-overhead network deserialization easy, fast and safe.</li>
<li><a>demos/io_uring</a>, how ring buffers can eliminate kernel syscalls, reduce server hardware requirements by a factor of two, and change the way we think about event loops.</li>
<li><a>demos/hash_table</a>, how linear probing compares with cuckoo probing, and what we look for in a hash table that needs to scale to millions (and billions) of account transfers.</li>
</ul>
License
Copyright 2020-2022 Coil Technologies, Inc
Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | []
|
https://avatars.githubusercontent.com/u/89497197?v=4 | fennec_precompile | cocoa-xu/fennec_precompile | 2022-06-28T00:41:31Z | Drop-in library for `:elixir_make` for precompiling NIF binaries with Zig as the cross-compiler. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/cocoa-xu/fennec_precompile/tags | Apache-2.0 | [
"elixir",
"elixir-library",
"zig"
]
| 103 | false | 2022-12-02T13:52:28Z | false | false | unknown | github | []
| FennecPrecompile
(This repo is archived, please use <a><code>cc_precompiler</code></a>)
Drop-in library for <code>:elixir_make</code> for precompiling NIF binaries with Zig as the cross-compiler.
This work is inspired by ~~(massively copy-and-paste from)~~ <a><code>rustler_precompiled</code></a>. However, this library is more focused on crosscompiling C/C++ projects using Zig as a cross-compiler whereas <code>rustler_precompiled</code> is focused on crosscompiling Rust projects to NIF using Rust with <a><code>rustler</code></a>.
Installation
If <a>available in Hex</a>, the package can be installed
by adding <code>fennec_precompile</code> to your list of dependencies in <code>mix.exs</code>:
<code>elixir
def deps do
[
{:fennec_precompile, "~> 0.3.0"}
]
end</code>
Documentation can be generated with <a>ExDoc</a>
and published on <a>HexDocs</a>. Once published, the docs can
be found at <a>https://hexdocs.pm/fennec_precompile</a>.
Usage
Setup <code>elixir_make</code>
Add <code>:elixir_make</code> to the <code>compilers</code> list and set <code>make_precompiler</code> to <code>FennecPrecompile</code> to use <code>fennec_precompile</code>.
Setup fennec_precompile specific config values
<code>fennec_base_url</code> should be set to the base URL of the precompiled binaries.
<code>fennec_nif_filename</code> will be used to indicate the file name of the compiled shared library.
<code>elixir
@version "0.1.0"
def project do
[
# ...
version: @version,
compilers: [:elixir_make] ++ Mix.compilers(),
make_precompiler: FennecPrecompile,
fennec_nif_filename: "stb_image_nif",
fennec_base_url: "https://github.com/me/myproject/downloads/releases/v#{@version}"
# ...
]
end</code>
A table of supported environment variables, their scopes and examples can be found in the <a><code>Enviroment Variable</code></a> section.
Precompile NIFs
Precompiling happens when run <code>mix elixir_make.precompile</code>.
```elixir
optional settings to override the default cache directory
export ELIXIR_MAKE_CACHE_DIR="$(pwd)/cache"
precompile
mix elixir_make.precompile
it's also possible to run <code>mix elixir_make.precompile</code> with other flags
other flags will be passed to <code>:elixir_make</code>
mix elixir_make.precompile --my-flag
```
What happens when you run <code>mix elixir_make.precompile</code>?
<ul>
<li><code>CC</code> will be set to <code>zig cc -target "ARCH-OS-ABI"</code></li>
<li><code>CXX</code> will be set to <code>zig c++ -target "ARCH-OS-ABI"</code></li>
<li><code>CPP</code> will be set to <code>zig c++ -target "ARCH-OS-ABI"</code></li>
</ul>
Everything else is the same as when you run <code>mix compile</code> (with <code>:elixir_make</code>, or <code>mix compile.elixir_make</code>).
The following targets will be compiled by default:
<ul>
<li>macOS</li>
<li>x86_64-macos</li>
<li>aarch64-macos</li>
<li>Linux</li>
<li>x86_64-linux-gnu</li>
<li>x86_64-linux-musl</li>
<li>aarch64-linux-gnu</li>
<li>aarch64-linux-musl</li>
<li>riscv64-linux-musl</li>
<li>Windows</li>
<li>x86_64-windows-gnu</li>
</ul>
A full list of supported targets can be found using <code>zig targets</code>.
It's worth noting that some targets may not successfully compile on certain platforms. For example, <code>x86_64-macos</code> will not compile on Linux and <code>x86_64-windows-msvc</code> will not compile on macOS.
Specifying targets to compile
To compile for a specific target/a list of targets, set the <code>FENNEC_PRECOMPILE_TARGETS</code> environment variable.
```elixir
for example, to compile for aarch64-linux-musl,riscv64-linux-musl
export ELIXIR_MAKE_CACHE_DIR="$(pwd)/cache"
export FENNEC_PRECOMPILE_TARGETS="aarch64-linux-musl,riscv64-linux-musl"
mix elixir_make.precompile
```
Fetch Precompiled Binaries
To fetch precompiled binaries, run <code>mix elixir_make.fetch</code>.
```elixir
fetch all precompiled binaries
mix elixir_make.fetch --all
fetch specific binaries
mix elixir_make.fetch --only-local
print checksums
mix elixir_make.fetch --all --print
mix elixir_make.fetch --only-local --print
```
Use zig for native build
This section only relates to the behaviour of the <code>mix compile</code> and <code>mix compile [--args] ...</code> commands.
For native build, <code>zig</code> is not used by default for two reasons.
<ol>
<li>For users who are only interested in using the app their native host, it is not necessary to compile the app using Zig.</li>
<li>As this tool aim to be a drop-in replacement for <code>:elixir_make</code>, the default behaviour of <code>mix compile</code> and <code>mix compile [--args] ...</code> of this tool is the same as what would be expected with <code>:elixir_make</code>.</li>
</ol>
However, you can choose to always use <code>zig</code> as the compiler by setting environment variable <code>FENNEC_PRECOMPILE_ALWAYS_USE_ZIG</code> to <code>true</code>.
To be more specific, by default, the environment variables <code>CC</code>, <code>CXX</code> and <code>CPP</code> will not be changed by this tool when running <code>mix compile</code> or <code>mix compile [--args] ...</code>. When <code>FENNEC_PRECOMPILE_ALWAYS_USE_ZIG</code> is <code>true</code>, the compiled NIF binaries (for the native host, identified as <code>ARCH-OS-ABI</code>) should be the same as the one generated by <code>mix elixir_make.precompile</code>.
For example, when running <code>mix compile</code> or <code>mix compile [--args]</code> on arm64 macOS with this option set to <code>true</code>, files in the <code>_build/${MIX_ENV}/lib/my_app/priv</code> directory should match the ones in the <code>my_app-nif-NIF_VERSION-aarch64-macos-VERSION.tar.gz</code> generated by <code>mix elixir_make.precompile</code>.
To install Zig from a package manager, please refer to the officail guide from zig, <a>Install Zig from a Package Manager</a>.
Where is the precompiled binaries?
The path of the cache directory is determined in the following order:
<ol>
<li><code>$ELIXIR_MAKE_CACHE_DIR</code></li>
<li><code>:filename.basedir(:user_cache, "", ...)</code></li>
</ol>
If the environment variable <code>ELIXIR_MAKE_CACHE_DIR</code> is set, the cache directory will be <code>$ELIXIR_MAKE_CACHE_DIR</code>. Otherwise, the cache directory will be determined by the following function:
```elixir
cache_opts = if System.get_env("MIX_XDG"), do: %{os: :linux}, else: %{}
cache_dir = :filename.basedir(:user_cache, "", cache_opts)
cache_dir =
System.get_env("ELIXIR_MAKE_CACHE_DIR", cache_dir)
|> Path.join(sub_dir)
```
Environment Variable
<ul>
<li><code>FENNEC_PRECOMPILE_TARGETS</code></li>
</ul>
Only used when running <code>mix elixir_make.precompile</code>. This environment variable is mostly used in CI or temporarily specify the target(s) to compile.
It is a comma separated list of targets to compile. For example,
<code>shell
export FENNEC_PRECOMPILE_TARGETS="aarch64-linux-musl,riscv64-linux-musl"
mix elixir_make.precompile</code>
If <code>FENNEC_PRECOMPILE_TARGETS</code> is not set, the <code>fennec_precompile</code> will then check <code>config/config.exs</code> to see if there is a <code>:fennec_targets</code> key for <code>my_app</code>. If there is, the value of the key will be the targets.
```elixir
import Config
config :fennec_precompile, :config, my_app: [
fennec_targets: ["aarch64-linux-musl", "riscv64-linux-musl"]
]
```
<code>:fennec_targets</code> in the <code>project</code> will only be used in the following cases:
<code>elixir
def project do
[
# ...
fennec_targets: ["aarch64-linux-musl", "riscv64-linux-musl"]
]
end</code>
<code>1. When `:fennec_force_build` is set to `true`. In this case, the `:fennec_targets` acts as a list of compatible targets in terms of the source code. For example, NIFs that are specifically written for ARM64 Linux will fail to compile for other OS or CPU architeture. If the source code is not compatible with the current node, the build will fail.
2. When `:fennec_force_build` is set to `false`. In this case, the `:fennec_targets` acts as a list of available targets of the precompiled binaries. If there is no match with the current node, no precompiled NIF will be downloaded and the app will fail to start.
</code>
<ul>
<li><code>FENNEC_PRECOMPILE_ALWAYS_USE_ZIG</code></li>
</ul>
Only used when running <code>mix compile</code> or <code>mix compile [--args] ...</code>.
It is a boolean value. When set to <code>true</code>, <code>zig</code> will be used as the compiler instead of the default <code>$CC</code>, <code>$CXX</code> or <code>$CPP</code>. For more information, please refer to the section above, <a>Use zig for native build</a>.
<code>``shell
# this is the default, equivalent to run</code>mix compile<code>with</code>:elixir_make`
unset FENNEC_PRECOMPILE_ALWAYS_USE_ZIG
mix compile
# this will force using zig as the compiler
export FENNEC_PRECOMPILE_ALWAYS_USE_ZIG=true
mix compile
```
License
Copyright 2022 Cocoa Xu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
<code>http://www.apache.org/licenses/LICENSE-2.0
</code>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. | []
|
https://avatars.githubusercontent.com/u/1831620?v=4 | razdal | m1kc/razdal | 2023-01-05T20:57:28Z | TFTP server with very small memory footprint | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/m1kc/razdal/tags | MIT | [
"embedded",
"minimal",
"tftp",
"tftp-server",
"tftpd",
"zig"
]
| 30 | false | 2023-01-05T21:17:19Z | true | false | unknown | github | []
| razdal
TFTP server with very small memory footprint. Stripped binary is about ~130 Kb, it doesn't need libc, and in theory requires just ~10 Kb of memory to work.
:wrench: Stability: alpha
Restrictions:
* read-only (doesn't accept write requests)
* retransmission not supported
* RRQ blocks until complete
Written in Zig. | []
|
https://avatars.githubusercontent.com/u/1575834?v=4 | aoc-2019 | michaeladler/aoc-2019 | 2022-03-24T16:35:23Z | My solutions for the Advent of Code 2019 | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/michaeladler/aoc-2019/tags | Apache-2.0 | [
"advent-of-code",
"advent-of-code-2019",
"aoc",
"aoc2019",
"rust",
"zig"
]
| 197 | false | 2023-11-01T17:10:54Z | true | false | unknown | github | []
| <a></a>
<a></a>
aoc-2019
My first <a>Advent of Code</a>.
Started in <a>Rust</a>, finished in <a>Zig</a>. | []
|
https://avatars.githubusercontent.com/u/107519028?v=4 | better-zig.github.io | better-zig/better-zig.github.io | 2022-07-21T11:45:14Z | null | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/better-zig/better-zig.github.io/tags | - | [
"zig"
]
| 2,274 | false | 2022-07-21T12:19:14Z | false | false | unknown | github | []
| Zig 教程:
This website is built using <a>Docusaurus 2</a>, a modern static website generator.
Zig 学习:
<ul>
<li>https://better-zig.github.io/</li>
<li>⭐⭐⭐⭐⭐</li>
</ul>
reference:
<blockquote>
docs:
</blockquote>
<ul>
<li>https://docusaurus.io/zh-CN/docs/installation</li>
</ul>
<blockquote>
example:
</blockquote>
<ul>
<li>https://casbin.org/docs/zh-CN/overview</li>
<li>https://github.com/casbin/casbin-website-v2</li>
</ul>
Installation
<code>$ yarn</code>
Local Development
<code>$ yarn start</code>
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
Build
<code>$ yarn build</code>
This command generates static content into the <code>build</code> directory and can be served using any static contents hosting service.
Deployment
Using SSH:
<code>$ USE_SSH=true yarn deploy</code>
Not using SSH:
<code>$ GIT_USER=<Your GitHub username> yarn deploy</code>
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the <code>gh-pages</code> branch. | []
|
https://avatars.githubusercontent.com/u/31109115?v=4 | hello-vulkan | straightcurve/hello-vulkan | 2022-03-05T05:46:56Z | null | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/straightcurve/hello-vulkan/tags | - | [
"cpp17",
"vulkan",
"zig"
]
| 19 | false | 2022-03-05T05:51:54Z | true | false | unknown | github | []
| <a>Vulkan Tutorial</a>
<ul>
<li>written in C++</li>
<li>uses Zig as build system</li>
</ul> | []
|
https://avatars.githubusercontent.com/u/13041216?v=4 | zygalim | ydah/zygalim | 2022-11-22T13:16:32Z | A YAML file parser by Zig-lang. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/ydah/zygalim/tags | MIT | [
"parser",
"yaml",
"yaml-parser",
"zig",
"ziglang"
]
| 5 | false | 2022-11-22T14:04:57Z | true | false | unknown | github | []
| zygalim
A YAML file parser by Zig-lang. | []
|
https://avatars.githubusercontent.com/u/49621563?v=4 | mcedit-zig-syntax | dee0xeed/mcedit-zig-syntax | 2022-09-12T19:11:14Z | Zig language syntax highlighting for mcedit | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/dee0xeed/mcedit-zig-syntax/tags | NOASSERTION | [
"mcedit",
"syntax-highlighting",
"zig"
]
| 13 | false | 2022-12-24T13:16:02Z | false | false | unknown | github | []
| Zig language syntax highlighting for mcedit
How to use
<ul>
<li>put <code>zig.syntax</code> file into <code>/usr/share/mc/syntax</code> directory</li>
<li>add following lines to <code>/usr/share/mc/syntax/Syntax</code>
<code>file .\*\\.(zig)$ zig\sProgram
include zig.syntax</code>
right before these lines (which are in the very end)
<code>file .\* unknown
include unknown.syntax</code></li>
</ul> | []
|
https://avatars.githubusercontent.com/u/50061290?v=4 | Grinch-Simulator | Dmrgn/Grinch-Simulator | 2022-12-31T00:26:43Z | Submission to MCPT's 2022 winter game jam | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/Dmrgn/Grinch-Simulator/tags | MIT | [
"raylib",
"zig"
]
| 33,694 | false | 2023-05-01T01:04:29Z | true | false | unknown | github | []
| Grinch Simulator
The Grinch has no-clipped out of reality and into a desolate city! Help him steal all their presents and avoid being caught by Santa.
<a>Demo video</a>
Inspiration 🤔
Grinch Simulator's art style was inspired by classic 80s games. I actually used the NES's colour palette to draw all the textures. Gameplay wise, I took inspiration from the popular genre of maze horror games like <a>Labyrinthine</a>, and <a>The Backrooms</a>. These games use the uncanny feeling of desolation and loneliness among a familiar environment to build suspense. I also heavily relied on music and sound effects, which I took from open source projects, in order to create a thematic environment.
What it does 🎁
In Grinch Simulator, the player plays as the Grinch who finds themselves in the middle of a desolate town on Christmas Eve. The player must navigate the complex maze while stealing any presents found along the way. But there is a catch! Santa is also on the loose and he is not too excited to see the Grinch's plot to ruin Christmas. The player must must avoid running into Santa at all costs and make use of their stamina to sprint away when he gets too close. But stamina will quickly deplete, and it takes a long time to regenerate.
How I built it ⚡
I created this game with the <a>Zig programming language</a> and the <a>Raylib graphics library</a> using <a>emscripten</a> to compile to <a>web assembly</a>.
This project was created based on <a>this zig-raylib examples repo</a>. I had to do major tweaking to get it to compile. Several random Raylib source files were giving errors and connecting my emscripten SDK was really finicky. Overall, I was surprised with the quality of documentation available for such niche technologies.
Challenges I ran into 👨🏻💻
I ran into many challenged while creating Grinch Simulator. One major challenge occurred when developing the system which textures the buildings and other 2.5D sprites. The graphics api Raylib provides is extremely low level and I had several issues with version discrepancies between the documentation and the version I was using. In the end, through a lot of trial and error, I managed to get textures rendering in a slightly incorrect manner which I was able to manually correct on a per case basis.
Accomplishments that I'm proud of ⭐
I'm proud of my implementation of the lighting system. Last year, during the Holiday Game Jam 2021, I implemented a similar lightning system in <a>my team's submission</a>. However, last year I attempted to implement it in a <a>glsl shader</a> and my inexperience working with glsl, as well as my improper use case, lead to the final product being slow, imprecise and not particularly all too amazing looking. This year I used a much simpler implementation that runs entirely on the CPU. I was able to make many optimization this time around which has lead to an infinitely better performance at no cost to quality.
What I learned 📔
Throughout the course of this jam, I became significantly more adept working with Zig. I believe this low level programming experience will translate to other programming languages of similar caliber, such as C or Rust. At the beginning of the jam, I was overly hesitant to use dynamic memory allocation for fear that it would lead to memory leaks. By the end of the jam, I had learned how to allocate memory and free it properly and was making much more use of it.
What's next for Grinch Simulator 📆
I think that I would like to expand this game by drawing more texture variations. Right now there are only 3 textures wall textures between every building. I could also make use of tinting, rotating, and mirroring textures to increase the diversity. I also think that in the future I would like to further develop Santa's AI, as currently the path finding algorithm is far from perfect. I would like the system to be more dynamic overall. | []
|
https://avatars.githubusercontent.com/u/11372210?v=4 | zig-raytracer | drumath2237/zig-raytracer | 2022-07-18T17:13:43Z | (WIP) make raytracer using zig-lang | main | 5 | 0 | 0 | 0 | https://api.github.com/repos/drumath2237/zig-raytracer/tags | Apache-2.0 | [
"raytracing",
"zig"
]
| 15 | false | 2022-07-19T15:07:47Z | true | false | unknown | github | []
| zig-raytracer
<a></a> | []
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.