Skip to content

Commit

Permalink
GH-19: Unified Windows build script
Browse files Browse the repository at this point in the history
  • Loading branch information
negrutiu committed May 28, 2024
1 parent 50cd8df commit c6daeb5
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 57 deletions.
73 changes: 73 additions & 0 deletions _build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
REM :: Marius Negrutiu (marius.negrutiu@protonmail.com)

@echo off
setlocal enabledelayedexpansion
echo.

cd /d "%~dp0"
set original_path=%PATH%

REM | build.bat [mingw|msvc] [debug|release] [win32|amd64|x86|x64] [unicode|ansi]

set compiler=mingw
set configuration=Release
set platform=x64
set charset=unicode

:arg
if "%~1" equ "" goto :arg_end
if /i "%~1" equ "mingw" set compiler=mingw
if /i "%~1" equ "msvc" set compiler=msvc
if /i "%~1" equ "debug" set configuration=Debug
if /i "%~1" equ "release" set configuration=Release
if /i "%~1" equ "win32" set platform=x86
if /i "%~1" equ "x86" set platform=x86
if /i "%~1" equ "amd64" set platform=x64
if /i "%~1" equ "x64" set platform=x64
if /i "%~1" equ "unicode" set charset=unicode
if /i "%~1" equ "ansi" set charset=ansi
shift /1
goto :arg
:arg_end

if "%platform%" neq "x86" set charset=unicode

title %configuration%-%compiler%-%platform%-%charset%
echo --- compiler = %compiler%
echo --- configuration = %configuration%
echo --- platform = %platform%
echo --- charset = %charset%

if "%compiler%" equ "mingw" goto :mingw
if "%compiler%" equ "msvc" goto :msvc

:: -------------------------------------------------------------------------------

:mingw
if "%platform%" equ "x86" if not exist "%mingw%\bin\gcc.exe" set MINGW=%SystemDrive%\msys2\mingw32
if "%platform%" equ "x86" if not exist "%mingw%\bin\gcc.exe" set MINGW=%SystemDrive%\msys64\mingw32
if "%platform%" equ "x64" if not exist "%mingw%\bin\gcc.exe" set MINGW=%SystemDrive%\msys2\mingw64
if "%platform%" equ "x64" if not exist "%mingw%\bin\gcc.exe" set MINGW=%SystemDrive%\msys64\mingw64
echo --- mingw = %mingw%
if not exist "%mingw%\bin\gcc.exe" echo ERROR: Missing "%mingw%\bin\gcc.exe" && exit /b 2
set PATH=%mingw%\bin;%PATH%

echo.
gcc --version

set platform_nsis=%platform%
if "%platform_nsis%" equ "x64" set platform_nsis=amd64

echo ^> mingw32-make.exe ARCH=%platform% CHAR=%charset% OUTDIR="%~dp0%configuration%-%compiler%-%platform_nsis%-%charset%" CONFIG=%configuration% clean all
mingw32-make.exe ARCH=%platform% CHAR=%charset% OUTDIR="%~dp0%configuration%-%compiler%-%platform_nsis%-%charset%" CONFIG=%configuration% clean all || exit /b !errorlevel!
goto :end

:: -------------------------------------------------------------------------------

:msvc
echo TODO
goto :end

:end
echo all done. errorlevel %errorlevel%
REM pause
60 changes: 3 additions & 57 deletions _build_mingw_Release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,7 @@ REM :: Marius Negrutiu (marius.negrutiu@protonmail.com)

@echo off
setlocal enabledelayedexpansion
echo.

if not exist "%MINGW32%\bin\gcc.exe" set MINGW32=%MINGW32_INSTDIR%
if not exist "%MINGW32%\bin\gcc.exe" set MINGW32=%SystemDrive%\msys2\mingw32
if not exist "%MINGW32%\bin\gcc.exe" set MINGW32=%SystemDrive%\msys64\mingw32

if not exist "%MINGW64%\bin\gcc.exe" set MINGW64=%MINGW64_INSTDIR%
if not exist "%MINGW64%\bin\gcc.exe" set MINGW64=%SystemDrive%\msys2\mingw64
if not exist "%MINGW64%\bin\gcc.exe" set MINGW64=%SystemDrive%\msys64\mingw64

set ORIGINAL_PATH=%PATH%

cd /d "%~dp0"

:x86
if not exist "%MINGW32%\bin\gcc.exe" echo ERROR: Missing "%MINGW32%" && pause && exit /B 2
set PATH=%MINGW32%\bin;%ORIGINAL_PATH%

echo.
echo -------------------------------------------------------------------
set OUTDIR=%~dp0Release-mingw-x86-ansi
echo %OUTDIR%
title %OUTDIR%
echo -------------------------------------------------------------------
pushd "%~dp0src\nscurl"
mingw32-make.exe ARCH=x86 CHAR=ANSI OUTDIR=%OUTDIR% clean all
popd
if %errorlevel% neq 0 pause && exit /B %errorlevel%

echo.
echo -------------------------------------------------------------------
set OUTDIR=%~dp0Release-mingw-x86-unicode
echo %OUTDIR%
title %OUTDIR%
echo -------------------------------------------------------------------
pushd "%~dp0src\nscurl"
mingw32-make.exe ARCH=x86 CHAR=Unicode OUTDIR=%OUTDIR% clean all
popd
if %errorlevel% neq 0 pause && exit /B %errorlevel%


:amd64
if not exist "%MINGW64%\bin\gcc.exe" echo ERROR: Missing "%MINGW64%" && pause && exit /B 2
set PATH=%MINGW64%\bin;%ORIGINAL_PATH%

echo.
echo -------------------------------------------------------------------
set OUTDIR=%~dp0Release-mingw-amd64-unicode
echo %OUTDIR%
title %OUTDIR%
echo -------------------------------------------------------------------
pushd "%~dp0src\nscurl"
mingw32-make.exe ARCH=x64 CHAR=Unicode OUTDIR=%OUTDIR% clean all
popd
if %errorlevel% neq 0 pause && exit /B %errorlevel%

echo.
REM pause
call "%~dp0_build.bat" mingw release x86 unicode || exit /b !errorlevel!
call "%~dp0_build.bat" mingw release x86 ansi || exit /b !errorlevel!
call "%~dp0_build.bat" mingw release x64 unicode || exit /b !errorlevel!

0 comments on commit c6daeb5

Please sign in to comment.