#!/bin/bash # _needgen is a helper function to tell if we need to generate files for msgp, codecgen. _needgen() { local a="$1" zneedgen=0 if [[ ! -e "$a" ]] then zneedgen=1 echo 1 return 0 fi for i in `ls -1 *.go.tmpl gen.go values_test.go` do if [[ "$a" -ot "$i" ]] then zneedgen=1 echo 1 return 0 fi done echo 0 } # _build generates fast-path.go and gen-helper.go. # # It is needed because there is some dependency between the generated code # and the other classes. Consequently, we have to totally remove the # generated files and put stubs in place, before calling "go run" again # to recreate them. _build() { if ! [[ "${zforce}" == "1" || "1" == $( _needgen "fast-path.generated.go" ) || "1" == $( _needgen "gen-helper.generated.go" ) || "1" == $( _needgen "gen.generated.go" ) || 1 == 0 ]] then return 0 fi # echo "Running prebuild" if [ "${zbak}" == "1" ] then # echo "Backing up old generated files" _zts=`date '+%m%d%Y_%H%M%S'` _gg=".generated.go" [ -e "gen-helper${_gg}" ] && mv gen-helper${_gg} gen-helper${_gg}__${_zts}.bak [ -e "fast-path${_gg}" ] && mv fast-path${_gg} fast-path${_gg}__${_zts}.bak # [ -e "safe${_gg}" ] && mv safe${_gg} safe${_gg}__${_zts}.bak # [ -e "unsafe${_gg}" ] && mv unsafe${_gg} unsafe${_gg}__${_zts}.bak else rm -f fast-path.generated.go gen.generated.go gen-helper.generated.go *safe.generated.go *_generated_test.go *.generated_ffjson_expose.go fi cat > gen.generated.go <> gen.generated.go < gen-dec-map.go.tmpl cat >> gen.generated.go <> gen.generated.go < gen-dec-array.go.tmpl cat >> gen.generated.go < fast-path.generated.go < gen-from-tmpl.generated.go <