autoexplicit.sh 1.4 KB

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