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 * * * 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. sleep 2
  70. if ! output=$($command 2>&1) ;
  71. then
  72. report_error "$command" "$output"
  73. echo "'$command' failed. Report sent."
  74. exit 1
  75. fi
  76. }
  77. set -o xtrace
  78. # Clone repo
  79. guard rm -rf /var/tmp/libigl
  80. cd /var/tmp/
  81. guard git clone git@github.com:libigl/libigl.git
  82. cd libigl
  83. # Update subrepos
  84. guard git submodule update --init --recursive
  85. # Build static library
  86. mkdir lib
  87. cd lib
  88. # Redundant paths make it clear which command is failing
  89. guard cmake -DCMAKE_BUILD_TYPE=Debug ../optional/
  90. guard make -C ../lib
  91. # Build tutorial with default settings
  92. mkdir ../tutorial/build
  93. cd ../tutorial/build
  94. guard cmake -DCMAKE_BUILD_TYPE=Debug ../../tutorial/
  95. guard make -C ../../tutorial/build
  96. # Build tutorial with static library
  97. cd ../
  98. mkdir build-use-static
  99. cd build-use-static
  100. guard cmake -DCMAKE_BUILD_TYPE=Debug -DLIBIGL_USE_STATIC_LIBRARY=ON ../../tutorial/
  101. guard make -C ../../tutorial/build-use-static