diff options
author | Simon Rettberg | 2018-11-23 15:06:42 +0100 |
---|---|---|
committer | Simon Rettberg | 2018-11-23 15:06:42 +0100 |
commit | d837b6ca461be3ec06d73c09475bc7ccb226137c (patch) | |
tree | 25d6e0a36ba7886d7017f1cf20108b0faf790d87 | |
parent | Improve VM descriütion file detection and parsing (diff) | |
download | master-sync-shared-d837b6ca461be3ec06d73c09475bc7ccb226137c.tar.gz master-sync-shared-d837b6ca461be3ec06d73c09475bc7ccb226137c.tar.xz master-sync-shared-d837b6ca461be3ec06d73c09475bc7ccb226137c.zip |
thrift-compile.sh: Smarter change detection
-rwxr-xr-x | thrift-compile.sh | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/thrift-compile.sh b/thrift-compile.sh index 4bc17ba..f7a6561 100755 --- a/thrift-compile.sh +++ b/thrift-compile.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if ! thrift --version | grep -q "0\.9\.3"; then echo -n "Warning! You should be using Thrift 0.9.3, but you have $(thrift --version), do you still want to continue? [y/N]: " @@ -13,19 +13,22 @@ fi echo "1) Masterserver + Satellite RPC" [ -e gen-java ] && rm -r gen-java if thrift --gen java src/main/thrift/bwlp.thrift; then - [ -e "src/main/java/org/openslx/bwlp/thrift/iface" ] && rm -rf src/main/java/org/openslx/bwlp/thrift/iface - if ! cp -r gen-java/org src/main/java/; then - echo "Error copying compiled files! Aborting!" - exit 1 - fi # reset all files where only the @Generated line changed, so we don't pollute the git history too much - for file in src/main/java/org/openslx/bwlp/thrift/iface/*.java; do - TOTAL=$(git diff "$file" | wc -l) - GENS=$(git diff "$file" | grep -E '^[\+\-]@Gen' | wc -l) - if [ "$TOTAL" = "13" -a "$GENS" = "2" ]; then - # Nothing but @Generated annotation changed - git checkout "$file" + for file in gen-java/org/openslx/bwlp/thrift/iface/*.java; do + bn=$(basename "$file") + if [ -e "src/main/java/org/openslx/bwlp/thrift/iface/$bn" ]; then + diff -q \ + <(sed -r 's/_i[0-9]+/_ix/g;s/_iter[0-9]+/_iterx/g;s/_elem[0-9]+/_elemx/g;s/_list[0-9]+/_listx/g;/@Generated/d' "$file") \ + <(sed -r 's/_i[0-9]+/_ix/g;s/_iter[0-9]+/_iterx/g;s/_elem[0-9]+/_elemx/g;s/_list[0-9]+/_listx/g;/@Generated/d' "src/main/java/org/openslx/bwlp/thrift/iface/$bn") + ret=$? + [ "$ret" = 0 ] && continue fi + cp -f "$file" "src/main/java/org/openslx/bwlp/thrift/iface/$bn" + git add "src/main/java/org/openslx/bwlp/thrift/iface/$bn" + done + for file in src/main/java/org/openslx/bwlp/thrift/iface/*.java; do + bn=$(basename "$file") + [ -e "gen-java/org/openslx/bwlp/thrift/iface/$bn" ] || git rm "$file" done fi |