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.2 kB

2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435
  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. pushd ../python
  18. cp -f $bind/player$i.py ./PyAPI/AI.py
  19. python3 -m compileall ./PyAPI >compile_log$i.txt 2>&1
  20. if [ ! -f ./PyAPI/__pycache__/AI.cpython-39.pyc ]; then
  21. flag=0
  22. else
  23. rm -rf ./PyAPI/__pycache__/AI.cpython-39.pyc
  24. fi
  25. mv ./compile_log$i.txt $bind/compile_log$i.txt
  26. popd
  27. fi
  28. let "i++"
  29. done
  30. # HTML request to update status.
  31. if [ $flag -eq 1 ]; then
  32. curl $URL -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"compile_status":"compiled"}' > $bind/curl_log.txt
  33. else
  34. curl $URL -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"compile_status":"failed"}' > $bind/curl_log.txt
  35. fi