Updated WIN build scripts

This commit is contained in:
Valentino Orlandi 2022-11-15 21:35:32 +01:00
parent a2872fba12
commit 9ef1732d78
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
5 changed files with 626 additions and 0 deletions

95
WIN_build_install_1.bat Normal file
View File

@ -0,0 +1,95 @@
@ECHO off
ECHO Initializing
:: Store the actual path
FOR /F "tokens=* USEBACKQ" %%e IN (`cd`) DO SET actual_path=%%e
:: Get the path of LogDoctor-git's folder and move in
SET logdocdir=%~dp0
SET logdocdir=%logdocdir:\=/%
IF "%logdocdir:~-1%"=="/" SET logdocdir=%logdocdir:~0,-1%
cd %logdocdir%
:: Call the builder
IF NOT EXIST "builder.bat" (
ECHO:
ECHO Error: builder not found
cd "%actual_path%"
PAUSE
EXIT /B 1
)
CALL builder.bat "%actual_path%"
IF ERRORLEVEL 1 (
ECHO:
ECHO Compilation failed
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:: Start installing LogDoctor
ECHO:
ECHO Starting installation process
cd ..\installation_stuff\
SET data_path=%USERPROFILE%\AppData\Local\LogDoctor
IF NOT EXIST "%data_path%" mkdir "%data_path%"
IF NOT EXIST "%data_path%\logdoctor.conf" GOTO :step11
:loop9
ECHO:
ECHO Warning: a configuration file already exists
ECHO If you choose 'YES' the current file will be overwritten
ECHO If you choose 'NO' the current file will be kept
SET /P agree=Overwrite? [y/n] :
IF "%agree%"=="y" (
GOTO :step10
)
IF "%agree%"=="Y" (
GOTO :step10
)
IF "%agree%"=="n" (
GOTO :step11
)
IF "%agree%"=="N" (
GOTO :step11
)
ECHO NOT A VALID ANSWER
GOTO :loop9
:step10
copy /V /Y logdoctor.conf %data_path%\
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to copy configuration file
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:step11
xcopy /E /V /Y logdocdata %data_path%\
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to copy LogDoctor's data
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:: End Of Part 1
ECHO:
ECHO First part is done, please run 'WIN_build_install_2' as Administrator
cd "%actual_path%"
PAUSE

104
WIN_build_install_2.bat Normal file
View File

@ -0,0 +1,104 @@
@ECHO off
:: Store the actual path
SET actual_path=%1
:: Get the path of LogDoctor-git's folder and move in
SET logdocdir=%~dp0
SET logdocdir=%logdocdir:\=/%
IF "%logdocdir:~-1%"=="/" SET logdocdir=%logdocdir:~0,-1%
cd %logdocdir%
:: Check the existence of a previous installation
IF NOT EXIST "C:\Program Files\LogDoctor\LogDoctor.exe" GOTO :step1
:loop0
ECHO:
ECHO Warning: a previous installation already exists
ECHO If you choose to continue, the actual content will be overwritten
SET /P agree=Continue? [y/n] :
IF "%agree%"=="y" (
GOTO :step1
)
IF "%agree%"=="Y" (
GOTO :step1
)
IF "%agree%"=="n" (
cd "%actual_path%"
EXIT /B 1
)
IF "%agree%"=="N" (
cd "%actual_path%"
EXIT /B 1
)
ECHO NOT A VALID ANSWER
GOTO :loop0
:step1
SET exec_path=C:\Program Files\LogDoctor
IF EXIST "%exec_path%" GOTO :step2
mkdir "%exec_path%"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to create directory: '%exec_path%'
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:step2
copy /B /V /Y build\LogDoctor.exe "%exec_path%"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to copy the executable
cd "%actual_path%"
PAUSE
EXIT /B 1
)
copy /V /Y installation_stuff\logdoctor.svg "%exec_path%\LogDoctor.svg"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to copy the icon
cd "%actual_path%"
PAUSE
EXIT /B 1
)
IF NOT EXIST "%exec_path%\licenses" GOTO :step3
rmdir /S /Q "%exec_path%\licenses"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to remove old licenses
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:step3
xcopy /E /I /V /Y logdocdata\licenses "%exec_path%\licenses"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to copy licenses
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:: Installation finished
ECHO:
ECHO Installation finished
cd "%actual_path%"
PAUSE

68
WIN_build_update_1.bat Normal file
View File

@ -0,0 +1,68 @@
@ECHO off
ECHO Initializing
:: Store the actual path
FOR /F "tokens=* USEBACKQ" %%e IN (`cd`) DO SET actual_path=%%e
:: Get the path of LogDoctor-git's folder and move in
SET logdocdir=%~dp0
SET logdocdir=%logdocdir:\=/%
IF "%logdocdir:~-1%"=="/" SET logdocdir=%logdocdir:~0,-1%
cd %logdocdir%
:: Call the builder
IF NOT EXIST "builder.bat" (
ECHO:
ECHO Error: builder not found
cd "%actual_path%"
PAUSE
EXIT /B 1
)
CALL builder.bat "%actual_path%"
IF ERRORLEVEL 1 (
ECHO:
ECHO Compilation failed
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:: Start updating LogDoctor
ECHO "Starting update process"
cd ../installation_stuff/
SET data_path=%USERPROFILE%\AppData\Local\LogDoctor
IF EXIST "%data_path%" GOTO :step1
mkdir "%data_path%"
IF ERRORLEVEL 1 (
ECHO Error: failed to create directory: '%data_path%'
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:step1
xcopy /E /V /Y logdocdata %data_path%\
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to copy LogDoctor's data
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:: End Of Part 1
ECHO:
ECHO First part is done, please run 'WIN_build_update_2' as Administrator
cd "%actual_path%"
PAUSE

76
WIN_build_update_2.bat Normal file
View File

@ -0,0 +1,76 @@
@ECHO off
:: Store the actual path
SET actual_path=%1
:: Get the path of LogDoctor-git's folder and move in
SET logdocdir=%~dp0
SET logdocdir=%logdocdir:\=/%
IF "%logdocdir:~-1%"=="/" SET logdocdir=%logdocdir:~0,-1%
cd %logdocdir%
SET exec_path=C:\Program Files\LogDoctor
IF EXIST "%exec_path%" GOTO :step1
mkdir "%exec_path%"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to create directory: '%exec_path%'
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:step1
copy /B /V /Y build\LogDoctor.exe "%exec_path%"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to copy the executable
cd "%actual_path%"
PAUSE
EXIT /B 1
)
copy /V /Y installation_stuff\logdoctor.svg "%exec_path%\LogDoctor.svg"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to copy the icon
cd "%actual_path%"
PAUSE
EXIT /B 1
)
IF NOT EXIST "%exec_path%\licenses" GOTO :step2
rmdir /S /Q "%exec_path%\licenses"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to remove old licenses
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:step2
xcopy /E /I /V /Y logdocdata\licenses "%exec_path%\licenses"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to copy licenses
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:: Update finished
ECHO:
ECHO "Update finished"
cd "%actual_path%"
PAUSE

283
builder.bat Normal file
View File

@ -0,0 +1,283 @@
@ECHO off
:: Store the actual path
SET actual_path=%1
:: Get Qt base path
SET qt_base_path=C:/Qt
IF EXIST "%qt_base_path%" GOTO :step0
SET qt_base_path=C:/Program Files/Qt
IF EXIST "%qt_base_path%" GOTO :step0
SET qt_base_path=C:/Program Files (x86)/Qt
IF EXIST "%qt_base_path%" GOTO :step0
SET qt_base_path=%USERPROFILE%\Qt
IF EXIST "%qt_base_path%" GOTO :step0
SET qt_base_path=NONE
:step0
SET qt_path=%qt_base_path%
IF "%qt_base_path%" == "NONE" GOTO :step1
SET qt_base_path=%qt_base_path:\=/%
IF "%qt_base_path:~-1%"=="/" SET qt_base_path=%qt_base_path:~0,-1%
:: Get Qt version
SET qt_path=%qt_base_path%/5.15.2
IF EXIST "%qt_path%" GOTO :step1
SET qt_path=%qt_base_path%/6.0
IF EXIST "%qt_path%" GOTO :step1
SET qt_path=%qt_base_path%/6.2
IF EXIST "%qt_path%" GOTO :step1
SET qt_path=%qt_base_path%/6.4
IF EXIST "%qt_path%" GOTO :step1
SET qt_path=NONE
:step1
IF NOT "%qt_path%" == "NONE" GOTO :step2
:loop1
ECHO:
ECHO Qt not found, please insert the path of your Qt installation, including the version
ECHO Ex: C:/your/path/to/Qt/5.15.2
SET /P qt_path= :
IF NOT EXIST "%qt_path%" (
ECHO Error: the given path doesn't exist
GOTO :loop1
)
:step2
SET qt_path=%qt_path:\=/%
IF "%qt_path:~-1%"=="/" SET qt_path=%qt_path:~0,-1%
:: Get CMake path
SET cmake_path=%qt_base_path%/Tools/CMake_64/bin/cmake.exe
IF EXIST "%cmake_path%" GOTO :step4
where /Q cmake
IF ERRORLEVEL 0 (
FOR /F "tokens=* USEBACKQ" %%e IN (`where cmake`) DO SET cmake_path=%%e
IF EXIST "%cmake_path%" GOTO :step4
)
SET cmake_path=C:/Program Files/CMake/bin/cmake.exe
IF EXIST "%cmake_path%" GOTO :step4
SET cmake_path=C:/Program Files (x86)/CMake/bin/cmake.exe
IF EXIST "%cmake_path%" GOTO :step4
SET cmake_path=C:/CMake/bin/cmake.exe
IF EXIST "%cmake_path%" GOTO :step4
SET cmake_path=C:/msys64/usr/bin/cmake.exe
IF EXIST "%cmake_path%" GOTO :step4
SET cmake_path=C:/msys64/mingw64/bin/cmake.exe
IF EXIST "%cmake_path%" GOTO :step4
:loop3
ECHO:
ECHO CMake not found, please insert the path of your CMake installation, including the executable
ECHO Ex: C:/your/path/to/cmake.exe
SET /P cmake_path= :
IF EXIST "%cmake_path%" (
IF NOT "%cmake_path:~-9%" == "cmake.exe" (
ECHO Error: the given path doesn't point to a cmake executable
GOTO :loop3
)
) ELSE (
ECHO Error: the given path doesn't exist
GOTO :loop3
)
:step4
SET cmake_path=%cmake_path:\=/%
:: Get the C++ compiler path
SET cxx_compiler=%qt_base_path%/Tools/mingw1120_64/bin/g++.exe
IF EXIST "%cxx_compiler%" GOTO :step6
SET cxx_compiler=%qt_base_path%/Tools/mingw810_64/bin/g++.exe
IF EXIST "%cxx_compiler%" GOTO :step6
where /Q g++
IF ERRORLEVEL 0 (
FOR /F "tokens=* USEBACKQ" %%e IN (`where g++`) DO SET cxx_compiler=%%e
IF EXIST "%cxx_compiler%" GOTO :step6
)
SET cxx_compiler=C:/msys64/mingw64/bin/g++.exe
IF EXIST "%cxx_compiler%" GOTO :step6
:loop5
ECHO:
ECHO G++ not found, please insert the path of the C++ compiler
ECHO Ex: C:/your/path/to/g++.exe
SET /P cxx_compiler= :
IF EXIST "%cxx_compiler%" (
IF NOT "%cxx_compiler:~-7%" == "g++.exe" (
ECHO Error: the given path doesn't point to a g++ executable
GOTO :loop5
)
) ELSE (
ECHO Error: the given path doesn't exist
GOTO :loop5
)
:step6
SET cxx_compiler=%cxx_compiler:\=/%
SET prefix_path=%qt_path%/mingw112_64
IF EXIST "%prefix_path%" GOTO :step7
SET prefix_path=%qt_path%/mingw81_64
IF EXIST "%prefix_path%" GOTO :step7
ECHO:
ECHO Error: CMAKE_PREFIX_PATH not found
PAUSE
EXIT /B 1
:step7
IF "%prefix_path:~-1%"=="/" SET prefix_path=%prefix_path:~0,-1%
SET qt_dir=%prefix_path%/lib/cmake/Qt5
IF EXIST "%qt_dir%" GOTO :step8
ECHO:
ECHO Error: QT_DIR not found
PAUSE
EXIT /B 1
:step8
IF "%qt_dir:~-1%"=="/" SET qt_dir=%qt_dir:~0,-1%
:: Check if JOM is in PATH
where /Q jom
IF ERRORLEVEL 0 (
FOR /F "tokens=* USEBACKQ" %%e IN (`where jom`) DO SET jom_path=%%e
IF EXIST "%jom_path%" GOTO :step9_a
)
SET jom_path=%qt_base_path%/Tools/QtCreator/bin/jom
IF EXIST "%jom_path%" SET PATH=%PATH%;%jom_path%
where /Q jom
IF ERRORLEVEL 0 (
FOR /F "tokens=* USEBACKQ" %%e IN (`where jom`) DO SET jom_path=%%e
IF EXIST "%jom_path%" GOTO :step9_a
)
ECHO:
ECHO Error: JOM not found in PATH, please add it or compilation won't succeed
PAUSE
EXIT /B 1
:step9_a
:: Check if libwinpthread-1.dll is in PATH
where /Q libwinpthread-1.dll
IF ERRORLEVEL 0 (
FOR /F "tokens=* USEBACKQ" %%e IN (`where libwinpthread-1.dll`) DO SET lib_path=%%e
IF EXIST "%lib_path%" GOTO :step9_b2
)
SET lib_path=%qt_base_path%/Tools/mingw1120_64/bin
IF EXIST "%lib_path%" GOTO :step9_b1
SET lib_path=%qt_base_path%/Tools/mingw810_64/bin
IF EXIST "%lib_path%" GOTO :step9_b1
SET lib_path=C:/msys64/mingw64/bin
IF EXIST "%lib_path%" GOTO :step9_b1
:step9_b1
SET PATH=%PATH%;%lib_path%
where /Q libwinpthread-1.dll
IF ERRORLEVEL 0 (
FOR /F "tokens=* USEBACKQ" %%e IN (`where libwinpthread-1.dll`) DO SET lib_path=%%e
IF EXIST "%lib_path%" GOTO :step9_b2
)
ECHO:
ECHO Error: libwinpthread-1.dll not found in PATH, please add it or compilation won't succeed
PAUSE
EXIT /B 1
:step9_b2
:: Start the compilation process
ECHO:
ECHO Starting compilation process
ECHO:
:: Make a build folder
IF EXIST build rmdir /S /Q build
mkdir build
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to create directory: 'build'
cd "%actual_path%"
PAUSE
EXIT /B 1
)
cd build
:: Prepare build files
"%cmake_path%" "%logdocdir%/logdoctor" "-DCMAKE_BUILD_TYPE:STRING=MinSizeRel" "-DCMAKE_GENERATOR:STRING=NMake Makefiles JOM" "-DCMAKE_MAKE_PROGRAM:STRING=jom" "-DCMAKE_CXX_COMPILER:FILEPATH=%cxx_compiler%" "-DCMAKE_PREFIX_PATH:PATH=%prefix_path%" "-DQT_DIR:PATH=%qt_dir%"
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to prepare cmake files
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:: Build the project
"%cmake_path%" --build ./ --target all
IF ERRORLEVEL 1 (
ECHO:
ECHO Error: failed to compile
cd "%actual_path%"
PAUSE
EXIT /B 1
)
:: Compilation finished
ECHO:
ECHO Compilation finished