2016-09-06 15:31:41 -04:00
@ echo off
setlocal
set Quite = ^> nul
: : Initialize environment
call " %~dp0 ..\env.bat "
if errorlevel 1 goto error_env
call " %EnvPath% \env.bat "
if errorlevel 1 goto error_env
2018-05-07 00:42:52 -04:00
: : Initialize environment
call " %~dp0 env.bat " %*
if errorlevel 2 exit /B 2
if errorlevel 1 goto error_env
2016-09-06 15:31:41 -04:00
: : Check external libraries
2018-05-07 00:42:52 -04:00
if not exist " %BuildLibsPath% \libs " %cecho% error " Please build external libraries first. " & exit /B 1
2016-09-06 15:31:41 -04:00
: : Check gcc version of external libraries
2018-05-07 00:42:52 -04:00
if not exist " %BuildLibsPath% \libs\gcc-version " %cecho% error " Cannot get gcc version of external libraries. " & exit /B 1
set /P LibsGCCVersion = < " %BuildLibsPath% \libs\gcc-version "
if " %LibsGCCVersion% " NEQ " %GCCVersion% " %cecho% error " Please use correct version of external libraries. (gcc %GCCVersion% ^ < ^ > libs %LibsGCCVersion% ). " & exit /B 1
2016-09-06 15:31:41 -04:00
: : Remove deploy path
if exist " %RsDeployPath% " rmdir /S /Q " %RsDeployPath% "
: : Check compilation
if not exist " %RsBuildPath% \Makefile " echo Project is not compiled.& goto error
: : Get compiled version
2020-08-08 09:05:05 -04:00
call " %ToolsPath% \get-rs-version.bat " " %RsBuildPath% \retroshare-gui\src\ %RsBuildConfig% \retroshare.exe " RsVersion
2018-10-13 07:19:22 -04:00
if errorlevel 1 %cecho% error " Version not found. " & goto error
2016-09-06 15:31:41 -04:00
2018-10-13 07:19:22 -04:00
if " %RsVersion.Major% " == " " %cecho% error " Major version not found. " & goto error
if " %RsVersion.Minor% " == " " %cecho% error " Minor version not found. " & goto error
if " %RsVersion.Mini% " == " " %cecho% error " Mini number not found " .& goto error
if " %RsVersion.Extra% " == " " %cecho% error " Extra number not found " .& goto error
2016-09-06 15:31:41 -04:00
2018-10-13 07:19:22 -04:00
set RsVersion = %RsVersion.Major% .%RsVersion.Minor% .%RsVersion.Mini%
2016-09-06 15:31:41 -04:00
2020-08-08 09:05:05 -04:00
: : Get date
call " %ToolsPath% \get-rs-date.bat " " %SourcePath% " RsDate
if errorlevel 1 %cecho% error " Could not get date. " & goto error
2016-09-06 15:31:41 -04:00
2020-08-08 09:05:05 -04:00
if " %RsDate% " == " " %cecho% error " Could not get date. " & goto error
2016-09-06 15:31:41 -04:00
2020-08-08 09:05:05 -04:00
rem Tor
2018-06-17 11:51:58 -04:00
if " %ParamTor% " == " 1 " (
: : Check for tor executable
2020-08-08 09:05:05 -04:00
if not exist " %EnvTorPath% \Tor\tor.exe " (
%cecho% error " Tor binary not found. Please download Tor Expert Bundle from\nhttps://www.torproject.org/download/download.html.en\nand unpack to\n %EnvTorPath:\=\\% "
2018-03-08 11:45:24 -05:00
goto error
)
)
2016-09-06 15:31:41 -04:00
set QtMainVersion = %QtVersion:~0,1%
rem Qt 4 = QtSvg4.dll
rem Qt 5 = Qt5Svg.dll
set QtMainVersion1 =
set QtMainVersion2 =
if " %QtMainVersion% " == " 4 " set QtMainVersion2 = 4
if " %QtMainVersion% " == " 5 " set QtMainVersion1 = 5
if " %RsBuildConfig% " NEQ " release " (
2020-07-30 18:52:56 -04:00
set Archive = %RsPackPath% \RetroShare-%RsVersion% -Windows-Portable-%RsDate% -%RsVersion.Extra% -Qt-%QtVersion% -%GCCArchitecture% %RsType% %RsArchiveAdd% -%RsBuildConfig% .7z
2016-09-06 15:31:41 -04:00
) else (
2020-07-30 18:52:56 -04:00
set Archive = %RsPackPath% \RetroShare-%RsVersion% -Windows-Portable-%RsDate% -%RsVersion.Extra% -Qt-%QtVersion% -%GCCArchitecture% %RsType% %RsArchiveAdd% .7z
2016-09-06 15:31:41 -04:00
)
if exist " %Archive% " del /Q " %Archive% "
: : Create deploy path
mkdir " %RsDeployPath% "
2018-03-08 11:45:24 -05:00
title Pack - %SourceName% %RsType% -%RsBuildConfig% [copy files]
2016-09-06 15:31:41 -04:00
set ExtensionsFile = %SourcePath% \libretroshare\src\rsserver\rsinit.cc
set Extensions =
for /f %% e in ( 'type " %ExtensionsFile% " ^| " %EnvSedExe% " -n "s/^.*\/\(extensions[^/]*\)\/.*$/\1/p" ^| " %EnvSedExe% " -n "1,1p"' ) do set Extensions = %% e
2018-10-13 07:19:22 -04:00
if " %Extensions% " == " " %cecho% error " Folder for extensions not found in %ExtensionsFile% " & goto error
2016-09-06 15:31:41 -04:00
: : Copy files
mkdir " %RsDeployPath% \Data\ %Extensions% "
mkdir " %RsDeployPath% \imageformats "
mkdir " %RsDeployPath% \qss "
mkdir " %RsDeployPath% \stylesheets "
mkdir " %RsDeployPath% \sounds "
mkdir " %RsDeployPath% \translations "
2019-02-04 13:07:20 -05:00
mkdir " %RsDeployPath% \license "
2016-09-06 15:31:41 -04:00
copy nul " %RsDeployPath% \portable " %Quite%
echo copy binaries
2020-07-30 18:52:56 -04:00
copy " %RsBuildPath% \retroshare-gui\src\ %RsBuildConfig% \retroshare*.exe " " %RsDeployPath% " %Quite%
copy " %RsBuildPath% \retroshare-service\src\ %RsBuildConfig% \retroshare*-service.exe " " %RsDeployPath% " %Quite%
2016-09-06 15:31:41 -04:00
echo copy extensions
for /D %% D in ( " %RsBuildPath% \plugins\* " ) do (
call : copy_extension " %% D " " %RsDeployPath% \Data\ %Extensions% "
call : copy_dependencies " %RsDeployPath% \Data\ %Extensions% \ %% ~nxD.dll " " %RsDeployPath% "
)
echo copy external binaries
2018-06-17 11:51:58 -04:00
copy " %BuildLibsPath% \libs\bin\*.dll " " %RsDeployPath% " %Quite%
2016-09-06 15:31:41 -04:00
echo copy dependencies
2017-07-17 04:44:27 -04:00
call : copy_dependencies " %RsDeployPath% \retroshare.exe " " %RsDeployPath% "
2016-09-06 15:31:41 -04:00
echo copy Qt DLL's
copy " %QtPath% \Qt %QtMainVersion1% Svg %QtMainVersion2% .dll " " %RsDeployPath% " %Quite%
if " %QtMainVersion% " == " 5 " (
mkdir " %RsDeployPath% \platforms "
copy " %QtPath% \..\plugins\platforms\qwindows.dll " " %RsDeployPath% \platforms " %Quite%
mkdir " %RsDeployPath% \audio "
copy " %QtPath% \..\plugins\audio\qtaudio_windows.dll " " %RsDeployPath% \audio " %Quite%
)
2018-03-04 14:08:15 -05:00
if exist " %QtPath% \..\plugins\styles\qwindowsvistastyle.dll " (
echo Copy styles
mkdir " %RsDeployPath% \styles " %Quite%
copy " %QtPath% \..\plugins\styles\qwindowsvistastyle.dll " " %RsDeployPath% \styles " %Quite%
)
2016-09-06 15:31:41 -04:00
copy " %QtPath% \..\plugins\imageformats\*.dll " " %RsDeployPath% \imageformats " %Quite%
del /Q " %RsDeployPath% \imageformats\*d?.dll " %Quite%
echo copy qss
xcopy /S " %SourcePath% \retroshare-gui\src\qss " " %RsDeployPath% \qss " %Quite%
echo copy stylesheets
xcopy /S " %SourcePath% \retroshare-gui\src\gui\qss\chat " " %RsDeployPath% \stylesheets " %Quite%
rmdir /S /Q " %RsDeployPath% \stylesheets\compact " %Quite%
rmdir /S /Q " %RsDeployPath% \stylesheets\standard " %Quite%
rmdir /S /Q " %RsDeployPath% \stylesheets\__MACOSX__Bubble " %Quite%
echo copy sounds
xcopy /S " %SourcePath% \retroshare-gui\src\sounds " " %RsDeployPath% \sounds " %Quite%
2019-02-04 13:07:20 -05:00
echo copy license
xcopy /S " %SourcePath% \retroshare-gui\src\license " " %RsDeployPath% \license " %Quite%
2016-09-06 15:31:41 -04:00
echo copy translation
copy " %SourcePath% \retroshare-gui\src\translations\qt_tr.qm " " %RsDeployPath% \translations " %Quite%
copy " %QtPath% \..\translations\qt_*.qm " " %RsDeployPath% \translations " %Quite%
if " %QtMainVersion% " == " 5 " (
copy " %QtPath% \..\translations\qtbase_*.qm " " %RsDeployPath% \translations " %Quite%
copy " %QtPath% \..\translations\qtscript_*.qm " " %RsDeployPath% \translations " %Quite%
copy " %QtPath% \..\translations\qtmultimedia_*.qm " " %RsDeployPath% \translations " %Quite%
copy " %QtPath% \..\translations\qtxmlpatterns_*.qm " " %RsDeployPath% \translations " %Quite%
)
echo copy bdboot.txt
copy " %SourcePath% \libbitdht\src\bitdht\bdboot.txt " " %RsDeployPath% " %Quite%
2020-08-04 13:04:45 -04:00
echo copy changelog.txt
copy " %RsBuildPath% \changelog.txt " " %RsDeployPath% " %Quite%
2016-09-06 15:31:41 -04:00
if exist " %SourcePath% \libresapi\src\webui " (
echo copy webui
mkdir " %RsDeployPath% \webui "
xcopy /S " %SourcePath% \libresapi\src\webui " " %RsDeployPath% \webui " %Quite%
)
2018-06-17 11:51:58 -04:00
if " %ParamTor% " == " 1 " (
2018-03-08 11:45:24 -05:00
echo copy tor
2020-08-08 09:05:05 -04:00
echo n | copy /-y " %EnvTorPath% \*.* " " %RsDeployPath% " %Quite%
2018-03-08 11:45:24 -05:00
)
2016-09-06 15:31:41 -04:00
rem pack files
2018-03-08 11:45:24 -05:00
title Pack - %SourceName% %RsType% -%RsBuildConfig% [pack files]
2016-09-06 15:31:41 -04:00
2016-11-03 03:32:15 -04:00
" %EnvSevenZipExe% " a -mx=9 -t7z " %Archive% " " %RsDeployPath% \* "
2016-09-06 15:31:41 -04:00
title %COMSPEC%
call : cleanup
endlocal
exit /B 0
: error
call : Cleanup
endlocal
exit /B 1
: cleanup
goto : EOF
: error_env
echo Failed to initialize environment.
endlocal
exit /B 1
: copy_extension
if exist " %~1 \ %RsBuildConfig% \ %~n1 .dll " (
copy " %~1 \ %RsBuildConfig% \ %~n1 .dll " %2 %Quite%
)
goto : EOF
: copy_dependencies
2018-06-17 11:51:58 -04:00
set CopyDependenciesCopiedSomething = 0
2016-09-06 15:31:41 -04:00
for /F " usebackq " %% A in ( ` %ToolsPath% \depends.bat list %1 ` ) do (
2018-06-17 11:51:58 -04:00
if not exist " %~2 \ %% A " (
if exist " %QtPath% \ %% A " (
set CopyDependenciesCopiedSomething = 1
copy " %QtPath% \ %% A " %2 %Quite%
) else (
if exist " %MinGWPath% \ %% A " (
set CopyDependenciesCopiedSomething = 1
copy " %MinGWPath% \ %% A " %2 %Quite%
)
2016-09-06 15:31:41 -04:00
)
)
)
2018-06-17 11:51:58 -04:00
if " %CopyDependenciesCopiedSomething% " == " 1 " goto copy_dependencies
2016-09-06 15:31:41 -04:00
goto : EOF