Update scripts/build.bat
This commit is contained in:
parent
303192b198
commit
cb7d4242d4
1 changed files with 29 additions and 38 deletions
|
|
@ -1,53 +1,44 @@
|
||||||
@echo off
|
@echo off
|
||||||
rem 환경 변경이 이 스크립트 실행 안에만 머물도록 합니다.
|
setlocal enabledelayedexpansion
|
||||||
setlocal
|
|
||||||
|
|
||||||
rem Makefile과 POSIX 스크립트처럼 실행 파일을 build\에 둡니다.
|
|
||||||
if not exist build mkdir build
|
if not exist build mkdir build
|
||||||
|
|
||||||
rem Visual Studio 컴파일러가 있으면 우선 사용합니다.
|
|
||||||
where cl >nul 2>nul
|
where cl >nul 2>nul
|
||||||
if %errorlevel% equ 0 goto build_msvc
|
if !errorlevel! equ 0 (
|
||||||
|
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 "res=!errorlevel!"
|
||||||
|
popd
|
||||||
|
if !res! equ 0 (
|
||||||
|
goto success
|
||||||
|
) else (
|
||||||
|
exit /b !res!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
rem GCC가 설치되어 있고 PATH에서 보이면 다음 후보로 사용합니다.
|
|
||||||
where gcc >nul 2>nul
|
where gcc >nul 2>nul
|
||||||
if %errorlevel% equ 0 goto build_gcc
|
if !errorlevel! equ 0 (
|
||||||
|
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 !errorlevel! equ 0 (
|
||||||
|
goto success
|
||||||
|
) else (
|
||||||
|
exit /b !errorlevel!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
rem 세 번째 지원 Windows 컴파일러로 Clang을 사용합니다.
|
|
||||||
where clang >nul 2>nul
|
where clang >nul 2>nul
|
||||||
if %errorlevel% equ 0 goto build_clang
|
if !errorlevel! equ 0 (
|
||||||
|
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 !errorlevel! equ 0 (
|
||||||
|
goto success
|
||||||
|
) else (
|
||||||
|
exit /b !errorlevel!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
rem 지원되는 컴파일러를 찾지 못했으므로 명확한 메시지를 출력하고 중단합니다.
|
|
||||||
echo C compiler not found. Install Visual Studio Build Tools, GCC, or Clang.
|
echo C compiler not found. Install Visual Studio Build Tools, GCC, or Clang.
|
||||||
exit /b 1
|
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
|
:success
|
||||||
rem 모든 컴파일러 선택지가 공유하는 성공 경로입니다.
|
|
||||||
echo Build complete: build\gerbera.exe
|
echo Build complete: build\gerbera.exe
|
||||||
exit /b 0
|
exit /b 0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue