clone-and-build.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 * * * /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\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>
  43. $(echo $1 | \
  44. sed \
  45. 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g')
  46. </code></pre>
  47. </p>
  48. <p>
  49. The command produced the following standard output/error before failing:
  50. <pre $pre_style><code>
  51. $(echo $2 | \
  52. sed \
  53. 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g')
  54. </code></pre>
  55. </p>
  56. <p>
  57. <a href=https://github.com/libigl/libigl/>libigl github</a> | <a href=https://github.com/libigl/libigl/commits/master>commits</a>
  58. </p>
  59. "
  60. echo $html_content | mail -s "$subject" $recipients
  61. }
  62. # Runs the arguements as a command as usual, but if the command fails send an
  63. # email using `report_error` and exit without continuing
  64. #
  65. # guard command arg1 arg2 ...
  66. #
  67. function guard {
  68. 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. set -o xtrace
  77. # Clone repo
  78. guard rm -rf /var/tmp/libigl
  79. cd /var/tmp/
  80. guard git clone git@github.com:libigl/libigl.git
  81. cd libigl
  82. # Update subrepos
  83. guard git submodule update --init --recursive
  84. # Build static library
  85. mkdir lib
  86. cd lib
  87. # echo's make it easier to identify which cmake/make command is failing
  88. guard echo "cmake static lib" && cmake -DCMAKE_BUILD_TYPE=Release ../optional/
  89. guard echo "make static lib" && make
  90. # Build tutorial with default settings
  91. mkdir ../tutorial/build
  92. cd ../tutorial/build
  93. guard echo "cmake tutorial" && cmake -DCMAKE_BUILD_TYPE=Release ..
  94. guard echo "make tutorial" && make
  95. # Build tutorial with static library
  96. cd ../
  97. rm -rf build
  98. mkdir build
  99. cd build
  100. guard echo "cmake tutorial static" && cmake -DLIBIGL_USE_STATIC_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release ..
  101. guard echo "make tutorial static" && make