Gerbera/scripts/build.bat
2026-06-25 13:48:22 +09:00

53 lines
1.8 KiB
Batchfile

@echo off
rem 환경 변경이 이 스크립트 실행 안에만 머물도록 합니다.
setlocal
rem Makefile과 POSIX 스크립트처럼 실행 파일을 build\에 둡니다.
if not exist build mkdir build
rem Visual Studio 컴파일러가 있으면 우선 사용합니다.
where cl >nul 2>nul
if %errorlevel% equ 0 goto build_msvc
rem GCC가 설치되어 있고 PATH에서 보이면 다음 후보로 사용합니다.
where gcc >nul 2>nul
if %errorlevel% equ 0 goto build_gcc
rem 세 번째 지원 Windows 컴파일러로 Clang을 사용합니다.
where clang >nul 2>nul
if %errorlevel% equ 0 goto build_clang
rem 지원되는 컴파일러를 찾지 못했으므로 명확한 메시지를 출력하고 중단합니다.
echo C compiler not found. Install Visual Studio Build Tools, GCC, or Clang.
exit /b 1
:build_msvc
rem MSVC는 build\ 안에 gerbera.exe를 쓰고 bcrypt.lib를 명시적으로 링크합니다.
pushd build
cl /nologo /std:c11 /O2 /W4 /I..\include ^
..\src\main.c ..\src\encrypt.c ..\src\decrypt.c ..\src\cipher.c ^
/Fe:gerbera.exe bcrypt.lib
set "result=%errorlevel%"
popd
if not %result% equ 0 exit /b %result%
goto success
:build_gcc
rem GCC는 POSIX 빌드와 같은 경고 옵션을 쓰고 bcrypt를 링크합니다.
gcc -Iinclude -std=c11 -O2 -Wall -Wextra -Wpedantic ^
src\main.c src\encrypt.c src\decrypt.c src\cipher.c ^
-o build\gerbera.exe -lbcrypt
if not %errorlevel% equ 0 exit /b %errorlevel%
goto success
:build_clang
rem Clang은 이 작은 프로젝트에서 GCC 방식 명령줄을 그대로 따릅니다.
clang -Iinclude -std=c11 -O2 -Wall -Wextra -Wpedantic ^
src\main.c src\encrypt.c src\decrypt.c src\cipher.c ^
-o build\gerbera.exe -lbcrypt
if not %errorlevel% equ 0 exit /b %errorlevel%
:success
rem 모든 컴파일러 선택지가 공유하는 성공 경로입니다.
echo Build complete: build\gerbera.exe
exit /b 0