You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

compile.sh 1.1 kB

2 years ago
2 years ago
12345678910111213141516171819202122232425262728293031
  1. #! /bin/bash
  2. # WORKDIR /usr/local/PlayerCode/CAPI/cpp
  3. i=1
  4. flag=1
  5. bind=/usr/local/mnt
  6. while (( $i <= 5 ))
  7. do
  8. if [ -f "${bind}/player${i}.cpp" ]; then
  9. cp -f $bind/player$i.cpp ./API/src/AI.cpp
  10. cmake ./CMakeLists.txt && make -j$(nproc) >compile_log$i.txt 2>&1
  11. mv ./capi $bind/capi$i # executable file
  12. if [ $? -ne 0 ]; then
  13. flag=0
  14. fi
  15. mv ./compile_log$i.txt $bind/compile_log$i.txt
  16. elif [ -f "${bind}/player${i}.py" ]; then
  17. cp -f $bind/player$i.py ../python/PyAPI/AI.py
  18. python3 -m compileall ../python/PyAPI
  19. mv ../python/PyAPI/__pycache__/AI.cpython-39.pyc $bind/__pycache__/AI$i.cpython-39.pyc
  20. if [ $? -ne 0 ]; then
  21. flag=0
  22. fi
  23. fi
  24. let "i++"
  25. done
  26. # HTML request to update status.
  27. if [ $flag -eq 1 ]; then
  28. curl $URL -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"compile_status":"compiled"}' > $bind/curl_log.txt
  29. else
  30. curl $URL -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"compile_status":"failed"}' > $bind/curl_log.txt
  31. fi