Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bazel-contrib/rules_jsonnet
Jsonnet rules for Bazel
https://github.com/bazel-contrib/rules_jsonnet
bazel bazel-rules jsonnet jsonnet-rules
Last synced: about 1 month ago
JSON representation
Jsonnet rules for Bazel
- Host: GitHub
- URL: https://github.com/bazel-contrib/rules_jsonnet
- Owner: bazel-contrib
- License: apache-2.0
- Created: 2016-03-15T18:56:06.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-11-13T05:53:22.000Z (about 2 months ago)
- Last Synced: 2024-11-13T06:26:34.825Z (about 2 months ago)
- Topics: bazel, bazel-rules, jsonnet, jsonnet-rules
- Language: Starlark
- Homepage: https://bazelbuild.github.io/rules_jsonnet/
- Size: 232 KB
- Stars: 68
- Watchers: 25
- Forks: 73
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: CODEOWNERS
- Authors: AUTHORS
Awesome Lists containing this project
- awesome-bazel - Jsonnet
README
[![Build status](https://badge.buildkite.com/c3449aba989713394a3237070971eb59b92ad19d6f69555a25.svg)](https://buildkite.com/bazel/rules-jsonnet-postsubmit)
# Jsonnet Rules
## Overview
These are build rules for working with [Jsonnet][jsonnet] files with Bazel.
[jsonnet]: https://jsonnet.org
## Setup
To use the Jsonnet rules as part of your Bazel project, please follow the
instructions on [the releases page](https://github.com/bazelbuild/rules_jsonnet/releases).## Jsonnet Compiler Selection
By default for Bzlmod, Bazel will use the [Go
compiler](https://github.com/google/go-jsonnet). Note that the
primary development focus of the Jsonnet project is now with the Go compiler.
This repository's support for using the C++ compiler is deprecated, and may be
removed in a future release.To use [the
C++](https://github.com/google/jsonnet) or
[Rust](https://github.com/CertainLach/jrsonnet) compiler of Jsonnet instead,
register a different compiler:| Jsonnet compiler | MODULE.bazel directive |
| ---------------- | --------------------------------- |
| Go | `jsonnet.compiler(name = "go")` |
| cpp | `jsonnet.compiler(name = "cpp")` |
| Rust | `jsonnet.compiler(name = "rust")` |### Rust Jsonnet Compiler
To use the Rust Jsonnet compiler a `Nightly` Rust version for the host tools is
required because `-Z bindeps` is needed to compile the Jrsonnet binary.Add the following snippet to the `MODULE.bazel` file:
```Starlark
bazel_dep(name = "rules_rust", version = "0.45.1")rust_host = use_extension("@rules_rust//rust:extensions.bzl", "rust_host_tools")
rust_host.host_tools(
version = "nightly/2024-05-02",
)
```### CLI
Use the `--extra_toolchains` flag to pass the preferred toolchain to the bazel
invocation:```bash
bazel build //... --extra_toolchains=@rules_jsonnet//jsonnet:cpp_jsonnet_toolchainbazel test //... --extra_toolchains=@rules_jsonnet//jsonnet:rust_jsonnet_toolchain
bazel run //... --extra_toolchains=@rules_jsonnet//jsonnet:go_jsonnet_toolchain
```## Rule usage
Please refer to [the StarDoc generated documentation](docs/jsonnet.md)
for instructions on how to use these rules.