From 69137c91b640adbd33ae915f2e30576d948a5c8d Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Wed, 26 Oct 2022 15:58:45 +1100 Subject: [PATCH] Update bazel cpp_jsonnet reference from update_cpp_jsonnet.sh Teach `update_cpp_jsonnet.sh` to update the cpp_jsonnet reference in `bazel/repositories.bzl` too. --- bazel/repositories.bzl | 10 +++++++--- update_cpp_jsonnet.sh | 11 +++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 28474e087..09be2001a 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -3,6 +3,10 @@ load( "http_archive", ) +# NB: update_cpp_jsonnet.sh looks for these. +CPP_JSONNET_SHA256 = "82d3cd35de8ef230d094b60a30e7659f415c350b0aa2bd62162cf2afdf163959" +CPP_JSONNET_GITHASH = "90cad75dcc2eafdcf059c901169d36539dc8a699" + def jsonnet_go_repositories(): http_archive( name = "io_bazel_rules_go", @@ -23,7 +27,7 @@ def jsonnet_go_repositories(): ) http_archive( name = "cpp_jsonnet", - sha256 = "82d3cd35de8ef230d094b60a30e7659f415c350b0aa2bd62162cf2afdf163959", - strip_prefix = "jsonnet-90cad75dcc2eafdcf059c901169d36539dc8a699", - urls = ["https://github.com/google/jsonnet/archive/90cad75dcc2eafdcf059c901169d36539dc8a699.tar.gz"], + sha256 = CPP_JSONNET_SHA256, + strip_prefix = "jsonnet-%s" % CPP_JSONNET_GITHASH, + urls = ["https://github.com/google/jsonnet/archive/%s.tar.gz" % CPP_JSONNET_GITHASH], ) diff --git a/update_cpp_jsonnet.sh b/update_cpp_jsonnet.sh index 954d195d5..777e22eac 100755 --- a/update_cpp_jsonnet.sh +++ b/update_cpp_jsonnet.sh @@ -8,9 +8,20 @@ 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 + +# NB: macOS sed doesn't support -i without arg. This is the easy workaround. +rm bazel/repositories.bzl.bak + set +x echo echo -e "\033[1mUpdate completed. Please check if any tests are broken and fix any encountered issues.\033[0m"