3
0

build.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. # Install required packages
  3. if [ "$1" != '--non-interactive' ]; then
  4. ./resources/install_dependencies.sh
  5. fi
  6. # Create the Makefile using cmake, from a clean build directory
  7. cd code_boost/src/build/
  8. if [ ${PWD##*/} = 'build' ]; then
  9. # Only delete everything if we are in a folder called 'build'.
  10. rm -rf ./*
  11. else
  12. echo "Error: The 'build' directory was not found."
  13. exit
  14. fi
  15. cmake ..
  16. if [ -f Makefile ]; then
  17. make
  18. else
  19. echo "Error: 'cmake' did not finish successfully."
  20. exit
  21. fi
  22. if [ $? -eq 0 ]; then
  23. cp libpcapreader.so ../../../code/ID2TLib/
  24. else
  25. echo "Error: 'make' did not finish successfully."
  26. exit
  27. fi
  28. cd ../../../
  29. # Create the ID2T script
  30. cat >./id2t <<EOF
  31. #!/bin/sh
  32. # Find the executable
  33. if [ $(uname) = 'Darwin' ]; then
  34. alias readlink='greadlink'
  35. fi
  36. ID2T_DIR=\$(readlink -f \$0)
  37. SCRIPT_PATH=\${ID2T_DIR%/*}
  38. cd \$SCRIPT_PATH
  39. # Execute ID2T
  40. exec ./code/CLI.py "\$@"
  41. EOF
  42. # Create the test script
  43. cat >./run_tests <<EOF
  44. #!/bin/sh
  45. # Find the executable
  46. if [ $(uname) = 'Darwin' ]; then
  47. alias readlink='greadlink'
  48. fi
  49. ID2T_DIR=\$(readlink -f \$0)
  50. SCRIPT_PATH=\${ID2T_DIR%/*}
  51. cd \$SCRIPT_PATH/code
  52. # Execute tests
  53. set -e
  54. PYTHONWARNINGS="ignore" coverage run --source=. -m unittest discover -s Test/ >/dev/null
  55. coverage html
  56. coverage report -m
  57. EOF
  58. chmod +x ./code/CLI.py
  59. chmod +x ./id2t
  60. chmod +x ./run_tests
  61. echo -e "\n\nAll is set. ID2T is ready."
  62. echo -e "\nRun ID2T with the command './id2t'"