User:Dart Raiden/Build Miranda: Difference between revisions

From Miranda NG
Jump to navigation Jump to search
No edit summary
No edit summary
 
(31 intermediate revisions by the same user not shown)
Line 1: Line 1:
start.bat:
It is assumed that you have [https://www.7-zip.org 7-Zip], [https://www.nasm.us NASM], [https://strawberryperl.com Strawberry Perl], and [[Building_Miranda|Visual Studion 2017]] installed.
 
build.bat:
<pre style="overflow:auto;">
<pre style="overflow:auto;">
@echo off
@echo off


start /wait elevate -c -w build.bat
:CheckAdminRights
exit
reg query "HKU\S-1-5-19\Environment" >nul 2>&1
</pre>
if not %ErrorLevel% == 0 (
echo Please run as administator^^!
pause
exit /b 1
)
 
:SetVariables
set "unpacker=%ProgramFiles%\7-Zip\7zG.exe"
set "Configuration=Release"
set "Miranda=%ProgramFiles%\Miranda NG"
set "Vs=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community"
set "Msbuild=%Vs%\MSBuild\15.0\Bin\MSBuild.exe"
set "Openssl=D:\dev\openssl"
set "Path=%ProgramFiles%\NASM;%Path%"
set "Solution=bin15"
set "Sources=D:\dev\miranda-ng"


build.bat:
:CleanSources
<pre style="overflow:auto;">
if exist "%Sources%\%Solution%\%Configuration%64" rd /s /q "%Sources%\%Solution%\%Configuration%64"
@echo off
cd /d "%Sources%"
call cleaner.bat


set sources=D:\dev\miranda-ng
:UpdateSources
set solution_dir=bin15
git --work-tree="%Sources%" --git-dir="%Sources%/.git" pull
set configuration=Release
:: or you can use something like tortoisegitproc /command:pull /path:"%Sources%"
set miranda_path=%PROGRAMFILES%\Miranda NG
set vspath=%PROGRAMFILES(X86)%\Microsoft Visual Studio\2017\Community
set msbuild=%vspath%\MSBuild\15.0\Bin\MSBuild.exe


:set_vs_variables
:SetVsEnvironmentVariables
call "%vspath%\Common7\Tools\vsdevcmd.bat" -arch=amd64 -host_arch=amd64 -no_logo -vcvars_spectre_libs=spectre
call "%Vs%\VC\Auxiliary\Build\vcvarsall.bat" x64


:clean_old_build
:BuildTdlib
cd /d "%sources%\%solution_dir%"
title Building TDLib...
if exist "%sources%\%solution_dir%\%configuration%64" rd /q /s "%sources%\%solution_dir%\%configuration%64" >nul
"%Msbuild%" "%Sources%\%Solution%\tdlib.sln" /m /t:Rebuild /p:Configuration=Release
if exist "%sources%\include\m_version.h" del /q /s "%sources%\include\m_version.h"
if not %ErrorLevel% == 0 (
call "%sources%\cleaner.bat"
echo ********** TDLib build failed **********
pause
exit /b 1
)


:update_sources
:BuildMiranda
call TortoiseGitProc /command:pull /path:"%sources%"
title Building Miranda...
"%Msbuild%" "%Sources%\%Solution%\my.sln" /m /t:Rebuild /p:Configuration=Release
if not %ErrorLevel% == 0 (
echo ********** Miranda build failed **********
pause
exit /b 1
)


:build_miranda
:BuildIcons
call "%msbuild%" %sources%\%solution_dir%\my.sln /m /t:Rebuild /p:Configuration=Release /p:Platform=x64
title Building icons...
if errorlevel 1 (
"%Msbuild%" "%Sources%\%Solution%\my_icons.sln" /m /t:Rebuild /p:Configuration=Release
echo ********** MIRANDA BUILD FAIL **********
if not %ErrorLevel% == 0 (
pause
echo ********** Icons build failed **********
exit )
pause
exit /b 1
)


:build_icons
:BuildLangpack
call "%msbuild%" %sources%\%solution_dir%\my_icons.sln /m /t:Rebuild /p:Configuration=Release /p:Platform=x64
mkdir "%Sources%\%Solution%\%Configuration%64\Languages"
if errorlevel 1 (
cscript /nologo "%Sources%\tools\lpgen\translate.js" /sourcelang:"russian" /release:"%Sources%\%Solution%\%Configuration%64\Languages\langpack_russian.txt"
echo ********** ICONS BUILD FAIL **********
pause
exit )


:sort
:SortCompiledFiles
cd /d "%sources%\%solution_dir%\%configuration%64"
cd /d "%Sources%\%Solution%\%Configuration%64"
rd /q /s "%sources%\%solution_dir%\%configuration%64\Obj" >nul
rd /q /s Obj
for /r "%sources%\%solution_dir%\%configuration%64" %%i in (*.ilk,*.iobj,*.ipdb) do del /q /s %%i >nul
for /r %%i in (*.ilk,*.iobj,*.ipdb) do del /q /s %%i
for /r "%sources%\%solution_dir%\%configuration%64\Icons" %%j in (*.pdb) do del /q /s %%j >nul
for /r Icons %%j in (*.pdb) do del /q /s %%j
for /r "%sources%\%solution_dir%\%configuration%64" %%k in (*.pdb) do move %%k "%sources%\%solution_dir%\%configuration%64" >nul
for /r %%k in (*.pdb) do move %%k "%Sources%\%Solution%\%Configuration%64"


:kill
:KillMiranda
Taskkill /f /im Miranda64.exe
Taskkill /f /im Miranda64.exe
timeout 3


:backup
:BackupOldMiranda
if exist "%miranda_path%\Plugin Updates\Backups" rd /q /s "%miranda_path%\Plugin Updates\Backups" >nul
if exist "%Temp%\Miranda_backup" rd /q /s "%Temp%\Miranda_backup"
if exist "%TEMP%\Miranda_backup" rd /q /s "%TEMP%\Miranda_backup" >nul
xcopy /i /s /y "%Miranda%" "%Temp%\Miranda_backup"
xcopy /i /s /y "%miranda_path%" "%TEMP%\Miranda_backup" >nul


:replace
:UpdateMiranda
cd /d "%sources%\%solution_dir%\%configuration%64"
xcopy /i /s /y "%Sources%\%Solution%\%Configuration%64" "%Miranda%"
for %%l in (exe,mir,pdb) do del /q /s "%miranda_path%\*.%%l" >nul
for %%m in (Core,Icons,Plugins) do rd /q /s "%miranda_path%\%%m" >nul
xcopy /i /s /y "%sources%\%solution_dir%\%configuration%64" "%miranda_path%" >nul
for %%n in (libeay32.mir,ssleay32.mir) do xcopy /y "%TEMP%\Miranda_backup\Libs\%%n" "%miranda_path%\Libs" >nul
for %%o in (libeay32.pdb,ssleay32.pdb) do xcopy /y "%TEMP%\Miranda_backup\%%o" "%miranda_path%" >nul


:clean
:BuildOpenssl
cd /d "%sources%\%solution_dir%"
title Building OpenSSL...
if exist "%sources%\%solution_dir%\%configuration%64" rd /q /s "%sources%\%solution_dir%\%configuration%64" >nul
cd /d "%Openssl%"
if exist "%sources%\include\m_version.h" del /q /s "%sources%\include\m_version.h"
git apply "%Sources%\tools\openssl\openssl-mir-changes.patch"
perl "%Openssl%\Configure" shared VC-WIN64A
nmake
for %%n in (libcrypto-3.mir,libssl-3.mir) do xcopy /y %%n "%Miranda%\Libs"
for %%n in (libcrypto-3.pdb,libssl-3.pdb) do xcopy /y %%n "%Miranda%"


:run
:RunMiranda
runas /trustlevel:0x20000 "%miranda_path%\Miranda64.exe"
:: dirty hack to prevent the app from inheriting elevated permissions
explorer "%Miranda%\Miranda64.exe"


exit
exit /b 0
</pre>
</pre>


[http://code.kliu.org/misc/elevate/ Here] you can download elevate utility. my.sln and my_icons.sln are my custom solutions.
my.sln and my_icons.sln are my custom solutions.

Latest revision as of 01:16, 22 March 2024

It is assumed that you have 7-Zip, NASM, Strawberry Perl, and Visual Studion 2017 installed.

build.bat:

@echo off

:CheckAdminRights
reg query "HKU\S-1-5-19\Environment" >nul 2>&1
if not %ErrorLevel% == 0 (
	echo Please run as administator^^!
	pause
	exit /b 1
)

:SetVariables
set "unpacker=%ProgramFiles%\7-Zip\7zG.exe"
set "Configuration=Release"
set "Miranda=%ProgramFiles%\Miranda NG"
set "Vs=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community"
set "Msbuild=%Vs%\MSBuild\15.0\Bin\MSBuild.exe"
set "Openssl=D:\dev\openssl"
set "Path=%ProgramFiles%\NASM;%Path%"
set "Solution=bin15"
set "Sources=D:\dev\miranda-ng"

:CleanSources
if exist "%Sources%\%Solution%\%Configuration%64" rd /s /q "%Sources%\%Solution%\%Configuration%64"
cd /d "%Sources%"
call cleaner.bat

:UpdateSources
git --work-tree="%Sources%" --git-dir="%Sources%/.git" pull
:: or you can use something like tortoisegitproc /command:pull /path:"%Sources%"

:SetVsEnvironmentVariables
call "%Vs%\VC\Auxiliary\Build\vcvarsall.bat" x64

:BuildTdlib
title Building TDLib...
"%Msbuild%" "%Sources%\%Solution%\tdlib.sln" /m /t:Rebuild /p:Configuration=Release
if not %ErrorLevel% == 0 (
	echo ********** TDLib build failed **********
	pause
	exit /b 1
)

:BuildMiranda
title Building Miranda...
"%Msbuild%" "%Sources%\%Solution%\my.sln" /m /t:Rebuild /p:Configuration=Release
if not %ErrorLevel% == 0 (
	echo ********** Miranda build failed **********
	pause
	exit /b 1
)

:BuildIcons
title Building icons...
"%Msbuild%" "%Sources%\%Solution%\my_icons.sln" /m /t:Rebuild /p:Configuration=Release
if not %ErrorLevel% == 0 (
	echo ********** Icons build failed **********
	pause
	exit /b 1
)

:BuildLangpack
mkdir "%Sources%\%Solution%\%Configuration%64\Languages"
cscript /nologo "%Sources%\tools\lpgen\translate.js" /sourcelang:"russian" /release:"%Sources%\%Solution%\%Configuration%64\Languages\langpack_russian.txt"

:SortCompiledFiles
cd /d "%Sources%\%Solution%\%Configuration%64"
rd /q /s Obj
for /r %%i in (*.ilk,*.iobj,*.ipdb) do del /q /s %%i
for /r Icons %%j in (*.pdb) do del /q /s %%j
for /r %%k in (*.pdb) do move %%k "%Sources%\%Solution%\%Configuration%64"

:KillMiranda
Taskkill /f /im Miranda64.exe

:BackupOldMiranda
if exist "%Temp%\Miranda_backup" rd /q /s "%Temp%\Miranda_backup"
xcopy /i /s /y "%Miranda%" "%Temp%\Miranda_backup"

:UpdateMiranda
xcopy /i /s /y "%Sources%\%Solution%\%Configuration%64" "%Miranda%"

:BuildOpenssl
title Building OpenSSL...
cd /d "%Openssl%"
git apply "%Sources%\tools\openssl\openssl-mir-changes.patch"
perl "%Openssl%\Configure" shared VC-WIN64A
nmake
for %%n in (libcrypto-3.mir,libssl-3.mir) do xcopy /y %%n "%Miranda%\Libs"
for %%n in (libcrypto-3.pdb,libssl-3.pdb) do xcopy /y %%n "%Miranda%"

:RunMiranda
:: dirty hack to prevent the app from inheriting elevated permissions
explorer "%Miranda%\Miranda64.exe"

exit /b 0

my.sln and my_icons.sln are my custom solutions.