autoexplicit.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. filename=`echo "$filename" | sed -e "s/::/\//g"`
  16. #echo "filename = $filename"
  17. cpp="$LIBIGL/include/igl/$filename.cpp"
  18. # append .cpp and check that file exists
  19. if [ ! -e "$cpp" ]
  20. then
  21. echo "Warning: $cpp does not exist, skipping ..."
  22. continue
  23. fi
  24. if ! grep -q "^\/\/ Explicit template specialization*$" "$cpp"
  25. then
  26. echo "Warning: skipping $cpp because it does not match ^\/\/ Explicit template specialization*$ "
  27. continue;
  28. fi
  29. before=`sed '/^\/\/ Explicit template specialization$/q' "$cpp"`;
  30. #echo "before = $before"
  31. after=`sed '1,/^\/\/ Explicit template specialization$/d' $cpp`;
  32. #echo "after = $after"
  33. explicit="template $symbol;"
  34. #echo "$explicit"
  35. if grep -F "$explicit" "$cpp"
  36. then
  37. echo "Error: $cpp already contains $explicit"
  38. echo " Recompile igl static lib, recompile your project, and try again."
  39. continue
  40. fi
  41. echo "$before" > "$cpp"
  42. echo "// generated by autoexplicit.sh" >> "$cpp"
  43. echo "$explicit" >> "$cpp"
  44. echo "$after" >> "$cpp"
  45. done