From 68ffe90dd9229719e268df04adb01bab24bac4e4 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Mon, 16 Dec 2024 16:05:47 +1100 Subject: [PATCH] fix: make protoc-gen-prost work (#3772) 1. Redirect stdout to stderr so we don't break the protoc plugin protocol 2. Use a file lock to avoid multiple concurrent invocations of protoc-gen-prost running cargo install many times --- backend/protos/buf.gen.yaml | 8 ++++---- scripts/protoc-gen-prost | 17 ++++++++++++++--- scripts/update-roadmap-issues | 7 ++++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/backend/protos/buf.gen.yaml b/backend/protos/buf.gen.yaml index 889fbfcace..b20b039648 100644 --- a/backend/protos/buf.gen.yaml +++ b/backend/protos/buf.gen.yaml @@ -16,7 +16,7 @@ plugins: out: ../../python-runtime/ftl/src/ftl/protos opt: - pyi_out=../../python-runtime/ftl/src/ftl/protos -# - plugin: prost -# out: ../../sqlc-gen-ftl/src/protos -# opt: -# - bytes=. + - plugin: prost + out: ../../sqlc-gen-ftl/src/protos + opt: + - bytes=. diff --git a/scripts/protoc-gen-prost b/scripts/protoc-gen-prost index d23952b803..eeff95117c 100755 --- a/scripts/protoc-gen-prost +++ b/scripts/protoc-gen-prost @@ -2,12 +2,23 @@ set -euo pipefail if [ ! "${HERMIT_ENV:-}" ]; then - # shellcheck disable=SC1091 - . "$(dirname "$(dirname "$0")")/bin/activate-hermit" + # shellcheck disable=SC1091 + . "$(dirname "$(dirname "$0")")/bin/activate-hermit" > /dev/null 2>&1 fi + +function flockexec() { + file="$1" + shift + if [ "$(uname)" = "Darwin" ]; then + lockf -t 120 "$file" "$@" + else + flock -w 120 "$file" "$@" + fi +} + # Ensure the binary exists, install if it doesn't -mk "${HERMIT_ENV}/.hermit/rust/bin/protoc-gen-prost" : -- cargo install protoc-gen-prost +flockexec /tmp/protoc-gen-prost.lock mk "${HERMIT_ENV}/.hermit/rust/bin/protoc-gen-prost" : -- cargo install protoc-gen-prost 1>&2 # Execute the binary with any passed arguments exec "${HERMIT_ENV}/.hermit/rust/bin/protoc-gen-prost" "$@" diff --git a/scripts/update-roadmap-issues b/scripts/update-roadmap-issues index bebb583775..9b0a77932c 100755 --- a/scripts/update-roadmap-issues +++ b/scripts/update-roadmap-issues @@ -1,7 +1,8 @@ #!/bin/bash +set -euo pipefail -label="$1" -issue_number="$2" +label="${1:-}" +issue_number="${2:-}" if [ -z "$label" ] || [ -z "$issue_number" ]; then echo "Error: Both label and issue number must be provided." echo "Usage: $0