Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the Bazel toolchain support to change the effective Jsonnet compiler. Go-Jsonnet, Jsonnet (cpp) and Jrsonnet (Rust) are implemented.
There are some incompatibilities:
Jsonnet (cpp) does not support the -c flag to create nested output directories.
Jrsonnet (Rust) does not support manifest files containing the files that were generated by the Jsonnet program. It's currently only able to write those outputs to stdout.
Jrsonnet text output (e.g. errors) is different compared to the cpp and Go implementations.
Due to these incompatibilities there are two addditional attributes on the toolchain: the flags to pass during directory creation and if manifest files are supported.
When adding rules_jsonnet as a bzlmod module, a user can now select the preferred compiler by using:
Currently there are three options:
cpp
,go
andrust
.Additionally, this fixes CI:
The current .bazelci expects a variable ${{ jsonnet_port }} to be defined. However, that isn't the case with the current setup. The current behaviour is an empty ${{ jsonnet_port }} which causes the implementation to fall back to the default (Go), effectively disabling the cpp tests.
The CI runs:
Lastly, fix docs:
The current docs setup only supports a single source file for docs generation (jsonnet.bzl). Now that
toolchains.bzl
is also a file that must be included in the docs generation, we use a helper filedocs.bzl
to aggregate what needs to be documented.Note:
To use the Rust Jsonnet compiler a
Nightly
Rust version for the host tools isrequired because
-Z bindeps
is needed to compile the Jrsonnet binary.Add the following snippet to the
Module.bazel
file:Fixes #150