segatools/msvc-build.bat
GEEKiDoS c80f903cf8 Fix build with Microsoft Visual C++, Fix gfxhook and felica issue (#48)
I just wanna say that It is a SHAME that a Windows ONLY project was not able to build without MINGW
Also where's the missing `3mpxsc.h` in diva hook?

This also fixes the window size issue from hook_CreateWindowExA in gfxhook
And Fixes felica issue as described in #45

Reviewed-on: #48
Reviewed-by: Dniel97 <dniel97@noreply.gitea.tendokyu.moe>
Co-authored-by: GEEKiDoS <geek_ds@foxmail.com>
Co-committed-by: GEEKiDoS <geek_ds@foxmail.com>
2024-11-11 16:28:24 +00:00

129 lines
3.3 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
set BUILD_DIR=build
set BUILD_DIR_32=%BUILD_DIR%\build32
set BUILD_DIR_64=%BUILD_DIR%\build64
set BUILD_DIR_ZIP=%BUILD_DIR%\zip
set DIST_DIR=dist
set DOC_DIR=doc
REM Set your Visual Studio install path if Visual Studio installation can not be detected
set VS_INSTALLATION=C:\Program Files\Microsoft Visual Studio\2022\Community
if /I "%1"=="build" (
call :detect-visual-studio
if ERRORLEVEL 2 exit /b
if ERRORLEVEL 1 (
echo Failed to detect Visual Studio installation path.
echo.
echo If Visual Studio is installed then edit VS_INSTALLATION in this file
echo to manually specify Visual Studio install path.
exit /b
)
call :detect-meson
if ERRORLEVEL 1 (
echo Meson is not installed.
exit /b
)
set VSVARSALL=!VSVARSALL!
set MESON=!MESON!
call :build
echo.
echo Build done!
exit /b
)
if /I "%1"=="zip" (
powershell -NoProfile -ExecutionPolicy Bypass -Command "& './package.ps1'"
exit /b
)
echo %~nx0 [action]
echo build: Build the for both x86 and x64
echo zip: Make zip file
exit /b
rem This should works for Visual Studio 2017+
:detect-visual-studio (
rem Who the hell on earth is still using a 32bit Windows in 2024
if "%ProgramFiles(x86)%"=="" (
set VSWHERE="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
) else (
set VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
)
if exist %VSWHERE% (
REM get vcvarsall by using vswhere
set VSVARSALL=""
for /f "tokens=* usebackq" %%i in (`%VSWHERE% -find VC\Auxiliary\Build\vcvarsall.bat`) do set VSVARSALL="%%i"
) else (
REM fallback to old method
set VSVARSALL="%VS_INSTALLATION%\VC\Auxiliary\Build\vcvarsall.bat"
)
:check-vcvarsall
if /i %VSVARSALL%=="" (
echo Microsoft Visual C++ Component is not installed
echo Install it from Visual Studio Installer
exit /b 2
)
rem if a path is returned by vswhere, then it's sure that the result path exists
rem if path not exists than it was assumed from VS_INSTALLATION
if not exist %VSVARSALL% (
echo vsvarsall.bat not exists in VS_INSTALLATION,
echo either Visual C++ Component is not installed
echo or VS_INSTALLATION is wrong.
exit /b 1
)
exit /b 0
)
:detect-meson (
for /f "tokens=* usebackq" %%i in (`where meson`) do set MESON="%%i"
if not exist %MESON% (
exit /b 1
)
exit /b 0
)
:build (
:build_x64 (
call %VSVARSALL% x64
if exist %BUILD_DIR_64% (
%MESON% setup %BUILD_DIR_64% --backend vs --buildtype release --reconfigure
) else (
%MESON% setup %BUILD_DIR_64% --backend vs --buildtype release
)
pushd %BUILD_DIR_64%
msbuild /m /p:Configuration=release /p:Platform=x64 segatools.sln
popd
)
:build_x86 (
call %VSVARSALL% x86
if exist %BUILD_DIR_32% (
%MESON% setup %BUILD_DIR_32% --backend vs --buildtype release --reconfigure
) else (
%MESON% setup %BUILD_DIR_32% --backend vs --buildtype release
)
pushd %BUILD_DIR_32%
msbuild /m /p:Configuration=release /p:Platform=Win32 segatools.sln
popd
)
:end (
exit /b
)
)