<commit_before>#!/bin/bash -e

function die() {
  echo 1>&2 $*
  exit 1
}

if [ -z "$PROTO_SRC" ]; then
  die "must set PROTO_SRC"
fi

echo 1>&2 "Checking required tools:"
for tool in protoc; do
  q=$(which $tool) || die "didn't find $tool"
  echo 1>&2 "$tool: $q"
done

dest="src/Sajari/proto"

rm -fr $dest
mkdir -p $dest

echo "$dest"
echo 1>&2 "Building protos:"
for dir in $(find $PROTO_SRC -name '*.proto' | xargs -n1 dirname | sort | uniq); do
  echo 1>&2 "- $dir"
  protoc -I$PROTO_SRC --php_out=$dest --grpc_out=$dest --plugin=protoc-gen-grpc=/Users/trent/grpc/bins/opt/grpc_php_plugin $dir/*.proto
done
<commit_msg>update generate script to work with protoc 3.3.0<commit_after>#!/bin/bash -e

function die() {
  echo 1>&2 $*
  exit 1
}

if [ -z "$PROTO_SRC" ]; then
  die "must set PROTO_SRC"
fi

if [ -z "$GRPC_PHP_PLUGIN" ]; then
  die "must set GRPC_PHP_PLUGIN"
fi

echo 1>&2 "Checking required tools:"
for tool in protoc; do
  q=$(which $tool) || die "didn't find $tool"
  echo 1>&2 "$tool: $q"
done

dest="src/Sajari/proto"

rm -r $dest
mkdir -p $dest

echo "$dest"
echo 1>&2 "Building protos:"
for dir in $(find $PROTO_SRC -name '*.proto' | xargs -n1 dirname | sort | uniq); do
  echo 1>&2 "- $dir"
  protoc -I$PROTO_SRC --php_out=$dest --grpc_out=$dest --plugin=protoc-gen-grpc=$GRPC_PHP_PLUGIN $dir/*.proto
done

{'fraction_non_alphanumeric': 0.17293233082706766, 'fraction_numerical': 0.02030075187969925, 'mean_word_length': 3.670175438596491, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2921553', 'n_tokens_mistral': 567, 'n_tokens_neox': 545, 'n_words': 164}