Team Fortress 2 Source Code as on 22/4/2020
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.

113 lines
2.9 KiB

  1. :: //
  2. :: // Batch file to build .py & .cpp modules from swig.i source files
  3. :: //
  4. :: // SYNTAX: swig_python.cmd file srcdir outdir pythonver
  5. :: //
  6. :: // EXAMPLE: swig_python.cmd base.i ..\..\.. d:\dev\main\game\sdktools\python\site-packages\vs pythonver 2.5
  7. :: //
  8. @echo off
  9. setlocal
  10. :: // Make sure we have 4 args
  11. if .%1.==.. (
  12. goto Usage
  13. )
  14. if .%2.==.. (
  15. goto Usage
  16. )
  17. if .%3.==.. (
  18. goto Usage
  19. )
  20. if .%4.==.. (
  21. goto Usage
  22. )
  23. :Main
  24. set SWIGFILE=%1%
  25. set SRCDIR=%2%
  26. set OUTDIR=%3%
  27. set PYTHONVER=%4%
  28. set SWIG=%SRCDIR%\devtools\swigwin-1.3.34\swig.exe
  29. set SWIGDIR=swig_python%PYTHONVER%
  30. set SWIGC=%SWIGFILE%_wrap_python%PYTHONVER%.cpp
  31. set DIFF=%SRCDIR%\devtools\bin\diff.exe -q
  32. set P4EDIT=%SRCDIR%\vpc_scripts\valve_p4_edit.cmd
  33. :: // Check to see if things don't exist and issue inteligible error messages
  34. if NOT EXIST %SWIG% goto NoSwig
  35. if NOT EXIST %DIFF% goto NoDiff
  36. :: // Make the output directory if necessary
  37. if NOT EXIST %SWIGDIR% mkdir %SWIGDIR%
  38. if NOT EXIST %SWIGDIR% goto NoSwigDir
  39. if EXIST %SWIGC% attrib -R %SWIGC%
  40. echo *** [swig_python] %SWIG% -small -Fmicrosoft -ignoremissing -c++ -Iswig_python%PYTHONVER% -I%SRCDIR%\public -o "%SWIGC%" -outdir "%SWIGDIR%" -python "%SWIGFILE%.i" ***
  41. call %SWIG% -small -Fmicrosoft -ignoremissing -c++ -Iswig_python%PYTHONVER% -I%SRCDIR%\public -o "%SWIGC%" -outdir "%SWIGDIR%" -python "%SWIGFILE%.i"
  42. if ERRORLEVEL 1 goto SwigFailed
  43. if EXIST %SWIGC% attrib -R %SWIGC%
  44. if NOT EXIST "%SWIGDIR%\%SWIGFILE%.py" echo "Can't Find diff SRC %SWIGDIR%\%SWIGFILE%.py"
  45. if NOT EXIST "%OUTDIR%\%SWIGFILE%.py" echo "Can't Find diff DST %OUTDIR%\%SWIGFILE%.py"
  46. echo *** [swig_python] %DIFF% "%SWIGDIR%\%SWIGFILE%.py" "%OUTDIR%\%SWIGFILE%.py" ***
  47. call %DIFF% "%SWIGDIR%\%SWIGFILE%.py" "%OUTDIR%\%SWIGFILE%.py" > NUL:
  48. if ERRORLEVEL 1 goto CopyPy
  49. goto EndOk
  50. :CopyPy
  51. echo *** [swig_python] %P4EDIT% %OUTDIR%\%SWIGFILE%.py %SRCDIR% ***
  52. call %P4EDIT% %OUTDIR%\%SWIGFILE%.py %SRCDIR%
  53. if ERRORLEVEL 1 goto P4Failed
  54. echo *** [swig_python] "%SWIGDIR%\%SWIGFILE%.py" "%OUTDIR%\%SWIGFILE%.py" ***
  55. call copy "%SWIGDIR%\%SWIGFILE%.py" "%OUTDIR%\%SWIGFILE%.py" > NUL:
  56. if ERRORLEVEL 1 goto CopyFailed
  57. :EndOk
  58. echo *** [swig_python] Swig Complete!
  59. endlocal
  60. exit /b 0
  61. :Usage
  62. echo *** [swig_python] Error calling command! No file specified for swig! Usage: swig_python.cmd file srcdir outdir pythonver
  63. endlocal
  64. exit 1
  65. :SwigFailed
  66. echo *** [swig_python] swig command failed
  67. goto EndError
  68. :P4Failed
  69. echo *** [swig_python] ERROR: %P4EDIT% %OUTDIR%\%SWIGFILE%.py %SRCDIR%
  70. goto EndError
  71. :CopyFailed
  72. echo *** [swig_python] ERROR: copy "%SWIGDIR%\%SWIGFILE%.py" "%OUTDIR%\%SWIGFILE%.py"
  73. goto EndError
  74. :NoSwig
  75. echo *** [swig_python] ERROR: Can't Find SWIG executable "%SWIG%", ensure src/devtools is synced
  76. goto EndError
  77. :NoDiff
  78. echo *** [swig_python] ERROR: Can't Find DIFF executable "%DIFF%", ensure src/devtools is synced
  79. goto EndError
  80. :NoSwigDir
  81. echo *** [swig_python] ERROR: Can't Find Or Create Swig Intermediate Directory "%SWIGDIR%"
  82. goto EndError
  83. :EndError
  84. endlocal
  85. exit 1