clone-and-build.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/bash
  2. # This script
  3. # - clones the libigl github repo into a temporary directory
  4. # - updates submodules
  5. # - compiles static library
  6. # - compiles tutorial
  7. # If any steps fail then an email is sent to a list of recipients (add yourself
  8. # if you'd like to be alerted to failures, see below regarding spam filters).
  9. #
  10. # You can set up an automated nightly build-check at 2:30 AM using:
  11. #
  12. # crontab -e
  13. #
  14. # and then add the line:
  15. #
  16. # 30 2 * * * source /Users/ajx/.profile; /usr/local/igl/libigl/scripts/clone-and-build.sh
  17. #
  18. # replace the path above with the **full path** to this file.
  19. #
  20. # Report that a command has failed and list its output
  21. #
  22. # report_error command output
  23. #
  24. # Note: Most mail clients will mark these messages as spam even if the local
  25. # sender (e.g. ajx@luftmatratze.local) is in your contact list. To force these
  26. # message to be not marked as spam, create a filter.
  27. #
  28. # You can test your spam settings with
  29. #
  30. # echo "t3st 3mail" | mail -s "libigl test email" youremail@gmail.com
  31. #
  32. # This will almost certainly end up in your spam, but you can find your default
  33. # email address as the sender and add a filter.
  34. #
  35. function report_error {
  36. subject="$(echo -e "libigl compilation failure: $1 \nContent-Type: text/html")"
  37. recipients="alecjacobson@gmail.com"
  38. pre_style="style='background-color: #c3e0f0; overflow: auto; padding-left: 8px; padding-right: 8px; padding-top: 4px; padding-bottom: 4px; border: 1px solid #999;'";
  39. html_content="
  40. <p>
  41. The following command failed during the last nightly libigl build:
  42. <pre $pre_style><code>$(echo -e "$1" | \
  43. sed \
  44. 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g')
  45. </code></pre>
  46. </p>
  47. <p>
  48. The command produced the following standard output/error before failing:
  49. <pre $pre_style><code>$(echo -e "$2" | \
  50. sed \
  51. 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g')
  52. </code></pre>
  53. </p>
  54. <p>
  55. <a href=https://github.com/libigl/libigl/>libigl github</a> | <a href=https://github.com/libigl/libigl/commits/master>commits</a>
  56. </p>
  57. "
  58. echo -e "$html_content" | mail -s "$subject" $recipients
  59. }
  60. # Runs the arguements as a command as usual, but if the command fails send an
  61. # email using `report_error` and exit without continuing
  62. #
  63. # guard command arg1 arg2 ...
  64. #
  65. function guard {
  66. command="$@"
  67. pwd
  68. echo "$command"
  69. if ! output=$($command 2>&1) ;
  70. then
  71. report_error "$command" "$output"
  72. echo "'$command' failed. Report sent."
  73. exit 1
  74. fi
  75. }
  76. function grep_std_1
  77. {
  78. (! grep -rI "std::__1" *)
  79. }
  80. set -o xtrace
  81. # Clone repo
  82. guard rm -rf /var/tmp/libigl
  83. cd /var/tmp/
  84. guard git clone --recursive git@github.com:libigl/libigl.git
  85. cd libigl
  86. # Build static library
  87. mkdir lib
  88. cd lib
  89. # Redundant paths make it clear which command is failing
  90. guard cmake -DCMAKE_BUILD_TYPE=Debug ../optional/
  91. guard make -C ../lib
  92. # Build tutorial with default settings
  93. mkdir ../tutorial/build
  94. cd ../tutorial/build
  95. guard cmake -DCMAKE_BUILD_TYPE=Debug ../../tutorial/
  96. guard make -C ../../tutorial/build
  97. # Build tutorial with static library
  98. cd ../
  99. mkdir build-use-static
  100. cd build-use-static
  101. guard cmake -DCMAKE_BUILD_TYPE=Debug -DLIBIGL_USE_STATIC_LIBRARY=ON ../../tutorial/
  102. guard make -C ../../tutorial/build-use-static
  103. # check that no files contain `std::__1` often coming from templates copied
  104. # from clang output. These will fail on gcc
  105. cd ../../include/igl
  106. guard grep_std_1