Skip to content

Commit

Permalink
Merge ad95725 into 2bc774a
Browse files Browse the repository at this point in the history
  • Loading branch information
sbarzowski committed Nov 21, 2020
2 parents 2bc774a + ad95725 commit a3d9ddc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ export PATH=$PATH:$GOPATH/bin # If you haven't already
go generate
```

## Update cpp-jsonnet sub-repo

This repo depends on [the original Jsonnet repo](https://github.com/google/jsonnet). Shared parts include the standard library, headers files for C API and some tests.

You can update the submodule and regenerate dependent files with one command:
```
./update_cpp_jsonnet.sh
```

Note: It needs to be run from repo root.

## Updating and modifying the standard library

Standard library source code is kept in `cpp-jsonnet` submodule, because it is shared with [Jsonnet C++
Expand All @@ -133,11 +144,11 @@ implementation](https://github.com/google/jsonnet).
For performance reasons we perform preprocessing on the standard library, so for the changes to be visible, regeneration is necessary:

```bash
git submodule init
git submodule update
go run cmd/dumpstdlibast/dumpstdlibast.go cpp-jsonnet/stdlib/std.jsonnet > astgen/stdast.go
```

**The

The above command creates the _astgen/stdast.go_ file which puts the desugared standard library into the right data structures, which lets us avoid the parsing overhead during execution. Note that this step is not necessary to perform manually when building with Bazel; the Bazel target regenerates the _astgen/stdast.go_ (writing it into Bazel's build sandbox directory tree) file when necessary.

## Keeping the Bazel files up to date
Expand Down
16 changes: 16 additions & 0 deletions update_cpp_jsonnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Updates cpp-jsonnet repo and regenerates dependent files

set -e
set -x

cd cpp-jsonnet
git checkout master
git pull
cd ..
go run cmd/dumpstdlibast/dumpstdlibast.go cpp-jsonnet/stdlib/std.jsonnet > astgen/stdast.go

set +x
echo
echo -e "\033[1mUpdate completed. Please check if any tests are broken and fix any encountered issues.\033[0m"

0 comments on commit a3d9ddc

Please sign in to comment.