autoexplicit.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. # Usage:
  3. # make 2>&1 | autoexplicit.sh
  4. # process input line by line
  5. while read line; do
  6. if ! echo "$line" | grep -q "^\".*\", referenced from:$"
  7. then
  8. # undefined symbol line not found
  9. continue
  10. fi
  11. symbol=`echo "$line" | sed -e "s/^\"\(.*\)\", referenced from:$/\1/"`
  12. #echo "symbol = $symbol"
  13. filename=`echo "$symbol" | perl -pe "s#.*?igl::([A-z0-9_]*).*$'$'#\1#"`
  14. #echo "filename = $filename"
  15. cpp="$filename.cpp"
  16. # append .cpp and check that file exists
  17. if [ ! -e "$cpp" ]
  18. then
  19. echo "Warning: $cpp does not exist, skipping ..."
  20. continue
  21. fi
  22. if ! grep -q "^\/\/ Explicit template specialization*$" "$cpp"
  23. then
  24. echo "Warning: skipping $cpp because it does not match ^\/\/ Explicit template specialization*$ "
  25. continue;
  26. fi
  27. before=`sed '/^\/\/ Explicit template specialization$/q' "$cpp"`;
  28. #echo "before = $before"
  29. after=`sed '1,/^\/\/ Explicit template specialization$/d' $cpp`;
  30. #echo "after = $after"
  31. explicit="template $symbol;"
  32. #echo "$explicit"
  33. if grep -F "$explicit" "$cpp"
  34. then
  35. echo "Error: $cpp already contains $explicit"
  36. echo " Recompile igl static lib, recompile your project, and try again."
  37. continue
  38. fi
  39. echo "$before" > "$cpp"
  40. echo "// generated by autoexplicit.sh" >> "$cpp"
  41. echo "$explicit" >> "$cpp"
  42. echo "$after" >> "$cpp"
  43. done