8000 GitHub - Titousensei/rules_zig: Bazel build rules for Zig
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Titousensei/rules_zig

 
 

Repository files navigation

Bazel build rules for Zig

Build Zig code with the Bazel build system.

Status

🚧 This is a hobby project in early development. 🚧

Please get in touch if you would like to use these rules in production.

Take a look at the planned functionality tracking issue to get a picture of which functionality is already implemented and what is still missing.

Motivation

Why would you use Bazel to build Zig code, when Zig comes with its own perfectly fine build system?

These Bazel rules are not meant as competition to the Zig build system. If your project fits well within the scope of Zig's build system, in particular, it only uses Zig code and perhaps C/C++ code, then Zig's build system will probably work very well for your use-case.

Bazel is useful for polyglot, monorepo projects, especially if they are very large. If your project involves multiple programming languages and if some of them are not supported by Zig's build system, or if your project involves complex code-generation steps or requires a lot of custom build steps, then Bazel may be a good choice. If your project is already a Bazel project and you want to add Zig code to it then this rule set is for you.

Bazel has builtin support for cross-compilation and build configuration, meaning it can support Zig's cross-compilation and build configuration features well.

Installation

Using Bzlmod with Bazel >=6

Add the following to your MODULE.bazel file to install rules_zig:

bazel_dep(name = "rules_zig")
archive_override(
    module_name = "rules_zig",
    integrity = "sha256-$SHA256",
    strip_prefix = "rules_zig-$COMMIT",
    urls = ["https://github.com/aherrmann/rules_zig/archive/$COMMIT.tar.gz"],
)

Using WORKSPACE

Add the following to your WORKSPACE file to install rules_zig:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_zig",
    sha256 = "$SHA256",
    strip_prefix = "rules_zig-$COMMIT",
    urls = ["https://github.com/aherrmann/rules_zig/archive/$COMMIT.tar.gz"],
)

load(
    "@rules_zig//zig:repositories.bzl",
    "rules_zig_dependencies",
    "zig_register_toolchains",
)

rules_zig_dependencies()

zig_register_toolchains(
    name = "zig",
    zig_version = "0.10.1",
)

Reference Documentation

Generated API documentation for the provided rules is available in ./docs/rules.md.

Usage Examples

Examples can be found among the end-to-end tests under ./e2e/workspace.

About

Bazel build rules for Zig

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Starlark 85.6%
  • Zig 11.3%
  • Python 3.0%
  • C 0.1%
0