forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.bat
More file actions
235 lines (199 loc) · 7.15 KB
/
compile.bat
File metadata and controls
235 lines (199 loc) · 7.15 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
@echo off
:: It's best to always call with a flag that specifies python
:: version and architecture (eg. --py27-32bit). This will ensure
:: that PATH contains only minimum set of directories and will
:: allow to detect possible issues early.
:: Arguments
if [%1] == [] (
echo [compile.bat] Version number not provided. Usage: compile.bat 31.0
echo [compile.bat] Opt: --rebuild --py27-32bit --py27-64bit --py34-32bit
echo --py34-64bit
exit /B 1
)
:: --rebuild flag to rebuild all vcproj builds
set rebuild_flag=0
echo.%*|findstr /C:"--rebuild" >nul 2>&1
if %errorlevel% equ 0 (
set rebuild_flag=1
)
:: Add only Python/ to PATH.
:: --py27-32bit flag
echo.%*|findstr /C:"--py27-32bit" >nul 2>&1
if %errorlevel% equ 0 (
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Python27
)
:: --py27-64bit flag
echo.%*|findstr /C:"--py27-64bit" >nul 2>&1
if %errorlevel% equ 0 (
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Python27_x64;C:\Python27_amd64;C:\Python27_64
)
:: --py34-32bit flag
echo.%*|findstr /C:"--py34-32bit" >nul 2>&1
if %errorlevel% equ 0 (
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Python34
)
:: --py34-64bit flag
echo.%*|findstr /C:"--py34-64bit" >nul 2>&1
if %errorlevel% equ 0 (
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Python34_x64;C:\Python34_amd64;C:\Python34_64
)
:: PATH
echo [compile.bat] PATH: %PATH%
:: Version number
set version=%1
echo [compile.bat] Version argument: %version%
:: Python architecture. %bits%=="32bit" or "64bit"
FOR /F "delims=" %%i IN ('python -c "import struct, sys; sys.stdout.write(str(8 * struct.calcsize('P')) + 'bit');"') do set bits=%%i
echo [compile.bat] Python architecture: %bits%
:: Cython version
FOR /F "delims=" %%i IN ('python -c "import sys, Cython; sys.stdout.write(Cython.__version__);"') do set cython_version=%%i
echo [compile.bat] Cython version: %cython_version%
:: Python version
for /F %%i in ('python -c "import sys; sys.stdout.write(str(sys.version_info[0])+str(sys.version_info[1]));"') do set pyver=%%i
echo [compile.bat] Python version: py%pyver%
:: Binaries directory
set binaries=%~dp0binaries_%bits%
echo [compile.bat] Binaries directory: %binaries%
:: Setup directory
set setup=%~dp0setup
echo [compile.bat] Setup directory: %setup%
:: Delete .pyd files
echo [compile.bat] Cleaning cython build files from previous run
del "%binaries%\cefpython_py%pyver%.pyd"
del "%setup%\cefpython_py%pyver%.pyd"
for /R %setup% %%f in (*.pyx) do del "%%f"
rmdir /S /Q "%setup%\build\"
:: Fix cefpython.h
echo [compile.bat] Fixing cefpython.h
cd %setup%
python fix_cefpython_h.py
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: failed to fix cefpython.h
cd ../
exit /B 1
)
cd ../
:: Compile VS projects: client_handler, libcefpythonapp, subprocess, cpp_utils
:: client_handler paths
set client_handler_dir=%~dp0..\client_handler
set client_handler_vcproj=%client_handler_dir%\client_handler_py%pyver%_%bits%.vcproj
set subprocess_dir=%~dp0..\subprocess
:: libcefpythonapp paths
set libcefpythonapp_vcproj=%subprocess_dir%\libcefpythonapp_py%pyver%_%bits%.vcproj
:: subprocess paths
set subprocess_vcproj=%subprocess_dir%\subprocess_%bits%.vcproj
:: cpp_utils paths
set cpp_utils_dir=%~dp0..\..\cpp_utils
set cpp_utils_vcproj=%cpp_utils_dir%\cpp_utils_%bits%.vcproj
set success=0
if "%pyver%"=="27" (
if "%bits%"=="32bit" (
set "vcbuild=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe"
set success=1
)
if "%bits%"=="64bit" (
REM :: The same vcbuild.exe 32-bit for building x64
set "vcbuild=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe"
set success=1
)
set "vcoptions=/nocolor /nologo /nohtmllog"
if %rebuild_flag% equ 1 (
set "vcoptions=%vcoptions% /rebuild"
)
)
if "%pyver%"=="34" (
:: In VS2010 vcbuild was replaced by msbuild.exe.
:: /clp:disableconsolecolor
:: msbuild /p:BuildProjectReferences=false project.proj
:: MSBuild.exe MyProject.proj /t:build
)
if %success% neq 1 (
echo [compile.bat] ERROR: failed determining tool to build vcproj files
exit /B 1
)
echo [compile.bat] Building client_handler vcproj
"%vcbuild%" %vcoptions% %client_handler_vcproj%
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: building client_handler vcproj failed
exit /B 1
)
echo [compile.bat] Building libcefpythonapp vcproj
"%vcbuild%" %vcoptions% %libcefpythonapp_vcproj%
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: building libcefpythonapp vcproj failed
exit /B 1
)
echo [compile.bat] Building subprocess vcproj
"%vcbuild%" %vcoptions% %subprocess_vcproj%
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: building subprocess vcproj failed
exit /B 1
)
echo [compile.bat] Building cpp_utils vcproj
"%vcbuild%" %vcoptions% %cpp_utils_vcproj%
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: building cpp_utils vcproj failed
exit /B 1
)
:: Do not clean VS build files, as this would slow down the process
:: of recompiling.
:: Compile .rc file to a .res object.
echo [compile.bat] Compiling cefpython.rc file to a .res object
cd %setup%\
python compile_rc.py -v %version%
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: compiling .rc file failed
exit /B 1
)
echo [compile.bat] Entering setup/ directory
cd %setup%
echo [compile.bat] Copying .pyx files to setup/ directory and fixing includes
python fix_pyx_files.py
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: running fix_pyx_files.py failed
exit /B 1
)
:: __version__.pyx must be generated after running fix_pyx_files.py,
:: as that script deletes old pyx files before copying new ones.
echo [compile.bat] Creating __version__.pyx file
echo __version__ = "%version%">>__version__.pyx
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: writing __version__.pyx failed
exit /B 1
)
echo [compile.bat] Running the cython setup.py script
python setup.py build_ext --inplace
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: the cython setup.py script failed
:: Clean files from the build that failed
for /R %setup% %%f in (*.pyx) do del "%%f"
for /R %setup% %%f in (*.res) do del "%%f"
rmdir /S /Q "%setup%\build\"
cd ../
exit /B 1
)
echo [compile.bat] Fixing cefpython.h
python fix_cefpython_h.py
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: failed to fix cefpython.h
exit /B 1
)
echo [compile.bat] Cleaning files from the build
for /R %setup% %%f in (*.pyx) do del "%%f"
for /R %setup% %%f in (*.res) do del "%%f"
rmdir /S /Q "%setup%\build\"
echo [compile.bat] Moving the pyd module to the binaries directory
move "%setup%\cefpython_py%pyver%.pyd" "%binaries%/cefpython_py%pyver%.pyd"
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: Moving the pyd module failed
exit /B 1
)
echo [compile.bat] Copying subprocess.exe to the binaries directory
copy "%~dp0..\subprocess\Release_%bits%\subprocess_%bits%.exe" "%binaries%\subprocess.exe"
if %errorlevel% neq 0 (
echo [compile.bat] ERROR: Copying subprocess.exe failed
exit /B 1
)
echo [compile.bat] Everything went OK. Running the wxpython.py example..
cd %binaries%
python wxpython.py & cd ../