Skip to content

Commit 906c7e7

Browse files
author
redxii1234
committed
Compile scripts v2
1 parent 9816a95 commit 906c7e7

5 files changed

+532
-0
lines changed

clean_windows2.cmd

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
set olddir=%CD%
2+
3+
cd dxlist
4+
mingw32-make distclean
5+
6+
cd ..\zlib
7+
mingw32-make -fwin32\makefile.gcc clean
8+
9+
cd ..\src
10+
mingw32-make distclean
11+
12+
cd ..
13+
del setup\scripts\win32inst_vars.cmd
14+
del src\translations\smplayer_*.qm
15+
del src\object_script.smplayer.Release
16+
del src\object_script.smplayer.Debug
17+
del src\svn_revision.h
18+
rd dxlist\release
19+
rd dxlist\debug
20+
rd src\release
21+
rd src\debug

compile_all.cmd

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
call clean_windows2.cmd
2+
call compile_windows2.cmd
3+
call clean_windows2.cmd
4+
call compile_windows2.cmd -portable -noupdate
5+
call clean_windows2.cmd

compile_windows2.cmd

+257
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
@echo off
2+
3+
:: Reset working dir especially when using 'Run as administrator'
4+
@cd /d "%~dp0"
5+
6+
:: ::
7+
:: Command-line Parsing ::
8+
:: ::
9+
10+
set start_dir=%~dp0
11+
12+
set build_themes=yes
13+
set build_skins=yes
14+
set build_pe=
15+
set runinstcmd=yes
16+
set runsvnup=yes
17+
18+
set qmake_defs=
19+
set use_svn_revision=
20+
21+
set config_file=setup\scripts\win32inst_vars.cmd
22+
23+
:: Default prefix
24+
for /f %%i in ("setup") do set BUILD_PREFIX=%%~fi
25+
26+
:: Default source dirs
27+
set SMPLAYER_SKINS_DIR=..\smplayer-skins
28+
set SMPLAYER_THEMES_DIR=..\smplayer-themes
29+
30+
rem set SMPLAYER_SKINS_DIR=..\..\smplayer-skins\trunk
31+
rem set SMPLAYER_THEMES_DIR=..\..\smplayer-themes\trunk
32+
33+
:cmdline_parsing
34+
if "%1" == "" goto build_env_info
35+
if "%1" == "-h" goto usage
36+
if "%1" == "-prefix" goto prefixTag
37+
if "%1" == "-nothemes" goto cfgThemes
38+
if "%1" == "-noskins" goto cfgSkins
39+
if "%1" == "-noinst" goto cfgInst
40+
if "%1" == "-noupdate" goto cfgUpdate
41+
if "%1" == "-portable" goto cfgPE
42+
43+
echo Unknown option: "%1"
44+
echo.
45+
goto usage
46+
47+
:usage
48+
echo Usage: compile_windows2.cmd [-prefix (dir)]
49+
echo [-portable]
50+
echo [-noinst] [-nothemes] [-noskins] [-noupdate]
51+
echo.
52+
echo Configuration:
53+
echo -h display this help and exit
54+
echo.
55+
echo -prefix (dir) prefix directory for installation
56+
echo (default prefix: %build_prefix%)
57+
echo.
58+
echo Optional Features:
59+
echo -portable Compile portable executables
60+
echo.
61+
echo Miscellaneous Options:
62+
echo -noinst Do not run installation script
63+
echo -nothemes Do not compile themes
64+
echo -noskins Do not compile skins
65+
echo -noupdate Do not update before compiling
66+
echo.
67+
goto end
68+
69+
:prefixTag
70+
71+
shift
72+
set build_prefix=%1
73+
shift
74+
75+
goto cmdline_parsing
76+
77+
:cfgPE
78+
79+
set qmake_defs=%qmake_defs% PORTABLE_APP
80+
set build_pe=yes
81+
set build_themes=
82+
set build_skins=
83+
set runinstcmd=
84+
shift
85+
86+
goto cmdline_parsing
87+
88+
:cfgInst
89+
90+
set runinstcmd=
91+
shift
92+
93+
goto cmdline_parsing
94+
95+
:cfgUpdate
96+
set runsvnup=
97+
shift
98+
99+
goto cmdline_parsing
100+
101+
:cfgThemes
102+
set build_themes=
103+
shift
104+
105+
goto cmdline_parsing
106+
107+
:cfgSkins
108+
set build_skins=
109+
shift
110+
111+
goto cmdline_parsing
112+
113+
:: ::
114+
:: Build Environment Info ::
115+
:: ::
116+
117+
:build_env_info
118+
119+
:: Command-line Debugging
120+
REM echo build_themes: %build_themes%
121+
REM echo build_skins: %build_skins%
122+
REM echo build_pe: %build_pe%
123+
REM echo runinstcmd: %runinstcmd%
124+
REM echo runsvnup: %runsvnup%
125+
REM echo qmake_defs: %qmake_defs%
126+
REM echo use_svn_revision: %use_svn_revision%
127+
REM goto end
128+
129+
:: GCC Target
130+
for /f "usebackq tokens=2" %%i in (`"gcc -v 2>&1 | find "Target""`) do set gcc_target=%%i
131+
if [%gcc_target%]==[x86_64-w64-mingw32] (
132+
set X86_64=yes
133+
) else if [%gcc_target%]==[i686-w64-mingw32] (
134+
set X86_64=no
135+
) else if [%gcc_target%]==[mingw32] (
136+
set X86_64=no
137+
)
138+
139+
:: MinGW locations from GCC
140+
for /f "usebackq tokens=*" %%d in (`where gcc.exe`) do set MINGW_DIR=%%d
141+
set MINGW_DIR=%MINGW_DIR:~0,-8%
142+
143+
:: Qt locations from QMAKE
144+
for /f "tokens=*" %%i in ('qmake -query QT_INSTALL_PREFIX') do set QT_DIR=%%i
145+
for /f "tokens=*" %%i in ('qmake -query QT_VERSION') do set QT_VER=%%i
146+
set QT_DIR=%QT_DIR:/=\%
147+
148+
set SMPLAYER_DIR=%start_dir%
149+
:: Does string have a trailing slash? if so remove it
150+
if %SMPLAYER_DIR:~-1%==\ set SMPLAYER_DIR=%SMPLAYER_DIR:~0,-1%
151+
152+
:: Relative paths into full paths
153+
for /f %%i in ("%SMPLAYER_THEMES_DIR%") do set SMPLAYER_THEMES_DIR=%%~fi
154+
for /f %%i in ("%SMPLAYER_SKINS_DIR%") do set SMPLAYER_SKINS_DIR=%%~fi
155+
156+
:: Try to parse if debug or release is uncommented in smplayer.pro
157+
findstr /b /c:"\#CONFIG \+\= release" src\smplayer.pro 2>&1 >nul && (set debug=yes) || (set debug=)
158+
findstr /b /c:"\#CONFIG \+\= debug" src\smplayer.pro 2>&1 >nul && (set debug=) || (set debug=yes)
159+
160+
:: Create var batch file
161+
echo set SMPLAYER_DIR=%SMPLAYER_DIR%>%config_file%
162+
echo set SMPLAYER_THEMES_DIR=%SMPLAYER_THEMES_DIR%>>%config_file%
163+
echo set SMPLAYER_SKINS_DIR=%SMPLAYER_SKINS_DIR%>>%config_file%
164+
echo set QT_DIR=%QT_DIR%>>%config_file%
165+
echo set QT_VER=%QT_VER%>>%config_file%
166+
echo set MINGW_DIR=%MINGW_DIR%>>%config_file%
167+
echo set X86_64=%X86_64%>>%config_file%
168+
echo set BUILD_PREFIX=%BUILD_PREFIX%>>%config_file%
169+
echo set DEBUG=%DEBUG%>>%config_file%
170+
171+
:: ::
172+
:: Main Compile Script ::
173+
:: ::
174+
175+
if [%runsvnup%]==[yes] (
176+
svn up "%SMPLAYER_DIR%" "%SMPLAYER_THEMES_DIR%" "%SMPLAYER_SKINS_DIR%"
177+
echo.
178+
)
179+
180+
call getrev2.cmd
181+
182+
cd dxlist
183+
if [%build_pe%]==[yes] ( goto skip_dxlist )
184+
for %%F in (directx\d3dtypes.h directx\ddraw.h directx\dsound.h) do if not exist %%F goto skip_dxlist
185+
qmake
186+
mingw32-make
187+
188+
if errorlevel 1 echo Dxlist failed to compile.
189+
190+
:skip_dxlist
191+
192+
cd ..\zlib
193+
mingw32-make -fwin32\makefile.gcc
194+
195+
if errorlevel 1 goto end
196+
197+
cd ..\src
198+
lrelease smplayer.pro
199+
qmake "DEFINES += %qmake_defs%"
200+
mingw32-make
201+
202+
if errorlevel 1 goto end
203+
204+
:: Themes
205+
if [%build_themes%]==[yes] (
206+
207+
cd "%SMPLAYER_THEMES_DIR%"
208+
call clean_windows.cmd
209+
cd themes && mingw32-make
210+
211+
if errorlevel 1 echo Failed to compile themes.
212+
213+
)
214+
215+
:: Skins
216+
if [%build_skins%]==[yes] (
217+
218+
cd "%SMPLAYER_SKINS_DIR%"
219+
call clean_windows.cmd
220+
cd themes && mingw32-make
221+
222+
if errorlevel 1 echo Failed to compile skins.
223+
224+
)
225+
226+
:: Installation
227+
if [%runinstcmd%]==[yes] (
228+
cd "%SMPLAYER_DIR%\setup\scripts"
229+
call install_smplayer2.cmd
230+
)
231+
232+
if [%build_pe%]==[yes] (
233+
mkdir "%BUILD_PREFIX%\portable"
234+
235+
if [%X86_64%]==[yes] (
236+
copy /y "%SMPLAYER_DIR%\src\release\smplayer.exe" "%BUILD_PREFIX%\portable\smplayer-portable64.exe"
237+
copy /y "%SMPLAYER_DIR%\src\debug\smplayer.exe" "%BUILD_PREFIX%\portable\smplayer-portable64d.exe"
238+
) else (
239+
copy /y "%SMPLAYER_DIR%\src\release\smplayer.exe" "%BUILD_PREFIX%\portable\smplayer-portable.exe"
240+
copy /y "%SMPLAYER_DIR%\src\debug\smplayer.exe" "%BUILD_PREFIX%\portable\smplayer-portabled.exe"
241+
)
242+
)
243+
244+
:: Return to starting directory
245+
cd /d "%start_dir%"
246+
247+
:end
248+
249+
:: Reset
250+
set startdir=
251+
set build_themes=
252+
set build_skins=
253+
set build_pe=
254+
set runinstcmd=
255+
set runsvnup=
256+
set qmake_defs=
257+
set use_svn_revision=

getrev2.cmd

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
@echo off
2+
3+
:: Some SVN clients can use localized messages (e.g. SlikSVN), force English
4+
set LC_ALL=C
5+
set svn_revision=
6+
set use_svn_versions=
7+
set version_cpp=
8+
9+
for /f "tokens=2" %%i in ('svn info ^| find /I "Revision:"') do set svn_revision=%%i
10+
11+
if "%svn_revision%"=="" (
12+
set svn_revision=UNKNOWN
13+
echo Unknown SVN revision. SVN missing in PATH or not a working copy.
14+
) else (
15+
echo SVN Revision: %svn_revision%
16+
)
17+
echo.
18+
19+
echo #define SVN_REVISION "%svn_revision%">src\svn_revision.h
20+
21+
:: Get values of USE_SVN_VERSIONS & VERSION
22+
for /f "tokens=3" %%j in ('type src\version.cpp ^| find /I "USE_SVN_VERSIONS"') do set use_svn_versions=%%j
23+
for /f "tokens=3" %%k in ('type src\version.cpp ^| find /I "#define VERSION"') do set version_cpp=%%k
24+
25+
:: Remove quotes
26+
setlocal enableDelayedExpansion
27+
for /f "delims=" %%A in ("!use_svn_versions!") do endlocal & set "use_svn_versions=%%~A"
28+
setlocal enableDelayedExpansion
29+
for /f "delims=" %%A in ("!version_cpp!") do endlocal & set "version_cpp=%%~A"
30+
31+
:: Verify svn revision & version are actually numbers and version has at least ver_major.ver_minor.ver_build
32+
if defined use_svn_versions (
33+
echo %svn_revision%|findstr /r /c:"^[0-9][0-9]*$" >nul
34+
if errorlevel 1 (set use_svn_versions=)
35+
)
36+
37+
if defined version_cpp (
38+
echo %version_cpp%|findstr /r /c:"^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$" >nul
39+
if errorlevel 1 (set version_cpp=)
40+
)
41+
42+
if defined version_cpp (
43+
if [%use_svn_versions%]==[1] (
44+
echo %version_cpp%.%svn_revision%>setup\scripts\pkg_version
45+
) else (
46+
echo %version_cpp%>setup\scripts\pkg_version
47+
)
48+
)
49+
50+
set svn_revision=
51+
set use_svn_versions=
52+
set version_cpp=

0 commit comments

Comments
 (0)