mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 15:14:35 +00:00
Windows build 2/2?
This commit is contained in:
parent
aebbe856c0
commit
263d6d525f
6 changed files with 261 additions and 17 deletions
85
build-windows.bat
Normal file
85
build-windows.bat
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
@echo off
|
||||
setlocal
|
||||
|
||||
REM ---------------------------------------------------------------------------
|
||||
REM Native Windows build with MSVC. No MSYS2 or MinGW shell required.
|
||||
REM
|
||||
REM Requirements:
|
||||
REM * Visual Studio 2019/2022 with the "Desktop development with C++"
|
||||
REM workload installed.
|
||||
REM * A GTK4 build for MSVC, for example the gvsbuild prebuilt package
|
||||
REM unzipped to C:\gtk (see README.md).
|
||||
REM
|
||||
REM If GTK lives somewhere other than C:\gtk, set GTK_ROOT first, e.g.
|
||||
REM set GTK_ROOT=D:\gtk
|
||||
REM ---------------------------------------------------------------------------
|
||||
|
||||
if not defined GTK_ROOT set "GTK_ROOT=C:\gtk"
|
||||
|
||||
REM --- 1. Locate Visual Studio and enter the 64-bit MSVC environment --------
|
||||
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
if not exist "%VSWHERE%" (
|
||||
echo [error] vswhere.exe not found.
|
||||
echo Install Visual Studio with the "Desktop development with C++"
|
||||
echo workload, then run this script again.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "VSPATH="
|
||||
for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSPATH=%%i"
|
||||
if not defined VSPATH (
|
||||
echo [error] No Visual Studio C++ installation found.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
call "%VSPATH%\VC\Auxiliary\Build\vcvars64.bat" >nul
|
||||
if errorlevel 1 (
|
||||
echo [error] Failed to initialise the MSVC environment.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM --- 2. Point the build at the GTK4 installation --------------------------
|
||||
set "PATH=%GTK_ROOT%\bin;%PATH%"
|
||||
set "PKG_CONFIG_PATH=%GTK_ROOT%\lib\pkgconfig;%PKG_CONFIG_PATH%"
|
||||
|
||||
set "PKG_CONFIG=pkg-config"
|
||||
where pkg-config >nul 2>nul
|
||||
if errorlevel 1 (
|
||||
where pkgconf >nul 2>nul
|
||||
if errorlevel 1 (
|
||||
echo [error] pkg-config/pkgconf was not found.
|
||||
echo Make sure GTK_ROOT points at a GTK4 install that contains
|
||||
echo bin\pkg-config.exe. Current GTK_ROOT: %GTK_ROOT%
|
||||
exit /b 1
|
||||
)
|
||||
set "PKG_CONFIG=pkgconf"
|
||||
)
|
||||
|
||||
REM --- 3. Collect the GTK4 flags in MSVC syntax -----------------------------
|
||||
set "GTK_CFLAGS="
|
||||
set "GTK_LIBS="
|
||||
for /f "usebackq delims=" %%c in (`%PKG_CONFIG% --cflags gtk4 --msvc-syntax`) do set "GTK_CFLAGS=%%c"
|
||||
for /f "usebackq delims=" %%l in (`%PKG_CONFIG% --libs gtk4 --msvc-syntax`) do set "GTK_LIBS=%%l"
|
||||
|
||||
if not defined GTK_CFLAGS (
|
||||
echo [error] pkg-config could not find gtk4.
|
||||
echo Check that "%PKG_CONFIG_PATH%" contains gtk4.pc.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM --- 4. Compile -----------------------------------------------------------
|
||||
echo Building maturita.exe with MSVC...
|
||||
cl /nologo /O2 /MD /W3 /std:c11 /D_CRT_SECURE_NO_WARNINGS ^
|
||||
%GTK_CFLAGS% maturita.c ^
|
||||
/Fe:maturita.exe ^
|
||||
/link /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup %GTK_LIBS%
|
||||
|
||||
if errorlevel 1 (
|
||||
echo [error] Build failed.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Built maturita.exe
|
||||
echo Run it from this terminal with: maturita.exe
|
||||
echo Or use run-windows.bat / double-click maturita.exe.
|
||||
Loading…
Add table
Add a link
Reference in a new issue