├── .github └── workflows │ ├── autofix.yml │ └── verify.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.zig ├── packages ├── Zig-PSP.json ├── adma.json ├── ansi-term.json ├── apple_pie.json ├── args.json ├── art.json ├── bearssl.json ├── bench.json ├── bincode-zig.json ├── bpf.json ├── clap.json ├── ctregex.json ├── dos.json ├── generator.json ├── hzzp.json ├── ihex.json ├── interface.json ├── iter-zig.json ├── known-folders.json ├── lola.json ├── lscolors.json ├── luf.json ├── mecha.json ├── network.json ├── ring-buffer.json ├── sdl.json ├── serial.json ├── string-searching.json ├── uri.json ├── vulkan-zig.json ├── wz.json ├── x86_64.json ├── xorfilter.json ├── zalgebra.json ├── zgl.json ├── zglfw.json ├── zig-alsa.json ├── zig-cassandra.json ├── zig-datetime.json ├── zig-pixman.json ├── zig-sqlite.json ├── zig-wayland.json ├── zig-windows-console.json ├── zig-wlroots.json ├── zig-xkbcommon.json ├── zigimg.json ├── zigvale.json ├── ziter.json ├── zitertools.json └── zlm.json ├── tags ├── algorithm.json ├── allocator.json ├── async.json ├── audio.json ├── binding.json ├── crypto.json ├── database.json ├── datastructure.json ├── datetime.json ├── functional.json ├── game.json ├── hardware.json ├── math.json ├── meta.json ├── networking.json ├── os.json ├── programming-language.json ├── serialization.json ├── string.json └── terminal.json └── tools ├── adder.zig ├── fixer.zig ├── http.zig ├── shared.zig └── verifier.zig /.github/workflows/autofix.yml: -------------------------------------------------------------------------------- 1 | name: Autofix 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '2 0 * * *' 7 | 8 | # Allow one concurrent deployment 9 | concurrency: 10 | group: "pages" 11 | cancel-in-progress: true 12 | 13 | jobs: 14 | fix: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Setup Zig 19 | uses: goto-bus-stop/setup-zig@v1 20 | with: 21 | version: master 22 | - name: Fix package metadata 23 | env: 24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 25 | run: | 26 | sudo apt-get update -y 27 | sudo apt-get install -y libcurl4-openssl-dev 28 | zig build fix 29 | - name: Auto commit 30 | uses: stefanzweifel/git-auto-commit-action@v4 31 | with: 32 | commit_message: Automated Change to packages 33 | file_pattern: 'packages/*.json' 34 | commit_author: Actions 35 | -------------------------------------------------------------------------------- /.github/workflows/verify.yml: -------------------------------------------------------------------------------- 1 | name: Repository Validation 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | verify: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | 16 | - name: Setup Zig 17 | uses: goto-bus-stop/setup-zig@v1 18 | with: 19 | version: master 20 | 21 | - name: Run verification 22 | run: | 23 | zig build verify 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | zig-cache 2 | *html 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 ZigLibs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zig Package Repository 2 | 3 | This is one community-maintained repository of zig packages. 4 | 5 | ## Contributions 6 | If you have an actively maintained package, feel free to create a PR that adds your package to the repository! If you feel like it, you're also free to add other peoples packages! 7 | 8 | ### Adding new packages 9 | 10 | The repo provides a convenience tool to create new packages. Just run `zig build add` to get a prompt for package informations. The tool will verify that the entered information is vaguely correct and follows the format rules, also checks if a package with that name already exists and if the tags are all valid. 11 | 12 | ### Verification 13 | 14 | ![Repository Validation](https://github.com/ziglibs/repository/workflows/Repository%20Validation/badge.svg?event=push) 15 | 16 | This repository will use the CI to verify if all PRs keep the database consistent. If you want to locally test this before doing the PR, just call `zig build verify` in the root folder. 17 | 18 | ## Repository structure 19 | 20 | The repository contains two major data sets: *packages* and *tags*. 21 | 22 | *Tags* are just groups of packages, each package can have zero or more tags assigned. *Packages* are basically a link to *any* git repository paired with a root source file which is required for the package to be imported. 23 | 24 | ### `packages/` 25 | A folder containing a single file per package. Each file is a json file following this structure: 26 | ```json 27 | { 28 | "author": "", 29 | "description": "", 30 | "git": "", 31 | "root_file": "", 32 | "tags": [ 33 | "", "" 34 | ] 35 | } 36 | ``` 37 | 38 | The fields have the following meaning: 39 | - `author` is the name (or nickname) of the package author 40 | - `description` is a short description of the package 41 | - `git` is a path to the git repository where the package can be fetched 42 | - `root_file` is an absolute path in unix style (path segments separated by `/`) to the root file of the package. This is what should be used for `std.build.Pkg.path` 43 | - `tags` is an array of strings where each item is the name of a tag in the folder `tags/`. Tags are identified by their file name (without extension) and will group the packages 44 | 45 | ### `tags/` 46 | A folder containing a single file per tag. Each file is a json file following this structure: 47 | ```json 48 | { 49 | "description": "" 50 | } 51 | ``` 52 | 53 | The fields have the following meaning: 54 | - `description` is a short description of what kind of packages can be found in this group. 55 | 56 | ### `tools/` 57 | 58 | This folder contains the sources of the verification tools and other nice things. 59 | -------------------------------------------------------------------------------- /build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub fn build(b: *std.build.Builder) !void { 4 | const verifier = b.addExecutable(.{ 5 | .name = "verifier", 6 | .root_source_file = .{ .path = "tools/verifier.zig" }, 7 | }); 8 | const adder = b.addExecutable(.{ 9 | .name = "adder", 10 | .root_source_file = .{ .path = "tools/adder.zig" }, 11 | }); 12 | 13 | const verify = verifier.run(); 14 | const add = adder.run(); 15 | 16 | const verify_step = b.step("verify", "Verifies if the repository structure is sane and valid."); 17 | verify_step.dependOn(&verify.step); 18 | 19 | const add_step = b.step("add", "Adds a new package"); 20 | add_step.dependOn(&add.step); 21 | 22 | try buildToolsFixer(b); 23 | } 24 | 25 | fn buildToolsFixer(b: *std.build.Builder) !void { 26 | const exe = b.addExecutable(.{ 27 | .name = "fix", 28 | .root_source_file = .{ .path = "tools/fixer.zig" }, 29 | }); 30 | exe.linkSystemLibrary("libcurl"); 31 | exe.linkLibC(); 32 | const run_cmd = exe.run(); 33 | 34 | const run_step = b.step("fix", "Fix GitHub package metadata"); 35 | run_step.dependOn(&run_cmd.step); 36 | } 37 | -------------------------------------------------------------------------------- /packages/Zig-PSP.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Nathan Bourgeois", 3 | "tags": [ 4 | "game" 5 | ], 6 | "git": "https://github.com/zPSP-Dev/Zig-PSP", 7 | "root_file": "/src/psp/pspsdk.zig", 8 | "description": "A project to bring the Zig Programming Language to the Sony PlayStation Portable!", 9 | "license": "other", 10 | "updated_at": "2023-04-05T20:44:18Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/adma.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Suirad", 3 | "tags": [ 4 | "allocator" 5 | ], 6 | "git": "https://github.com/suirad/adma", 7 | "root_file": "/src/adma.zig", 8 | "description": "A general purpose, multithreaded capable slab allocator for Zig", 9 | "license": "mit", 10 | "updated_at": "2023-01-28T07:45:53Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/ansi-term.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "joachimschmidt557", 3 | "tags": [ 4 | "terminal" 5 | ], 6 | "git": "https://github.com/ziglibs/ansi-term", 7 | "root_file": "/src/main.zig", 8 | "description": "Zig library for dealing with ANSI terminals", 9 | "license": "mit", 10 | "updated_at": "2023-03-26T19:10:32Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/apple_pie.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Luukdegram", 3 | "tags": [ 4 | "networking" 5 | ], 6 | "git": "https://github.com/Luukdegram/apple_pie", 7 | "root_file": "/src/apple_pie.zig", 8 | "description": "Basic HTTP server implementation in Zig", 9 | "license": "mit", 10 | "updated_at": "2023-04-05T04:56:38Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/args.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "os" 5 | ], 6 | "git": "https://github.com/MasterQ32/zig-args", 7 | "root_file": "/args.zig", 8 | "description": "Simple-to-use argument parser with struct-based config", 9 | "license": "mit", 10 | "updated_at": "2023-04-07T23:54:58Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/art.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "travisstaloch", 3 | "tags": [], 4 | "git": "https://github.com/travisstaloch/art.zig", 5 | "root_file": "/src/art.zig", 6 | "description": "An Adaptive Radix Tree ported from c", 7 | "license": "mit", 8 | "updated_at": "2023-03-26T02:47:11Z", 9 | "homepage": "" 10 | } 11 | -------------------------------------------------------------------------------- /packages/bearssl.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "networking", 5 | "crypto", 6 | "binding" 7 | ], 8 | "git": "https://github.com/MasterQ32/zig-bearssl", 9 | "root_file": "/src/lib.zig", 10 | "description": "A BearSSL binding for Zig", 11 | "license": "mit", 12 | "updated_at": "2023-03-03T17:44:52Z", 13 | "homepage": null 14 | } 15 | -------------------------------------------------------------------------------- /packages/bench.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "hejsil", 3 | "tags": [], 4 | "git": "https://github.com/Hejsil/zig-bench", 5 | "root_file": "/bench.zig", 6 | "description": "Simple benchmarking library", 7 | "license": "mit", 8 | "updated_at": "2023-03-25T12:39:34Z", 9 | "homepage": "" 10 | } 11 | -------------------------------------------------------------------------------- /packages/bincode-zig.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Quetzal Bradley", 3 | "tags": [ 4 | "serialization" 5 | ], 6 | "git": "https://github.com/qbradley/bincode-zig", 7 | "root_file": "/bincode.zig", 8 | "description": "A zig binary serializer/deserializer that is compatible with the rust bincode crate.", 9 | "license": "mit", 10 | "updated_at": "2023-03-15T17:39:25Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/bpf.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "mattnite", 3 | "tags": [ 4 | "networking", 5 | "os" 6 | ], 7 | "git": "https://github.com/mattnite/bpf", 8 | "root_file": "/exports.zig", 9 | "description": "[WIP] Zig BPF library", 10 | "license": "mit", 11 | "updated_at": "2023-01-30T01:07:23Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/clap.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "hejsil", 3 | "tags": [ 4 | "os" 5 | ], 6 | "git": "https://github.com/Hejsil/zig-clap", 7 | "root_file": "/clap.zig", 8 | "description": "Simple command line argument parsing library", 9 | "license": "mit", 10 | "updated_at": "2023-04-10T03:36:16Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/ctregex.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "alexnask", 3 | "tags": [ 4 | "string", 5 | "meta" 6 | ], 7 | "git": "https://github.com/alexnask/ctregex.zig", 8 | "root_file": "/ctregex.zig", 9 | "description": "Compile time regular expressions in zig", 10 | "license": null, 11 | "updated_at": "2023-03-31T04:35:41Z", 12 | "homepage": null 13 | } 14 | -------------------------------------------------------------------------------- /packages/dos.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "jayschwa", 3 | "tags": [ 4 | "os" 5 | ], 6 | "git": "https://github.com/jayschwa/dos.zig", 7 | "root_file": "/src/dos.zig", 8 | "description": "Create DOS programs with Zig", 9 | "license": "mit", 10 | "updated_at": "2023-04-02T01:29:49Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/generator.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "yrashk", 3 | "tags": [ 4 | "async" 5 | ], 6 | "git": "https://github.com/yrashk/zig-generator", 7 | "root_file": "/src/lib.zig", 8 | "description": "Async generator type for Zig", 9 | "license": "mit", 10 | "updated_at": "2023-03-24T21:07:14Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/hzzp.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "truemedian", 3 | "tags": [ 4 | "networking" 5 | ], 6 | "git": "https://github.com/truemedian/hzzp", 7 | "root_file": "/src/main.zig", 8 | "description": "A HTTP/1.0 and HTTP/1.1 library for Zig", 9 | "license": "mit", 10 | "updated_at": "2023-04-07T02:24:26Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/ihex.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "serialization" 5 | ], 6 | "git": "https://github.com/MasterQ32/zig-ihex", 7 | "root_file": "/ihex.zig", 8 | "description": "An intel hex loader written in Zig", 9 | "license": "mit", 10 | "updated_at": "2022-12-29T09:55:09Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/interface.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "alexnask", 3 | "tags": [ 4 | "meta" 5 | ], 6 | "git": "https://github.com/alexnask/interface.zig", 7 | "root_file": "/interface.zig", 8 | "description": "Dynamic dispatch for zig made easy", 9 | "license": "mit", 10 | "updated_at": "2023-04-10T00:18:11Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/iter-zig.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Takayuki Goto (@eldesh)", 3 | "tags": [ 4 | "datastructure", 5 | "algorithm" 6 | ], 7 | "git": "https://github.com/eldesh/iter-zig", 8 | "root_file": "/src/lib.zig", 9 | "description": "A basic iterator library written in Zig", 10 | "license": "bsd-2-clause", 11 | "updated_at": "2023-02-21T00:03:41Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/known-folders.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "ziglibs", 3 | "tags": [ 4 | "os" 5 | ], 6 | "git": "https://github.com/ziglibs/known-folders", 7 | "root_file": "/known-folders.zig", 8 | "description": "Provides access to well-known folders across several operating systems", 9 | "license": "mit", 10 | "updated_at": "2023-03-27T18:56:11Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/lola.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "programming-language" 5 | ], 6 | "git": "https://github.com/MasterQ32/LoLa", 7 | "root_file": "/src/library/main.zig", 8 | "description": "LoLa is a small programming language meant to be embedded into games.", 9 | "license": "mit", 10 | "updated_at": "2023-03-23T06:10:34Z", 11 | "homepage": "https://lola.random-projects.net/" 12 | } 13 | -------------------------------------------------------------------------------- /packages/lscolors.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "joachimschmidt557", 3 | "tags": [ 4 | "os", 5 | "terminal" 6 | ], 7 | "git": "https://github.com/ziglibs/lscolors", 8 | "root_file": "/src/main.zig", 9 | "description": "A zig library for colorizing paths according to LS_COLORS", 10 | "license": "mit", 11 | "updated_at": "2023-03-23T06:10:43Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/luf.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Luukdegram", 3 | "tags": [ 4 | "programming-language" 5 | ], 6 | "git": "https://github.com/Luukdegram/luf", 7 | "root_file": "/src/luf.zig", 8 | "description": "Statically typed, embeddable, scripting language written in Zig.", 9 | "license": "mit", 10 | "updated_at": "2023-03-03T17:42:57Z", 11 | "homepage": "https://github.com/Luukdegram/luf" 12 | } 13 | -------------------------------------------------------------------------------- /packages/mecha.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "hejsil", 3 | "tags": [ 4 | "functional", 5 | "string" 6 | ], 7 | "git": "https://github.com/Hejsil/mecha", 8 | "root_file": "/mecha.zig", 9 | "description": "A parser combinator library for Zig", 10 | "license": "mit", 11 | "updated_at": "2023-04-08T22:31:57Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/network.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "networking" 5 | ], 6 | "git": "https://github.com/MasterQ32/zig-network", 7 | "root_file": "/network.zig", 8 | "description": "A smallest-common-subset of socket functions for crossplatform networking, TCP & UDP", 9 | "license": "mit", 10 | "updated_at": "2023-04-10T01:29:51Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/ring-buffer.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Guigui220D", 3 | "tags": [ 4 | "datastructure" 5 | ], 6 | "git": "https://github.com/Guigui220D/RingBuffer-Zig", 7 | "root_file": "/ring_buffer.zig", 8 | "description": "Thread-Safe template for a ring buffer with std compatible reader and writer and safety checks", 9 | "license": null, 10 | "updated_at": "2022-08-10T10:10:04Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/sdl.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "game", 5 | "binding" 6 | ], 7 | "git": "https://github.com/MasterQ32/SDL.zig", 8 | "root_file": "/src/lib.zig", 9 | "description": "A shallow wrapper around SDL that provides object API and error handling", 10 | "license": "mit", 11 | "updated_at": "2023-04-11T14:23:20Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/serial.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "os" 5 | ], 6 | "git": "https://github.com/MasterQ32/zig-serial", 7 | "root_file": "/serial.zig", 8 | "description": "Serial port configuration library for Zig", 9 | "license": "mit", 10 | "updated_at": "2023-03-27T06:06:42Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/string-searching.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "joachimschmidt557", 3 | "tags": [ 4 | "string" 5 | ], 6 | "git": "https://github.com/ziglibs/string-searching", 7 | "root_file": "/src/main.zig", 8 | "description": "String(not limited to []const u8)-searching algorithms in zig", 9 | "license": "mit", 10 | "updated_at": "2023-03-23T06:10:43Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/uri.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "networking" 5 | ], 6 | "git": "https://github.com/MasterQ32/zig-uri", 7 | "root_file": "/uri.zig", 8 | "description": "A small URI parser that parses URIs after RFC3986", 9 | "license": "mit", 10 | "updated_at": "2023-01-07T08:10:00Z", 11 | "homepage": null 12 | } 13 | -------------------------------------------------------------------------------- /packages/vulkan-zig.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Snektron", 3 | "tags": [ 4 | "game", 5 | "binding" 6 | ], 7 | "git": "https://github.com/Snektron/vulkan-zig", 8 | "root_file": "/generator/index.zig", 9 | "description": "Vulkan binding generator for Zig", 10 | "license": "mit", 11 | "updated_at": "2023-04-09T22:27:02Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/wz.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "truemedian", 3 | "tags": [ 4 | "networking" 5 | ], 6 | "git": "https://github.com/truemedian/wz", 7 | "root_file": "/src/main.zig", 8 | "description": "A WebSocket 1.3 library for Zig", 9 | "license": "mit", 10 | "updated_at": "2023-01-19T21:49:27Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/x86_64.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "leecannon", 3 | "tags": [ 4 | "hardware" 5 | ], 6 | "git": "https://github.com/leecannon/zig-x86_64", 7 | "root_file": "/src/index.zig", 8 | "description": "Support for x86_64 specific instructions (e.g. TLB flush), registers (e.g. control registers), and structures (e.g. page tables)", 9 | "license": "mit", 10 | "updated_at": "2023-02-20T13:38:11Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/xorfilter.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "hexops", 3 | "tags": [ 4 | "algorithm" 5 | ], 6 | "git": "https://github.com/hexops/xorfilter", 7 | "root_file": "/src/main.zig", 8 | "description": "fastfilter: Binary fuse & xor filters for Zig (faster and smaller than bloom filters)", 9 | "license": "other", 10 | "updated_at": "2023-04-11T07:17:51Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zalgebra.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Alexandre Chêne (kooparse)", 3 | "tags": [ 4 | "math", 5 | "game" 6 | ], 7 | "git": "https://github.com/kooparse/zalgebra", 8 | "root_file": "/src/main.zig", 9 | "description": "Linear algebra library for games and real-time graphics.", 10 | "license": "mit", 11 | "updated_at": "2023-03-29T22:37:35Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/zgl.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "game", 5 | "binding" 6 | ], 7 | "git": "https://github.com/ziglibs/zgl", 8 | "root_file": "/zgl.zig", 9 | "description": "Zig OpenGL Wrapper", 10 | "license": "mit", 11 | "updated_at": "2023-04-10T21:46:43Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/zglfw.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Nathan Bourgeois", 3 | "tags": [ 4 | "game" 5 | ], 6 | "git": "https://github.com/Iridescence-Technologies/zglfw", 7 | "root_file": "/src/glfw.zig", 8 | "description": "A thin, idiomatic wrapper for GLFW. Written in Zig, for Zig!", 9 | "license": "other", 10 | "updated_at": "2022-12-15T11:23:44Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zig-alsa.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "hazeycode", 3 | "tags": [ 4 | "binding", 5 | "audio" 6 | ], 7 | "git": "https://github.com/hazeycode/zig-alsa", 8 | "root_file": "/src/main.zig", 9 | "description": "ALSA (libasound) bindings for Zig", 10 | "license": "0bsd", 11 | "updated_at": "2022-02-19T21:43:37Z", 12 | "homepage": null 13 | } 14 | -------------------------------------------------------------------------------- /packages/zig-cassandra.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "vrischmann", 3 | "tags": [ 4 | "database" 5 | ], 6 | "git": "https://github.com/vrischmann/zig-cassandra", 7 | "root_file": "/src/lib.zig", 8 | "description": "Cassandra CQL client", 9 | "license": "mit", 10 | "updated_at": "2022-07-18T22:43:17Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zig-datetime.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "frmdstryr", 3 | "tags": [ 4 | "datetime" 5 | ], 6 | "git": "https://github.com/frmdstryr/zig-datetime", 7 | "root_file": "/src/main.zig", 8 | "description": "A date and time module for Zig", 9 | "license": "mit", 10 | "updated_at": "2023-04-03T23:31:35Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zig-pixman.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Isaac Freund", 3 | "tags": [ 4 | "binding" 5 | ], 6 | "git": "https://github.com/ifreund/zig-pixman", 7 | "root_file": "/pixman.zig", 8 | "description": "Zig bindings for pixman", 9 | "license": "mit", 10 | "updated_at": "2022-01-15T15:31:25Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zig-sqlite.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "vrischmann", 3 | "tags": [ 4 | "database" 5 | ], 6 | "git": "https://github.com/vrischmann/zig-sqlite", 7 | "root_file": "/sqlite.zig", 8 | "description": "zig-sqlite is a small wrapper around sqlite's C API, making it easier to use with Zig. ", 9 | "license": "mit", 10 | "updated_at": "2023-04-04T01:17:38Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zig-wayland.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Isaac Freund", 3 | "tags": [ 4 | "binding" 5 | ], 6 | "git": "https://github.com/ifreund/zig-wayland", 7 | "root_file": null, 8 | "description": "Zig wayland scanner and libwayland bindings", 9 | "license": "mit", 10 | "updated_at": "2023-04-03T22:41:11Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zig-windows-console.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "SuperAuguste", 3 | "tags": [ 4 | "os", 5 | "terminal" 6 | ], 7 | "git": "https://github.com/ziglibs/zig-windows-console", 8 | "root_file": "/src/main.zig", 9 | "description": "Zig Windows Console stuff", 10 | "license": "mit", 11 | "updated_at": "2023-02-11T08:24:27Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/zig-wlroots.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Isaac Freund", 3 | "tags": [ 4 | "binding" 5 | ], 6 | "git": "https://github.com/swaywm/zig-wlroots", 7 | "root_file": "/src/wlroots.zig", 8 | "description": "Zig bindings for wlroots", 9 | "license": "mit", 10 | "updated_at": "2023-04-03T22:38:13Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zig-xkbcommon.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Isaac Freund", 3 | "tags": [ 4 | "binding" 5 | ], 6 | "git": "https://github.com/ifreund/zig-xkbcommon", 7 | "root_file": "/src/xkbcommon.zig", 8 | "description": "Zig bindings for xkbcommon", 9 | "license": "mit", 10 | "updated_at": "2023-03-09T19:40:12Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zigimg.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "mlarouche", 3 | "tags": [ 4 | "game" 5 | ], 6 | "git": "https://github.com/zigimg/zigimg", 7 | "root_file": "/zigimg.zig", 8 | "description": "Zig library for reading and writing different image formats", 9 | "license": "mit", 10 | "updated_at": "2023-04-10T17:15:11Z", 11 | "homepage": "" 12 | } 13 | -------------------------------------------------------------------------------- /packages/zigvale.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "ominitay", 3 | "tags": [], 4 | "git": "https://github.com/ominitay/zigvale", 5 | "root_file": "/zigvale.zig", 6 | "description": "A Zig implementation of the stivale2 boot protocol", 7 | "license": "mit", 8 | "updated_at": "2023-01-28T19:33:58Z", 9 | "homepage": "" 10 | } 11 | -------------------------------------------------------------------------------- /packages/ziter.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "hejsil", 3 | "tags": [ 4 | "functional", 5 | "math" 6 | ], 7 | "git": "https://github.com/Hejsil/ziter", 8 | "root_file": "/ziter.zig", 9 | "description": "The missing iterators for Zig", 10 | "license": "mit", 11 | "updated_at": "2023-03-28T13:58:55Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/zitertools.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "onebsv1", 3 | "tags": [ 4 | "functional", 5 | "math" 6 | ], 7 | "git": "https://github.com/onebsv1/zitertools", 8 | "root_file": "/src/main.zig", 9 | "description": "An improved rewrite of the python itertools library to Zig.", 10 | "license": "mit", 11 | "updated_at": "2022-03-23T07:53:42Z", 12 | "homepage": "" 13 | } 14 | -------------------------------------------------------------------------------- /packages/zlm.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "xq", 3 | "tags": [ 4 | "game", 5 | "math" 6 | ], 7 | "git": "https://github.com/ziglibs/zlm", 8 | "root_file": "/zlm.zig", 9 | "description": "Zig linear mathemathics", 10 | "license": "mit", 11 | "updated_at": "2023-03-30T16:56:22Z", 12 | "homepage": null 13 | } 14 | -------------------------------------------------------------------------------- /tags/algorithm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that implement algorithms described in academic papers." 3 | } -------------------------------------------------------------------------------- /tags/allocator.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that are related to memory allocators." 3 | } 4 | -------------------------------------------------------------------------------- /tags/async.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages related to asynchronous computations." 3 | } -------------------------------------------------------------------------------- /tags/audio.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "description": "Packages that are related to working with audio." 4 | } 5 | -------------------------------------------------------------------------------- /tags/binding.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that are bindings to foreign libraries." 3 | } -------------------------------------------------------------------------------- /tags/crypto.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Any package that is related to cryptographic algorithms." 3 | } -------------------------------------------------------------------------------- /tags/database.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that are related to databases." 3 | } 4 | -------------------------------------------------------------------------------- /tags/datastructure.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that implement certain datastructures." 3 | } -------------------------------------------------------------------------------- /tags/datetime.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that deal with time" 3 | } 4 | -------------------------------------------------------------------------------- /tags/functional.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Contains functional programming constructs." 3 | } 4 | -------------------------------------------------------------------------------- /tags/game.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Package that are related to game development." 3 | } -------------------------------------------------------------------------------- /tags/hardware.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that deal with hardware abstraction." 3 | } 4 | -------------------------------------------------------------------------------- /tags/math.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that provide advanced math functionality." 3 | } 4 | -------------------------------------------------------------------------------- /tags/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "A package that provides new features to the language." 3 | } -------------------------------------------------------------------------------- /tags/networking.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that are related to networking applications." 3 | } -------------------------------------------------------------------------------- /tags/os.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that are related to interfacing the operating system." 3 | } -------------------------------------------------------------------------------- /tags/programming-language.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Embedded programming languages usable from Zig" 3 | } -------------------------------------------------------------------------------- /tags/serialization.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that are related to file formats, either providing saving/loading or both." 3 | } -------------------------------------------------------------------------------- /tags/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that provide advanced string/text manipulation." 3 | } 4 | -------------------------------------------------------------------------------- /tags/terminal.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Packages that assist in dealing with terminal input, output, and user interfaces." 3 | } 4 | -------------------------------------------------------------------------------- /tools/adder.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | const shared = @import("shared.zig"); 4 | 5 | const PackageDescription = shared.PackageDescription; 6 | const TagDescription = shared.TagDescription; 7 | 8 | var tag_collection: std.StringHashMap(void) = undefined; 9 | 10 | var allocator: std.mem.Allocator = undefined; 11 | var string_arena: std.mem.Allocator = undefined; 12 | 13 | pub fn main() !u8 { 14 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; 15 | defer _ = gpa.deinit(); 16 | 17 | allocator = gpa.allocator(); 18 | 19 | var string_arena_impl = std.heap.ArenaAllocator.init(allocator); 20 | defer string_arena_impl.deinit(); 21 | 22 | string_arena = string_arena_impl.allocator(); 23 | 24 | tag_collection = std.StringHashMap(void).init(allocator); 25 | defer tag_collection.deinit(); 26 | 27 | try loadTags(); 28 | 29 | try readPackage(); 30 | 31 | return 0; 32 | } 33 | 34 | fn readPackage() !void { 35 | const stdin = std.io.getStdIn().reader(); 36 | const stdout = std.io.getStdOut().writer(); 37 | 38 | var pkg = PackageDescription{ 39 | .author = undefined, 40 | .tags = undefined, 41 | .git = undefined, 42 | .root_file = undefined, 43 | .description = undefined, 44 | }; 45 | 46 | var file: std.fs.File = undefined; 47 | var path: []u8 = undefined; 48 | while (true) { 49 | try stdout.writeAll("name: "); 50 | var name = try stdin.readUntilDelimiterAlloc(allocator, '\n', 512); 51 | defer allocator.free(name); 52 | 53 | path = try std.mem.concat(allocator, u8, &[_][]const u8{ 54 | "packages/", 55 | name, 56 | ".json", 57 | }); 58 | 59 | file = std.fs.cwd().createFile(path, .{ 60 | .truncate = true, 61 | .exclusive = true, 62 | }) catch |err| switch (err) { 63 | error.PathAlreadyExists => { 64 | allocator.free(path); 65 | try stdout.writeAll("A package with this name already exists!\n"); 66 | continue; 67 | }, 68 | else => |e| { 69 | allocator.free(path); 70 | return e; 71 | }, 72 | }; 73 | break; 74 | } 75 | defer allocator.free(path); 76 | errdefer { 77 | std.fs.cwd().deleteFile(path) catch std.debug.panic("Failed to delete file {s}!", .{path}); 78 | } 79 | defer file.close(); 80 | 81 | try stdout.writeAll("author: "); 82 | pkg.author = try stdin.readUntilDelimiterAlloc(allocator, '\n', 512); 83 | defer allocator.free(pkg.author); 84 | 85 | try stdout.writeAll("description: "); 86 | pkg.description = try stdin.readUntilDelimiterAlloc(allocator, '\n', 512); 87 | defer allocator.free(pkg.description); 88 | 89 | try stdout.writeAll("git: "); 90 | pkg.git = try stdin.readUntilDelimiterAlloc(allocator, '\n', 512); 91 | defer allocator.free(pkg.git); 92 | 93 | try stdout.writeAll("source: "); 94 | pkg.root_file = try stdin.readUntilDelimiterAlloc(allocator, '\n', 512); 95 | defer if (pkg.root_file) |root_file| allocator.free(root_file); 96 | 97 | var tags = std.ArrayList([]const u8).init(allocator); 98 | defer { 99 | for (tags.items) |tag| { 100 | allocator.free(tag); 101 | } 102 | tags.deinit(); 103 | } 104 | while (true) { 105 | try stdout.writeAll("tags: "); 106 | const tag_string = try stdin.readUntilDelimiterAlloc(allocator, '\n', 512); 107 | defer allocator.free(tag_string); 108 | 109 | var bad = false; 110 | var iterator = std.mem.split(u8, tag_string, ","); 111 | while (iterator.next()) |part| { 112 | const tag = std.mem.trim(u8, part, " \t\r\n"); 113 | if (tag.len == 0) 114 | continue; 115 | if (tag_collection.get(tag) == null) { 116 | try stdout.print("Tag '{s}' does not exist!\n", .{tag}); 117 | bad = true; 118 | } 119 | } 120 | 121 | if (bad) continue; 122 | 123 | iterator = std.mem.split(u8, tag_string, ","); 124 | while (iterator.next()) |part| { 125 | const tag = std.mem.trim(u8, part, " \t\r\n"); 126 | if (tag.len == 0) 127 | continue; 128 | 129 | const str = try allocator.dupe(u8, tag); 130 | errdefer allocator.free(str); 131 | 132 | try tags.append(str); 133 | } 134 | 135 | break; 136 | } 137 | 138 | pkg.tags = tags.items; 139 | try pkg.writeTo(file.writer()); 140 | } 141 | 142 | fn freePackage(pkg: *PackageDescription) void { 143 | for (pkg.tags.items) |tag| { 144 | allocator.free(tag); 145 | } 146 | allocator.free(pkg.author); 147 | allocator.free(pkg.tags); 148 | allocator.free(pkg.git); 149 | allocator.free(pkg.root_file); 150 | allocator.free(pkg.description); 151 | } 152 | 153 | fn loadTags() !void { 154 | const stderr_file = std.io.getStdErr(); 155 | const stderr = stderr_file.writer(); 156 | 157 | var directory = try std.fs.cwd().openIterableDir("tags", .{ .no_follow = true }); 158 | defer directory.close(); 159 | 160 | var iterator = directory.iterate(); 161 | while (try iterator.next()) |entry| { 162 | if (entry.kind != .File) 163 | continue; 164 | if (std.mem.endsWith(u8, entry.name, ".json")) { 165 | var file = try directory.dir.openFile(entry.name, .{}); 166 | defer file.close(); 167 | 168 | const name = entry.name[0 .. entry.name.len - 5]; 169 | 170 | try tag_collection.put(try string_arena.dupe(u8, name), {}); // file names ought to be unique 171 | } else { 172 | try stderr.print("{s}/{s} is not a json file!\n", .{ "tags", entry.name }); 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /tools/fixer.zig: -------------------------------------------------------------------------------- 1 | //! Fix package metadata by GitHub REST API 2 | 3 | const std = @import("std"); 4 | const mem = std.mem; 5 | const log = std.log; 6 | const fs = std.fs; 7 | const json = std.json; 8 | const http = @import("http.zig"); 9 | const PackageDescription = @import("shared.zig").PackageDescription; 10 | 11 | const GITHUB_ROOT = "https://api.github.com"; 12 | const MAX_JSON_SIZE = 4096; 13 | 14 | // This struct define which fields to fill in 15 | const Repository = struct { 16 | homepage: ?[]const u8, 17 | description: ?[]const u8, 18 | updated_at: ?[]const u8, 19 | license: ?struct { 20 | key: []const u8, 21 | }, 22 | }; 23 | 24 | fn fetchRepositoryMetadata(allocator: mem.Allocator, hc: http.Client, repo_name: []const u8) !Repository { 25 | const url = try std.fmt.allocPrintZ(allocator, "{s}/repos/{s}", .{ GITHUB_ROOT, repo_name }); 26 | defer allocator.free(url); 27 | 28 | return try hc.json(Repository, url); 29 | } 30 | 31 | fn githubRepoName(packageGit: []const u8) ?[]const u8 { 32 | const prefix = "github.com/"; 33 | if (mem.indexOf(u8, packageGit, prefix)) |idx| { 34 | return packageGit[idx + prefix.len ..]; 35 | } 36 | return null; 37 | } 38 | 39 | fn fillGitHubPackage(allocator: mem.Allocator, hc: http.Client, file: fs.File) !void { 40 | var buf = std.ArrayList(u8).init(allocator); 41 | try file.reader().readAllArrayList(&buf, MAX_JSON_SIZE); 42 | defer buf.deinit(); 43 | 44 | var stream = json.TokenStream.init(buf.items); 45 | var package_desc = try json.parse(PackageDescription, &stream, .{ .allocator = allocator, .ignore_unknown_fields = true }); 46 | 47 | if (githubRepoName(package_desc.git)) |repo_name| { 48 | std.log.info("Fetch package metadata, repo:{s}", .{repo_name}); 49 | const repo = try fetchRepositoryMetadata(allocator, hc, repo_name); 50 | package_desc.updated_at = repo.updated_at; 51 | if (repo.license) |license| { 52 | package_desc.license = license.key; 53 | } 54 | if (repo.homepage) |homepage| { 55 | package_desc.homepage = homepage; 56 | } 57 | if (repo.description) |description| { 58 | package_desc.description = description; 59 | } 60 | 61 | try file.seekTo(0); 62 | try file.setEndPos(0); 63 | try package_desc.writeTo(file.writer()); 64 | } 65 | } 66 | 67 | pub fn main() anyerror!void { 68 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); 69 | defer arena.deinit(); 70 | const allocator = arena.allocator(); 71 | 72 | const hc = try http.Client.init(allocator); 73 | defer hc.deinit(); 74 | 75 | const dir = try fs.cwd().openIterableDir("packages", .{}); 76 | var walker = try dir.walk(allocator); 77 | defer walker.deinit(); 78 | 79 | while (try walker.next()) |entry| { 80 | const file = try entry.dir.openFile(entry.basename, .{ .mode = .read_write }); 81 | defer file.close(); 82 | 83 | try fillGitHubPackage(allocator, hc, file); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /tools/http.zig: -------------------------------------------------------------------------------- 1 | //! HTTP Client based on libcurl 2 | 3 | const std = @import("std"); 4 | const mem = std.mem; 5 | const cURL = @cImport({ 6 | @cInclude("curl/curl.h"); 7 | }); 8 | 9 | const UA: []const u8 = "ziglibs/1.0.0"; 10 | 11 | pub const Client = struct { 12 | allocator: mem.Allocator, 13 | handle: *cURL.CURL, 14 | headers: *cURL.curl_slist, 15 | 16 | const Self = @This(); 17 | const RawResponse = std.ArrayList(u8); 18 | 19 | pub fn deinit(self: Self) void { 20 | cURL.curl_slist_free_all(self.headers); 21 | cURL.curl_easy_cleanup(self.handle); 22 | } 23 | 24 | pub fn init(alloctor: mem.Allocator) !Self { 25 | const handle = cURL.curl_easy_init() orelse return error.CURLHandleInitFailed; 26 | 27 | var headers: ?*cURL.curl_slist = null; 28 | headers = cURL.curl_slist_append(headers, "Accept: application/vnd.github.v3+json"); 29 | if (std.os.getenv("GITHUB_TOKEN")) |token| { 30 | var buf = std.ArrayList(u8).init(alloctor); 31 | try buf.appendSlice("Authorization: Bearer "); 32 | try buf.appendSlice(token); 33 | headers = cURL.curl_slist_append(headers, buf.items.ptr); 34 | } 35 | if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_HTTPHEADER, headers) != cURL.CURLE_OK) 36 | unreachable(); 37 | 38 | if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_WRITEFUNCTION, writeToArrayListCallback) != cURL.CURLE_OK) 39 | unreachable(); 40 | 41 | if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_USERAGENT, UA.ptr) != cURL.CURLE_OK) 42 | unreachable(); 43 | 44 | if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_FOLLOWLOCATION, @as(c_long, 1)) != cURL.CURLE_OK) 45 | unreachable(); 46 | 47 | return Self{ .allocator = alloctor, .handle = handle, .headers = headers orelse unreachable }; 48 | } 49 | 50 | pub fn json(self: Self, comptime T: type, url: [:0]const u8) !T { 51 | const resp = try self.request(url); 52 | defer resp.deinit(); 53 | 54 | var stream = std.json.TokenStream.init(resp.items); 55 | return try std.json.parse(T, &stream, .{ .allocator = self.allocator, .ignore_unknown_fields = true }); 56 | } 57 | 58 | fn request( 59 | self: Self, 60 | url: [:0]const u8, 61 | ) !RawResponse { 62 | if (cURL.curl_easy_setopt(self.handle, cURL.CURLOPT_URL, url.ptr) != cURL.CURLE_OK) 63 | return error.CouldNotSetURL; 64 | 65 | var response_buffer = RawResponse.init(self.allocator); 66 | if (cURL.curl_easy_setopt(self.handle, cURL.CURLOPT_WRITEDATA, &response_buffer) != cURL.CURLE_OK) 67 | return error.CouldNotSetWriteCallback; 68 | 69 | if (cURL.curl_easy_perform(self.handle) != cURL.CURLE_OK) 70 | return error.FailedToPerformRequest; 71 | 72 | return response_buffer; 73 | } 74 | 75 | fn writeToArrayListCallback(data: *anyopaque, size: c_uint, nmemb: c_uint, user_data: *anyopaque) callconv(.C) c_uint { 76 | var buffer = @intToPtr(*std.ArrayList(u8), @ptrToInt(user_data)); 77 | var typed_data = @intToPtr([*]u8, @ptrToInt(data)); 78 | buffer.appendSlice(typed_data[0 .. nmemb * size]) catch return 0; 79 | return nmemb * size; 80 | } 81 | }; 82 | -------------------------------------------------------------------------------- /tools/shared.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub const PackageDescription = struct { 4 | author: []const u8, 5 | tags: [][]const u8, 6 | git: []const u8, 7 | root_file: ?[]const u8, 8 | description: []const u8, 9 | // https://github.com/ziglang/zig/pull/10498 10 | license: ?[]const u8 = null, 11 | updated_at: ?[]const u8 = null, 12 | homepage: ?[]const u8 = null, 13 | 14 | const Self = @This(); 15 | pub fn writeTo(self: Self, writer: anytype) !void { 16 | try std.json.stringify(self, .{ 17 | .whitespace = .{ 18 | .indent = .{ .Space = 2 }, 19 | .separator = true, 20 | }, 21 | .string = .{ 22 | .String = .{}, 23 | }, 24 | }, writer); 25 | try writer.writeAll("\n"); 26 | } 27 | }; 28 | 29 | pub const TagDescription = struct { 30 | description: []const u8, 31 | }; 32 | -------------------------------------------------------------------------------- /tools/verifier.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | const shared = @import("shared.zig"); 4 | 5 | const PackageDescription = shared.PackageDescription; 6 | const TagDescription = shared.TagDescription; 7 | 8 | var tag_collection: std.StringHashMap(void) = undefined; 9 | 10 | var allocator: std.mem.Allocator = undefined; 11 | var string_arena: std.mem.Allocator = undefined; 12 | 13 | pub fn main() !u8 { 14 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; 15 | defer _ = gpa.deinit(); 16 | 17 | allocator = gpa.allocator(); 18 | 19 | var string_arena_impl = std.heap.ArenaAllocator.init(allocator); 20 | defer string_arena_impl.deinit(); 21 | 22 | string_arena = string_arena_impl.allocator(); 23 | 24 | tag_collection = std.StringHashMap(void).init(allocator); 25 | defer tag_collection.deinit(); 26 | 27 | var success = true; 28 | 29 | if (!try verifyFolder("tags", verifyTagJson)) 30 | success = false; 31 | 32 | if (!try verifyFolder("packages", verifyPackageJson)) 33 | success = false; 34 | 35 | return if (success) @as(u8, 0) else 1; 36 | } 37 | 38 | const VerifierFunction = fn ( 39 | name: []const u8, 40 | data: []const u8, 41 | errors: *std.ArrayList([]const u8), 42 | ) anyerror!void; 43 | 44 | fn verifyFolder(directory_name: []const u8, comptime verifier: VerifierFunction) !bool { 45 | const stderr_file = std.io.getStdErr(); 46 | const stderr = stderr_file.writer(); 47 | 48 | var directory = try std.fs.cwd().openDir(directory_name, .{ .no_follow = true }); 49 | defer directory.close(); 50 | var dirs = try std.fs.cwd().openIterableDir(directory_name, .{ .no_follow = true }); 51 | defer dirs.close(); 52 | 53 | var success = true; 54 | 55 | var iterator = dirs.iterate(); 56 | while (try iterator.next()) |entry| { 57 | if (entry.kind != .File) 58 | continue; 59 | if (std.mem.endsWith(u8, entry.name, ".json")) { 60 | var file = try directory.openFile(entry.name, .{ .mode = .read_only }); 61 | defer file.close(); 62 | 63 | const source = try file.readToEndAlloc(allocator, 16384); // 16kB is a sane limit for a package description 64 | defer allocator.free(source); 65 | 66 | const name = entry.name[0 .. entry.name.len - 5]; 67 | 68 | var errors = std.ArrayList([]const u8).init(allocator); 69 | defer errors.deinit(); 70 | 71 | verifier(name, source, &errors) catch |err| { 72 | try errors.append(@errorName(err)); 73 | }; 74 | 75 | if (errors.items.len > 0) { 76 | try stderr.print("{s}/{s} is not a valid package description file:\n", .{ 77 | directory_name, 78 | entry.name, 79 | }); 80 | for (errors.items) |err| { 81 | try stderr.print("\t{s}\n", .{err}); 82 | } 83 | success = false; 84 | } 85 | } else { 86 | try stderr.print("{s}/{s} is not a json file!\n", .{ directory_name, entry.name }); 87 | success = false; 88 | } 89 | } 90 | 91 | return success; 92 | } 93 | 94 | fn verifyTagJson( 95 | name: []const u8, 96 | json_data: []const u8, 97 | errors: *std.ArrayList([]const u8), 98 | ) !void { 99 | var options = std.json.ParseOptions{ 100 | .allocator = allocator, 101 | .duplicate_field_behavior = .Error, 102 | }; 103 | var stream = std.json.TokenStream.init(json_data); 104 | 105 | const tag = try std.json.parse(TagDescription, &stream, options); 106 | defer std.json.parseFree(TagDescription, tag, options); 107 | 108 | if (tag.description.len == 0) 109 | try errors.append("description is empty!"); 110 | 111 | try tag_collection.put(try string_arena.dupe(u8, name), {}); // file names ought to be unique 112 | } 113 | 114 | fn verifyPackageJson( 115 | name: []const u8, 116 | json_data: []const u8, 117 | errors: *std.ArrayList([]const u8), 118 | ) !void { 119 | _ = name; 120 | 121 | var options = std.json.ParseOptions{ 122 | .allocator = allocator, 123 | .duplicate_field_behavior = .Error, 124 | }; 125 | var stream = std.json.TokenStream.init(json_data); 126 | 127 | const pkg = try std.json.parse(PackageDescription, &stream, options); 128 | defer std.json.parseFree(PackageDescription, pkg, options); 129 | 130 | if (pkg.author.len == 0) 131 | try errors.append("author is empty!"); 132 | 133 | if (pkg.git.len == 0) 134 | try errors.append("git is empty!"); 135 | 136 | if (pkg.description.len == 0) 137 | try errors.append("description is empty!"); 138 | 139 | if (pkg.root_file) |root| { 140 | if (root.len == 0) { 141 | try errors.append("root_file is empty! Use 'null' if the root file is unrequired."); 142 | } else if (!std.mem.startsWith(u8, root, "/")) { 143 | try errors.append("root_file must start with a '/'!"); 144 | } 145 | } 146 | 147 | for (pkg.tags) |tag| { 148 | const entry = tag_collection.get(tag); 149 | if (entry == null) { 150 | try errors.append(try std.fmt.allocPrint(string_arena, "Tag '{s}' does not exist!", .{tag})); 151 | } 152 | } 153 | } 154 | --------------------------------------------------------------------------------