Closed Kevintjeb closed 3 months ago
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
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 is required because-Z bindeps
is needed to compile the Jrsonnet binary.Add the following snippet to the
Module.bazel
file:Fixes #150