From 8c02d17bea5def5b7006a7290a9f111433d0ab19 Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Mon, 24 Feb 2020 14:46:24 -0800 Subject: [PATCH] Skip writing reflection_generated.h if not changed (#5776) --- reflection/generate_code.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/reflection/generate_code.sh b/reflection/generate_code.sh index 0c1157d3f..f0405d5ca 100755 --- a/reflection/generate_code.sh +++ b/reflection/generate_code.sh @@ -15,4 +15,16 @@ # limitations under the License. set -e -../flatc -c --cpp-std c++0x --no-prefix -o ../include/flatbuffers reflection.fbs +tempDir="../include/flatbuffers/.tmp" +originalFile="../include/flatbuffers/reflection_generated.h" +newFile="$tempDir/reflection_generated.h" + +../flatc -c --cpp-std c++0x --no-prefix -o $tempDir reflection.fbs + +if [ -f "$newFile" ]; then + if ! cmp -s "$originalFile" "$newFile"; then + mv $newFile $original + fi + rm $newFile + rmdir $tempDir +fi \ No newline at end of file