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 899 B

2 years ago
2 years ago
12345678910111213141516171819202122232425262728293031
  1. #! /bin/bash
  2. # WORKDIR /usr/local/PlayerCode/CAPI/cpp
  3. workdir=/usr/local/PlayerCode/CAPI/cpp
  4. bind=/usr/local/code
  5. output=/usr/local/output
  6. flag=1
  7. cd $bind
  8. file_count=$(ls -l *.cpp | wc -l);
  9. if [ $file_count -eq 1 ]
  10. then
  11. filename=$(ls *.cpp)
  12. base_name=$(basename "$filename" .cpp)
  13. cd $workdir
  14. cp -f $bind/$filename $workdir/API/src/AI.cpp
  15. cmake ./CMakeLists.txt && make -j$(nproc) >$base_name.txt 2>&1
  16. mv ./capi $output/$base_name
  17. if [ $? -eq 0 ]; then
  18. flag=0
  19. fi
  20. mv ./compile_log.txt $output/compile_log.txt
  21. else
  22. flag=0
  23. fi
  24. if [ $flag -eq 1 ]; then
  25. curl $URL -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"compile_status":"compiled"}' > $bind/curl_log.txt
  26. else
  27. curl $URL -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"compile_status":"failed"}' > $bind/curl_log.txt
  28. fi