github.com/dolthub/dolt/go@v0.40.5-0.20240520175717-68db7794bea6/serial/generate.sh (about) 1 #!/bin/bash 2 3 set -eou pipefail 4 SRC=$(dirname ${BASH_SOURCE[0]}) 5 6 GEN_DIR="$SRC/../gen/fb/serial" 7 8 # cleanup old generated files 9 if [ ! -z "$(ls $GEN_DIR)" ]; then 10 rm $GEN_DIR/*.go 11 fi 12 13 FLATC=${FLATC:-$SRC/../../proto/third_party/flatbuffers/bazel-bin/flatc} 14 15 if [ ! -x "$FLATC" ]; then 16 echo "$FLATC is not an executable. Did you remember to run 'bazel build //:flatc' in $(dirname $(dirname $FLATC))" 17 exit 1 18 fi 19 20 # generate golang (de)serialization package 21 "$FLATC" -o $GEN_DIR --gen-onefile --filename-suffix "" --gen-mutable --go-namespace "serial" --go \ 22 addressmap.fbs \ 23 blob.fbs \ 24 branchcontrol.fbs \ 25 collation.fbs \ 26 commit.fbs \ 27 commitclosure.fbs \ 28 encoding.fbs \ 29 foreign_key.fbs \ 30 mergeartifacts.fbs \ 31 prolly.fbs \ 32 rootvalue.fbs \ 33 schema.fbs \ 34 stash.fbs \ 35 stashlist.fbs \ 36 storeroot.fbs \ 37 stat.fbs \ 38 table.fbs \ 39 tag.fbs \ 40 workingset.fbs 41 42 # prefix files with copyright header 43 for FILE in $GEN_DIR/*.go; 44 do 45 mv $FILE "tmp.go" 46 cat "copyright.txt" "tmp.go" >> $FILE 47 rm "tmp.go" 48 done 49 50 cp fileidentifiers.go $GEN_DIR 51 52 # format and remove unused imports 53 goimports -w $GEN_DIR