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