sandboxed-api/oss-internship-2020/jsonnet/README.md

37 lines
2.0 KiB
Markdown
Raw Normal View History

2020-09-09 17:56:42 +08:00
# Jsonnet Sandboxed API
This library provides sandboxed version of the [Jsonnet](https://github.com/google/jsonnet) library.
## Examples
2020-09-10 21:27:22 +08:00
The `examples/` directory contains code to produce three command-line tools -- `jsonnet_sandboxed`, `jsonnet_yaml_stream_sandboxed` and `jsonnet_multiple_files_sandboxed`. The first one enables the user to evaluate jsonnet code held in one file and writing to one output file. The second evaluates one jsonnet file into one file, which can be interepreted as YAML stream. The third one is for evaluating one jsonnet file into multiple output files.
All three tools are based on what can be found [here](https://github.com/google/jsonnet/blob/master/cmd/jsonnet.cpp).
2020-09-09 17:56:42 +08:00
## Build
To build this example, after cloning the whole Sandbox API project, you also need to run
```
git submodule update --init --recursive
```
anywhere in the project tree in order to clone the `jsonnet` submodule.
Then in the `sandboxed-api/oss-internship-2020/jsonnet` run
```
mkdir build && cd build
cmake -G Ninja
ninja
```
2020-09-10 21:27:22 +08:00
To run `jsonnet_sandboxed` (or `jsonnet_yaml_stream_sandboxed` in a similar way):
2020-09-09 17:56:42 +08:00
```
cd examples
./jsonnet_sandboxed absolute/path/to/the/input_file.jsonnet \
absolute/path/to/the/output_file
```
2020-09-10 18:19:06 +08:00
To run `jsonnet_mutiple_files_sandboxed`:
```
cd examples
./jsonnet_mutiple_files_sandboxed absolute/path/to/the/input_file.jsonnet \
absolute/path/to/the/output_directory
```
2020-09-10 21:27:22 +08:00
All three tools support evaluating one input file (possibly relying on multiple other files, e.x. by jsonnet `import` command; the files must be held in the same directory as input file) into one or more output files. Example jsonnet codes to evaluate in a one-in-one-out manner can be found [here](https://github.com/google/jsonnet/tree/master/examples). Example code producing multiple output files or YAML stream files can be found in the `examples/jsonnet_codes` directory, in files called `multiple_files_example.jsonnet` and `yaml_stream_example.jsonnet`, respectively.