-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: ``` jsonnet = use_extension("@rules_jsonnet//jsonnet:extensions.bzl", "jsonnet") jsonnet.compiler(name = "rust") ``` Currently there are three options: `cpp`, `go` and `rust`. 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: ``` bazel test //... --extra_toolchains=@rules_jsonnet//jsonnet:go_jsonnet_toolchain bazel test //... --extra_toolchains=@rules_jsonnet//jsonnet:rust_jsonnet_toolchain bazel test //... --extra_toolchains=@rules_jsonnet//jsonnet:cpp_jsonnet_toolchain ``` 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 file `docs.bzl` to aggregate what needs to be documented.
- Loading branch information
Showing
18 changed files
with
371 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
^RUNTIME ERROR: Foo\. | ||
.*invalid\.jsonnet:15:1-13 ($|\$ | ||
During evaluation ) | ||
^RUNTIME ERROR: Foo.*invalid\.jsonnet:15:1-13* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This module 'other_toolchain_module' is here to test multiple modules | ||
# providing different toolchains and the logic in the toolchain conflict | ||
# resolution logic. | ||
|
||
module( | ||
name = "other_toolchain_module", | ||
version = "0.0.0", | ||
) | ||
|
||
bazel_dep(name = "rules_jsonnet", version = "0.0.0") | ||
|
||
jsonnet = use_extension("@rules_jsonnet//jsonnet:extensions.bzl", "jsonnet") | ||
jsonnet.compiler(name = "rust") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
'hello.txt': 'Hello, Bazel!', | ||
'goodbye.txt': 'Goodbye, Bazel!', | ||
'nested/nested.txt': 'This file is in a nested directory.', | ||
} |
Oops, something went wrong.