tools/old/build_windows.bat
author Simon McVittie <smcv@debian.org>
Mon, 12 Sep 2022 10:40:53 -0400
branch1.0.0
changeset 15859 7b1d6dfa3173
parent 13511 b62b14aa88d4
permissions -rw-r--r--
Remove FindSDL2 find-module, use sdl2-config.cmake instead This requires SDL >= 2.0.4. Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was not itself built using CMake: it installs a sdl2-config.cmake file to ${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and library, analogous to a pkg-config .pc file. As a result, we no longer need to copy/paste a "find-module package" to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2). Find-module packages are now discouraged by the CMake developers, in favour of having upstream projects behave as config-file packages. This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR and SDL2_LIBRARY, but the standard behaviour for config-file packages is to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword to make sure we search in config-file package mode, and will not find a FindSDL2.cmake in some other directory that implements the old interface. In addition to deleting redundant code, this avoids some assumptions in FindSDL2 about the layout of a SDL installation. The current libsdl2-dev package in Debian breaks those assumptions; this is considered a bug and will hopefully be fixed soon, but it illustrates how fragile these assumptions can be. We can be more robust against different installation layouts by relying on SDL's own CMake integration. When linking to a copy of CMake in a non-standard location, users can now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point to it; previously, these users would have used the SDL2DIR environment variable. This continues to be unnecessary if using matching system-wide installations of CMake and SDL2, for example both from Debian.

:: WARNNG WARNING WARNING ::
:: This Batch script is BROKEN and EXTREMELY OUTDATED!
:: It does not work with latest version and needs a complete redo or removal.
:: Its functionality has been disabled.

:: Print dummy text and return.
echo Sorry, this script is outdated. You're on your own.
exit


::::::::::::::::::::::::::::::
:: Old script code follows ...
::::::::::::::::::::::::::::::
@echo off
::edit these variables if you need
set PASCAL=C:\FPC\2.6.0\bin\i386-win32\
:: FIXME: Go Qt 5
set QTDIR=C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin
set PATH=%PATH%;%PASCAL%
set BUILD_TYPE="Debug"

:setup
set CURRDIR="%CD%"
cd ..

echo Fetching all DLLs...
if %BUILD_TYPE%=="Debug" (
    for %%G in (QtCored4 QtGuid4 QtNetworkd4) do xcopy /d/y %QTDIR%\%%G.dll %CD%\bin\
)
:: should you libgcc dynamically you should try adding libgcc_s_dw2-1 and mingwm10
:: FIXME: Use Qt5
for %%G in (QtCore4 QtGui4 QtNetwork4) do (
    xcopy /d/y %QTDIR%\%%G.dll %CD%\bin\
)

:: FIXME: Use SDL 2.0
if not exist %CD%\misc\winutils\bin\ mkdir %CD%\misc\winutils\bin\
if not exist %CD%\misc\winutils\bin\SDL.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://www.libsdl.org/release/SDL-1.2.15-win32.zip %CD%\misc\winutils\bin
if not exist %CD%\misc\winutils\bin\SDL_image.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.12-win32.zip %CD%\misc\winutils\bin
if not exist %CD%\misc\winutils\bin\SDL_net.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://www.libsdl.org/projects/SDL_net/release/SDL_net-1.2.8-win32.zip %CD%\misc\winutils\bin
if not exist %CD%\misc\winutils\bin\SDL_mixer.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.12-win32.zip %CD%\misc\winutils\bin
if not exist %CD%\misc\winutils\bin\SDL_ttf.dll cscript %CD%\tools\w32DownloadUnzip.vbs  http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-2.0.11-win32.zip %CD%\misc\winutils\bin

::for video recording
:: FIXME: googlecode.com is defunct.
if not exist %CD%\misc\winutils\bin\avformat-54.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://hedgewars.googlecode.com/files/libav-win32-20121022-dll.zip %CD%\misc\winutils\bin

::this is needed because fpc png unit hardcodes libpng-1.2.12
if not exist %CD%\misc\winutils\bin\libpng13.dll copy /y %CD%\misc\winutils\bin\libpng15-15.dll %CD%\misc\winutils\bin\libpng13.dll

xcopy /d/y %CD%\misc\winutils\bin\*.dll %CD%\bin\

::setting up the environment...
call %QTDIR%\qtenv2.bat

echo Running cmake...
set ERRORLEVEL=
cmake . -G "MinGW Makefiles" -DPNG_LIBRARY="%CD%\misc\winutils\bin\libpng13.dll" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_PREFIX_PATH="%CD%\misc\winutils\\"
:: prefix should be last

if %ERRORLEVEL% NEQ 0 goto exitpoint

echo Running make...
set ERRORLEVEL=
mingw32-make VERBOSE=1
if %ERRORLEVEL% NEQ 0 goto exitpoint

echo Installing...
set ERRORLEVEL=
mingw32-make install > nul
if %ERRORLEVEL% NEQ 0 goto exitpoint

echo Creating commodity shortcut...
copy /y %CD%\misc\winutils\Hedgewars.lnk C:%HOMEPATH%\Desktop\Hedgewars.lnk

echo ALL DONE, Hedgewars has been successfully compiled and installed

:exitpoint
cd %CURRDIR%
pause