3
0

build.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. coverage run --source=. -m unittest discover -s Test/
  54. coverage html
  55. coverage report -m
  56. EOF
  57. chmod +x ./code/CLI.py
  58. chmod +x ./id2t
  59. chmod +x ./run_tests
  60. echo -e "\n\nAll is set. ID2T is ready."
  61. echo -e "\nRun ID2T with the command './id2t'"