Debian Codegraph @

README.md

raw
1 # Jsonnet - The data templating language
2
3 ![master branch build status badge](https://github.com/google/jsonnet/actions/workflows/build_and_test.yml/badge.svg?event=push&branch=master)
4
5 For an introduction to Jsonnet and documentation,
6 [visit our website](https://jsonnet.org).
7
8 This repository contains the original implementation. You can also try [go-jsonnet](https://github.com/google/go-jsonnet), a newer implementation which in some cases is orders of magnitude faster, and is recommended in preference to the C++ version.
9
10 Visit our [discussion forum](https://groups.google.com/g/jsonnet).
11
12 **Security notes:** If you need to process *untrusted inputs* (untrusted Jsonnet code), it is best not to use the C++ implementation, as it is not hardened for that use-case. The expected use-case is for evaluating Jsonnet code that you / your organisation has written and trusts not to be malicious. Even ignoring the risk of exploitable bugs in the implementation, the `import`, `importstr`, and `importbin` language constructs can potentially be used to exfiltrate sensitive data unless you take extra steps to restrict these or sandbox the jsonnet interpreter. By default, these constructs can import from any path accessible to the interpreter process.
13
14 ## Packages
15
16 Jsonnet is available on Homebrew:
17
18 ```
19 brew install jsonnet
20 ```
21
22 [Jsonnet](https://packages.msys2.org/base/mingw-w64-jsonnet) is available on [MSYS2](https://www.msys2.org/):
23
24 ```
25 pacman -S mingw-w64-clang-i686-jsonnet
26 ```
27 ```
28 pacman -S mingw-w64-clang-x86_64-jsonnet
29 ```
30 ```
31 pacman -S mingw-w64-i686-jsonnet
32 ```
33 ```
34 pacman -S mingw-w64-x86_64-jsonnet
35 ```
36 ```
37 pacman -S mingw-w64-ucrt-x86_64-jsonnet
38 ```
39
40 The Python binding is on pypi:
41
42 ```
43 pip install jsonnet
44 ```
45
46 You can also download and install Jsonnet using the [vcpkg](https://github.com/Microsoft/vcpkg/)
47 dependency manager:
48
49 ```
50 git clone https://github.com/Microsoft/vcpkg.git
51 cd vcpkg
52 ./bootstrap-vcpkg.sh
53 ./vcpkg integrate install
54 vcpkg install jsonnet
55 ```
56
57 The Jsonnet port in vcpkg is kept up to date by Microsoft team members and community contributors.
58 If the version is out of date, please [create an issue or pull
59 request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
60
61 ## Building Jsonnet
62
63 You can use either GCC or Clang to build Jsonnet. Note that on recent versions
64 of macOS, `/usr/bin/gcc` and `/usr/bin/g++` are actually Clang, so there is no
65 difference.
66
67 ### Makefile
68
69 To build Jsonnet with GCC, run:
70
71 ```
72 make
73 ```
74
75 To build Jsonnet with Clang, run:
76
77 ```
78 make CC=clang CXX=clang++
79 ```
80
81 To run the output binary, run:
82
83 ```
84 ./jsonnet
85 ```
86
87 To run the reformatter, run:
88
89 ```
90 ./jsonnetfmt
91 ```
92
93 ### Bazel
94
95 Bazel builds are also supported.
96 Install [Bazel](https://www.bazel.io/versions/master/docs/install.html) if it is
97 not installed already. Then, run the following command to build with GCC:
98
99 ```
100 bazel build -c opt //cmd:all
101 ```
102
103 To build with Clang, use one of these two options:
104
105 ```
106 env CC=clang CXX=clang++ bazel build -c opt //cmd:all
107
108 # OR
109
110 bazel build -c opt --action_env=CC=clang --action_env=CXX=clang++ //cmd:all
111 ```
112
113 This builds the `jsonnet` and `jsonnetfmt` targets defined in [`cmd/BUILD`](./cmd/BUILD). To launch
114 the output binaries, run:
115
116 ```
117 bazel-bin/cmd/jsonnet
118 bazel-bin/cmd/jsonnetfmt
119 ```
120
121
122 ### CMake
123
124
125 ```
126 cmake . -Bbuild
127 ```
128
129 ```
130 cmake --build build --target run_tests
131 ```
132
133 ## Contributing
134
135 See the [contributing page](https://jsonnet.org/learning/community.html#license) on our website.
136
137
138 ## Developing Jsonnet
139
140 ### Running tests
141
142 To run the comprehensive suite:
143
144 ```
145 make test
146 ```
147
148
149 ### Locally serving the website
150
151 You need a `doc/js/libjsonnet.wasm` which can either be downloaded from the
152 production website:
153
154 ```
155 wget https://jsonnet.org/js/libjsonnet.wasm -O doc/js/libjsonnet.wasm
156 ```
157
158 Or you can build it yourself, which requires checking out
159 [go-jsonnet](https://github.com/google/go-jsonnet). See the README.md in
160 that repo for instructions.
161
162 The standard library is documented in a structured format in `doc/_stdlib_gen/stdlib-content.jsonnet`.
163 The HTML (input for Jekyll) is regenerated using the following command:
164
165 ```
166 tools/scripts/update_web_content.sh
167 ```
168
169 Then, from the root of the repository you can generate and serve the website using
170 [Jekyll](https://jekyllrb.com/) (you need version 4.3.0 or later):
171
172 ```
173 jekyll serve -s doc/
174 ```
175
176 This should build and serve the website locally, and automatically rebuild
177 when you change any underlying files.