build.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. echo "$1 ($2, $3)..."
  3. make clean 1>/dev/null 2>/dev/null
  4. echo -n "building..."
  5. if [ -f /proc/cpuinfo ]
  6. then
  7. MAKE_JOBS=$(( ($(cat /proc/cpuinfo | grep -E '^processor[[:space:]]*:' | tail -n -1 | cut -d':' -f2) + 1) * 2 + 1 ))
  8. else
  9. MAKE_JOBS=8
  10. fi
  11. CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" make -j$MAKE_JOBS -f $3 all_test 1>gcc_1.txt 2>gcc_2.txt
  12. mret=$?
  13. cnt=$(wc -l < gcc_2.txt)
  14. # ignore 1 line since ar prints to stderr instead of stdout and ar is called for
  15. # $(LIBNAME)
  16. if [[ $mret -ne 0 ]] || [[ $cnt -gt 1 ]]; then
  17. echo "build $1 failed! printing gcc_2.txt now for convenience"
  18. cat gcc_2.txt
  19. exit 1
  20. fi
  21. # remove the standard arguments from the make options
  22. opts=${3//makefile.shared/}
  23. opts=${opts//makefile/}
  24. opts=${opts//V=1/}
  25. opts=${opts//COVERAGE=1/}
  26. opts=$(echo $opts | tr -d '[:space:]')
  27. # if there's something else than the standard arguments we check if we're currently
  28. # building a Travis PR and if it's like that, we skip those tests
  29. if [ ! -z "$opts" ]; then
  30. if [ ! -z "$TRAVIS_PULL_REQUEST" ] && [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
  31. echo "PR Tests skipped" | tee testok.txt
  32. exit 0
  33. fi
  34. fi
  35. echo -n "testing..."
  36. if [ -a test ] && [ -f test ] && [ -x test ]; then
  37. ((./test >test_std.txt 2>test_err.txt && ./tv_gen > tv.txt) && echo "$1 test passed." && echo "y" > testok.txt) || (echo "$1 test failed, look at test_err.txt or tv.txt" && exit 1)
  38. if find *_tv.txt -type f 1>/dev/null 2>/dev/null ; then
  39. for f in *_tv.txt; do
  40. # check for lines starting with '<' ($f might be a subset of notes/$f)
  41. difftroubles=$(diff -i -w -B $f notes/$f | grep '^<')
  42. if [ -n "$difftroubles" ]; then
  43. echo "FAILURE: $f"
  44. diff -i -w -B $f notes/$f
  45. echo "tv_gen $f failed" && rm -f testok.txt && exit 1
  46. else
  47. true
  48. fi
  49. done
  50. fi
  51. fi
  52. if [ -a testok.txt ] && [ -f testok.txt ]; then
  53. if [ "$LTC_COVERAGE" != "" ]; then
  54. bash .ci/coverage_more.sh > test_coverage_more.txt || exit 1
  55. lcov_opts="--capture --no-external --directory src -q"
  56. lcov_out=$(echo coverage_$1_$2_$3 | tr ' -=+' '_')".info"
  57. lcov $lcov_opts --output-file $lcov_out
  58. fi
  59. exit 0
  60. fi
  61. exit 1