diff --git a/build/tools/mingw/README.md b/build/tools/mingw/README.md new file mode 100644 index 0000000000..ab222a5e37 --- /dev/null +++ b/build/tools/mingw/README.md @@ -0,0 +1,29 @@ +MinGW build tools +----------------- + +This folder contains batch files used to create zip packages for official +builds with different versions of the MinGW compiler. + +Building a new release +---------------------- + +1. If needed, update the versions list in the 'buildall.bat' script (the first 'for' loop of this file) +2. Update the 'parameters.bat" file to reflect your system and your installations of the different MinGW versions. This script is first called without any parameter, to initialize generals values. It will then be called with the compiler version, and the number of bits of the architecture (32 or 64). Here are the lines that will probably need to be changed: + * `set /A JOBS=%NUMBER_OF_PROCESSORS%-1` : the value of this variable contains the number of processes that will be launched simultaneously. It is automatically calculated as "number of cores of your processor - 1" which is the recommended value. It can be overridden by writing something like `set JOBS=3` to directly assign a numerical value to this variable. + * `set CLEANBUILD=1` : setting this value to 0 will not remove old builds previously done. It is not recommended to modify it, unless you know what you're doing. + * `set COMPBINDIR=G:\msys64\mingw%2\bin` and/or `set COMPBINDIR=G:\MinGW%1-%2\bin` : these lines will surely need to be updated. The `COMPBINDIR` value must point to the binary folder of the corresponding MinGW installation. The `%1` parameter will contain the version of the current compiler (such as 730, 810, 1020, 920, ...) and the `%2` one will contain the number of bits of the architecture (32 or 64). + * The 7Zip executable path can also be changed (see at the end of the 'parameters.bat' file). + +3) Launch the builds by running the 'buildall.bat' script. + +4) Check if nothing went wrong: Have a look at the main log file (a file named `_wxWidgets-x.x.x.log` in the `logs` sub directory). It will contain the result of each executed command line. If a value is different than zero, there was a problem. + +Current compilers versions +-------------------------- + +The following versions of MinGW are actually used to create binaries (they all use Win32 threads): + + * MinGW-W64 GCC-7.3.0 using SJLJ exceptions for 32 bits architecture downloadable from [here](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/7.3.0/threads-win32/sjlj/i686-7.3.0-release-win32-sjlj-rt_v5-rev0.7z "MinGW-W64 GCC-7.3.0 i686 Win32 SJLJ") and SEH exceptions for 64 bits architecture downloadable from [here](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-win32/seh/x86_64-7.3.0-release-win32-seh-rt_v5-rev0.7z "MinGW-W64 GCC-7.3.0 x86_64 Win32 SEH") + * MinGW-W64 GCC-8.1.0 using SJLJ exceptions for 32 bits architecture downloadable from [here](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/i686-8.1.0-release-win32-sjlj-rt_v6-rev0.7z "MinGW-W64 GCC-8.1.0 i686 Win32 SJLJ") and SEH exceptions for 64 bits architecture downloadable from [here](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z "MinGW-W64 GCC-8.1.0 x86_64 Win32 SEH") + * MinGW-TDM GCC-9.2.0 downloadable from [here](https://jmeubank.github.io/tdm-gcc/articles/2020-03/9.2.0-release "TDM GCC-9.2.0") + * MSYS2 MinGW GCC-10.2.0 which is the last version installable using [MSYS2](https://www.msys2.org "www.msys2.org") package manager diff --git a/build/tools/mingw/buildall.bat b/build/tools/mingw/buildall.bat new file mode 100644 index 0000000000..c8c0c0396d --- /dev/null +++ b/build/tools/mingw/buildall.bat @@ -0,0 +1,21 @@ +@echo off + +rem Initialize general parameters +call parameters.bat + +rem Create output and logs directories if needed +if not exist %OUTPUTDIR% mkdir %OUTPUTDIR% +if not exist %LOGDIR% mkdir %LOGDIR% + +rem Initialize the main log file with the current date and time +echo %date% %time% : wxWidgets-%wxMAJOR_VERSION%.%wxMINOR_VERSION%.%wxRELEASE_NUMBER% build started > %MAINLOGFILE% + +rem Loop through all versions of the compiler +for %%c in ( 730 810 1020 920 ) do ( + rem For each version, create a 32 and a 64 bits build + for %%a in ( 32 64 ) do ( + call officialbuild.bat %%c %%a + ) +) + +echo %date% %time% : wxWidgets-%wxMAJOR_VERSION%.%wxMINOR_VERSION%.%wxRELEASE_NUMBER% build ended >> %MAINLOGFILE% diff --git a/build/tools/mingw/officialbuild.bat b/build/tools/mingw/officialbuild.bat new file mode 100644 index 0000000000..a0e25c4f7c --- /dev/null +++ b/build/tools/mingw/officialbuild.bat @@ -0,0 +1,95 @@ +@echo off + +rem Check if compiler version is present +if "%1" == "" goto :ERR_NOPARM +rem Check if architecture is present +if "%2" == "" goto :ERR_NOPARM + +rem Initialize specifics parameters related to the current build +call parameters.bat %1 %2 + +echo Starting official build for %COMPNAME% ( %COMPBINDIR% ) + +if %CLEANBUILD%==1 ( + echo - Cleanup + for %%d in ( lib\%COMPNAME%_dll build\msw\%COMPNAME%_mswuddll build\msw\%COMPNAME%_mswudll utils\wxrc\%COMPNAME%_mswudll ) do ( + if exist %WXDIR%\%%d ( + echo * removing %%d + rmdir /s /q %WXDIR%\%%d + ) + ) +) + +rem Common part of the build command line +set MAINCMDLINE=SHARED=1 CXXFLAGS="-fno-keep-inline-dllexport" OFFICIAL_BUILD=1 COMPILER_VERSION=%COMPVERS% +if "%2" == "64" ( + set MAINCMDLINE=%MAINCMDLINE% CPP="gcc -E -D_M_AMD64" +) +pushd %WXDIR%\build\msw +rem ============================================ Build debug version +title Debug for %COMPNAME% +echo - Debug +set BUILDLOGFILE=%LOGDIR%\wxWidgets-%wxMAJOR_VERSION%.%wxMINOR_VERSION%.%wxRELEASE_NUMBER%-%COMPNAME%-Debug +set CMDLINE=BUILD=debug %MAINCMDLINE% +echo mingw32-make -f makefile.gcc setup_h %CMDLINE% >%BUILDLOGFILE%-build.log +echo mingw32-make -f makefile.gcc setup_h %CMDLINE% >%BUILDLOGFILE%-errors.log +mingw32-make -f makefile.gcc setup_h %CMDLINE% 1>>%BUILDLOGFILE%-build.log 2>>%BUILDLOGFILE%-errors.log +set ERRLVL=%ERRORLEVEL% +echo %date% %time% : %COMPNAME%%XTRASPCS% Dbg setup : ERRORLEVEL=%ERRLVL% >> %MAINLOGFILE% +if not %ERRLVL%==0 goto :ENDBUILD +echo mingw32-make -j%JOBS% -f makefile.gcc %CMDLINE% >>%BUILDLOGFILE%-build.log +echo mingw32-make -j%JOBS% -f makefile.gcc %CMDLINE% >>%BUILDLOGFILE%-errors.log +mingw32-make -j%JOBS% -f makefile.gcc %CMDLINE% 1>>%BUILDLOGFILE%-build.log 2>>%BUILDLOGFILE%-errors.log +set ERRLVL=%ERRORLEVEL% +echo %date% %time% : %COMPNAME%%XTRASPCS% Dbg build : ERRORLEVEL=%ERRLVL% >> %MAINLOGFILE% +if not %ERRLVL%==0 goto :ENDBUILD +rem ============================================ Build release version +title Release for %COMPNAME% +echo - Release +set BUILDLOGFILE=%LOGDIR%\wxWidgets-%wxMAJOR_VERSION%.%wxMINOR_VERSION%.%wxRELEASE_NUMBER%-%COMPNAME%-Release +set CMDLINE=BUILD=release %MAINCMDLINE% +echo mingw32-make -f makefile.gcc setup_h %CMDLINE% >%BUILDLOGFILE%-build.log +echo mingw32-make -f makefile.gcc setup_h %CMDLINE% >%BUILDLOGFILE%-errors.log +mingw32-make -f makefile.gcc setup_h %CMDLINE% 1>>%BUILDLOGFILE%-build.log 2>>%BUILDLOGFILE%-errors.log +set ERRLVL=%ERRORLEVEL% +echo %date% %time% : %COMPNAME%%XTRASPCS% Rel setup : ERRORLEVEL=%ERRLVL% >> %MAINLOGFILE% +if not %ERRLVL%==0 goto :ENDBUILD +echo mingw32-make -j%JOBS% -f makefile.gcc %CMDLINE% >>%BUILDLOGFILE%-build.log +echo mingw32-make -j%JOBS% -f makefile.gcc %CMDLINE% >>%BUILDLOGFILE%-errors.log +mingw32-make -j%JOBS% -f makefile.gcc %CMDLINE% 1>>%BUILDLOGFILE%-build.log 2>>%BUILDLOGFILE%-errors.log +set ERRLVL=%ERRORLEVEL% +echo %date% %time% : %COMPNAME%%XTRASPCS% Rel build : ERRORLEVEL=%ERRLVL% >> %MAINLOGFILE% +if not %ERRLVL%==0 goto :ENDBUILD +rem ============================================ Build wxrc executable +title wxrc for %COMPNAME% +echo - wxrc.exe +set BUILDLOGFILE=%LOGDIR%\wxWidgets-%wxMAJOR_VERSION%.%wxMINOR_VERSION%.%wxRELEASE_NUMBER%-%COMPNAME%-wxrc +cd %WXDIR%\utils\wxrc +echo mingw32-make -j%JOBS% -f makefile.gcc %CMDLINE% >%BUILDLOGFILE%-build.log +echo mingw32-make -j%JOBS% -f makefile.gcc %CMDLINE% >%BUILDLOGFILE%-errors.log +mingw32-make -j%JOBS% -f makefile.gcc %CMDLINE% 1>>%BUILDLOGFILE%-build.log 2>>%BUILDLOGFILE%-errors.log +set ERRLVL=%ERRORLEVEL% +echo %date% %time% : %COMPNAME%%XTRASPCS% wxrc.exe : ERRORLEVEL=%ERRLVL% >> %MAINLOGFILE% +if not %ERRLVL%==0 goto :ENDBUILD +copy %WXDIR%\utils\wxrc\%COMPNAME%_mswudll\wxrc.exe %WXDIR%\lib\%COMPNAME%_dll\ +rem ============================================ Create archives +title Archives for %COMPNAME% +cd %WXDIR%\ +if exist %OUTPUTDIR%\%ARCHNAME%%COMPNAME%_Dev.7z del %OUTPUTDIR%\%ARCHNAME%%COMPNAME%_Dev.7z +%ZIP% a -t7z -mx4 -bb %OUTPUTDIR%\%ARCHNAME%%COMPNAME%_Dev.7z -r %COMPNAME%_dll +set ERRLVL=%ERRORLEVEL% +if exist %OUTPUTDIR%\%ARCHNAME%%COMPNAME%_ReleaseDLL.7z del %OUTPUTDIR%\%ARCHNAME%%COMPNAME%_ReleaseDLL.7z +%ZIP% a -t7z -mx4 -bb %OUTPUTDIR%\%ARCHNAME%%COMPNAME%_ReleaseDLL.7z -r -ir!lib\%COMPNAME%_dll\*.dll -xr!*ud_*.dll +set ERRLVL=%ERRLVL% / %ERRORLEVEL% +echo %date% %time% : %COMPNAME%%XTRASPCS% archives : ERRORLEVEL=%ERRLVL% >> %MAINLOGFILE% + +:ENDBUILD +popd +goto :EOF + +:ERR_NOPARM + echo. + echo ERROR: NO PARAMETER SUPPLIED: + echo officialbuildgcc.bat cmpVers arch + echo cmpVers = Compiler version (730, 810, 920, ...) + echo arch = architecture (32 or 64) diff --git a/build/tools/mingw/parameters.bat b/build/tools/mingw/parameters.bat new file mode 100644 index 0000000000..d6ea5d67e3 --- /dev/null +++ b/build/tools/mingw/parameters.bat @@ -0,0 +1,56 @@ +@echo off + +rem Number of jobs for parallels builds +if "%NUMBER_OF_PROCESSORS%" == "" set NUMBER_OF_PROCESSORS=2 +set /A JOBS=%NUMBER_OF_PROCESSORS%-1 + +rem Removing (if = 1) or not (otherwise) actuals build and lib dirs +set CLEANBUILD=1 + +rem Check if compiler version is present +if "%1" == "" goto :NOPARAMS +rem Check if architecture is present +if "%2" == "" goto :NOPARAMS + +rem Define compiler's bin directory +if "%1" == "1020" ( + set COMPBINDIR=G:\msys64\mingw%2\bin +) else ( + set COMPBINDIR=G:\MinGW%1-%2\bin +) +rem Define compiler's version string such as 810, 730_x64, 920TDM +rem Also define extra spaces for "aligned" logs lines +set COMPVERS=%1 +set XTRASPCS= : +if "%1" == "920" ( + set COMPVERS=%COMPVERS%TDM +) else ( + set XTRASPCS= %XTRASPCS% +) +if "%2" == "64" ( + set COMPVERS=%COMPVERS%_x64 +) else ( + set XTRASPCS= %XTRASPCS% +) +rem Define compiler's name, such as gcc810, gcc730_x64, gcc920TDM, ... +set COMPNAME=gcc%COMPVERS% +rem Simplified (but sufficient) PATH variable +set PATH=C:\Windows;C:\Windows\system32\;%COMPBINDIR% + +goto :EOF + +rem Generals parameters +:NOPARAMS +rem Normalized wxWidgets base dir +set WXDIR=%CD%\..\..\.. +for %%i in ("%WXDIR%") do SET "WXDIR=%%~fi" +rem wxWidgets version +call ..\msvs\getversion.bat +rem Logs and output +set LOGDIR=%CD%\logs +set OUTPUTDIR=%CD%\output +SET MAINLOGFILE=%LOGDIR%\_wxWidgets-%wxMAJOR_VERSION%.%wxMINOR_VERSION%.%wxRELEASE_NUMBER%.log +rem Base of each created zip archive +set ARCHNAME=wxMSW-%wxMAJOR_VERSION%.%wxMINOR_VERSION%.%wxRELEASE_NUMBER%_ +rem 7Zip executable +set ZIP="C:\Program Files\7-Zip\7z.exe"