ISEWrap.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. #
  3. # Vivado(TM)
  4. # ISEWrap.sh: Vivado Runs Script for UNIX
  5. # Copyright 1986-2022 Xilinx, Inc. All Rights Reserved.
  6. # Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.
  7. #
  8. cmd_exists()
  9. {
  10. command -v "$1" >/dev/null 2>&1
  11. }
  12. HD_LOG=$1
  13. shift
  14. # CHECK for a STOP FILE
  15. if [ -f .stop.rst ]
  16. then
  17. echo "" >> $HD_LOG
  18. echo "*** Halting run - EA reset detected ***" >> $HD_LOG
  19. echo "" >> $HD_LOG
  20. exit 1
  21. fi
  22. ISE_STEP=$1
  23. shift
  24. # WRITE STEP HEADER to LOG
  25. echo "" >> $HD_LOG
  26. echo "*** Running $ISE_STEP" >> $HD_LOG
  27. echo " with args $@" >> $HD_LOG
  28. echo "" >> $HD_LOG
  29. # LAUNCH!
  30. $ISE_STEP "$@" >> $HD_LOG 2>&1 &
  31. # BEGIN file creation
  32. ISE_PID=$!
  33. HostNameFile=/proc/sys/kernel/hostname
  34. if cmd_exists hostname
  35. then
  36. ISE_HOST=$(hostname)
  37. elif cmd_exists uname
  38. then
  39. ISE_HOST=$(uname -n)
  40. elif [ -f "$HostNameFile" ] && [ -r $HostNameFile ] && [ -s $HostNameFile ]
  41. then
  42. ISE_HOST=$(cat $HostNameFile)
  43. elif [ X != X$HOSTNAME ]
  44. then
  45. ISE_HOST=$HOSTNAME #bash
  46. else
  47. ISE_HOST=$HOST #csh
  48. fi
  49. ISE_USER=$USER
  50. ISE_HOSTCORE=$(awk '/^processor/{print $3}' /proc/cpuinfo | wc -l)
  51. ISE_MEMTOTAL=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
  52. ISE_BEGINFILE=.$ISE_STEP.begin.rst
  53. /bin/touch $ISE_BEGINFILE
  54. echo "<?xml version=\"1.0\"?>" >> $ISE_BEGINFILE
  55. echo "<ProcessHandle Version=\"1\" Minor=\"0\">" >> $ISE_BEGINFILE
  56. echo " <Process Command=\"$ISE_STEP\" Owner=\"$ISE_USER\" Host=\"$ISE_HOST\" Pid=\"$ISE_PID\" HostCore=\"$ISE_HOSTCORE\" HostMemory=\"$ISE_MEMTOTAL\">" >> $ISE_BEGINFILE
  57. echo " </Process>" >> $ISE_BEGINFILE
  58. echo "</ProcessHandle>" >> $ISE_BEGINFILE
  59. # WAIT for ISEStep to finish
  60. wait $ISE_PID
  61. # END/ERROR file creation
  62. RETVAL=$?
  63. if [ $RETVAL -eq 0 ]
  64. then
  65. /bin/touch .$ISE_STEP.end.rst
  66. else
  67. /bin/touch .$ISE_STEP.error.rst
  68. fi
  69. exit $RETVAL