go-jsonnet/update_cpp_jsonnet.sh
John Bartholomew e1304d1698 update cppjsonnet and depend on a specific commit of jsonnet
This changes the bazel module dependencies so that the C++ jsonnet
repo dependency (which is actually used as the source for the
standard library and nothing else in the Bazel build) comes from
a specific commit of the jsonnet repo, rather than depending on
the 'published' jsonnet 0.20.0.

The two repos are tightly coupled anyway so I think this more
accurately reflects the situation. Particularly since the C++ repo
is also linked (at a specific commit) as a git submodule, which
is used for non-Bazel build and testing.
2025-01-20 21:45:24 +00:00

29 lines
817 B
Bash
Executable File

#!/bin/bash
# Updates cpp-jsonnet repo and regenerates dependent files
set -e
set -x
cd cpp-jsonnet
git checkout master
git pull
hash=$(git rev-parse HEAD)
cd ..
go run cmd/dumpstdlibast/dumpstdlibast.go cpp-jsonnet/stdlib/std.jsonnet > astgen/stdast.go
sha256=$(curl -fL https://github.com/google/jsonnet/archive/$hash.tar.gz | shasum -a 256 | awk '{print $1}')
sed -i.bak \
-e "s/CPP_JSONNET_SHA256 = .*/CPP_JSONNET_SHA256 = \"$sha256\"/;" \
-e "s/CPP_JSONNET_GITHASH = .*/CPP_JSONNET_GITHASH = \"$hash\"/;" \
bazel/repositories.bzl MODULE.bazel
# NB: macOS sed doesn't support -i without arg. This is the easy workaround.
rm bazel/repositories.bzl.bak
rm MODULE.bazel.bak
set +x
echo
echo -e "\033[1mUpdate completed. Please check if any tests are broken and fix any encountered issues.\033[0m"