Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.7 KiB

  1. @echo off
  2. setlocal
  3. set valveTmpFileFromVS2005=%1%
  4. set valveTmpFileFromVS2005=%valveTmpFileFromVS2005:\\=\%
  5. set valveChangelistName="Visual Studio Auto Checkout"
  6. :: // Make sure we have 2 args
  7. if .%2.==.. (
  8. echo *** [valve_p4_edit] Error calling command! No file specified for checkout!
  9. echo *** Usage: valve_p4_edit.cmd file srcdir ["changelist name"]
  10. echo *** The changelist name is optional. If present, must be quoted. By default it's %valveChangelistName%.
  11. endlocal
  12. exit /b 1
  13. )
  14. if [%3] NEQ [] (
  15. set valveChangelistName=%3
  16. )
  17. :: // Fallback to old functionality and just change file attribs
  18. if NOT "%VALVE_NO_AUTO_P4%"=="" (
  19. echo [valve_p4_edit] VALVE_NO_AUTO_P4 defined. Changing file attribs only!
  20. if EXIST %valveTmpFileFromVS2005% (
  21. attrib -r %valveTmpFileFromVS2005%
  22. )
  23. endlocal
  24. exit /b 0
  25. )
  26. rem // :: // First check if file exists
  27. rem // if NOT EXIST %valveTmpFileFromVS2005% (
  28. rem // :: // File does not exist
  29. rem // rem // echo [valve_p4_edit] %valveTmpFileFromVS2005% does not exist! Skipping p4 edit command.
  30. rem // endlocal
  31. rem // exit /b 0
  32. rem // )
  33. rem //
  34. rem // :: // Check if file is read-only (NOTE: If the file is writable, we don't call p4!)
  35. rem // dir /b /ar %valveTmpFileFromVS2005% >nul 2>&1
  36. rem // if NOT %ERRORLEVEL%==0 (
  37. rem // rem // echo [valve_p4_edit] %valveTmpFileFromVS2005% is already writable. Not calling p4 edit.
  38. rem // endlocal
  39. rem // exit /b 0
  40. rem // )
  41. :: // Put 360 bins into their own changelist
  42. for /f %%A in ('echo %valveTmpFileFromVS2005% ^| find /i "360"') do set valveTmpIs360=%%A
  43. if NOT "%valveTmpIs360%"=="" (
  44. set valveChangelistName="360 Visual Studio Auto Checkout"
  45. )
  46. for /f %%A in ('echo %valveTmpFileFromVS2005% ^| find /i "launcher_main"') do set valveTmpIs360=%%A
  47. if NOT "%valveTmpIs360%"=="" (
  48. set valveChangelistName="360 Visual Studio Auto Checkout"
  49. )
  50. set valveP4EditCall=%2\devtools\bin\valve_p4_edit_to_changelist.cmd %valveTmpFileFromVS2005% %valveChangelistName%
  51. if "%VALVE_WAIT_ON_P4%"=="" (
  52. :: // The file exists and is read-only, so change the file attrib and spawn the Perforce checkout asynchronously
  53. if EXIST %valveTmpFileFromVS2005% attrib -r %valveTmpFileFromVS2005%
  54. start /b cmd /c %valveP4EditCall% EXIT
  55. rem // (NOTE: The EXIT arg is needed because we're using the start command to launch the cmd!)
  56. ) ELSE (
  57. :: // Do not use attrib -r if we're doing synchronous p4 edit. If this fails, we want to throw an error below
  58. call %valveP4EditCall%
  59. )
  60. :: // Make sure file is writable if it exists
  61. if NOT EXIST %valveTmpFileFromVS2005% goto End
  62. dir /b /a-r %valveTmpFileFromVS2005% >nul 2>&1
  63. if NOT %ERRORLEVEL%==0 (
  64. :: // Return with an error to stop the build!
  65. echo *** [valve_p4_edit] Error! %valveTmpFileFromVS2005% is not writable!
  66. endlocal
  67. exit /b 1
  68. )
  69. :End
  70. endlocal
  71. exit /b 0