stagit-fork

a stagit fork compatible with Windows (original: https://codemadness.org/git/stagit)
git clone https://github.com/5hif7y/stagit.git
Log | Files | Refs | README | LICENSE

build.bat (2091B)


      1 @echo off
      2 setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
      3 
      4 :: compilation settings
      5 set CC=cl
      6 set CFLAGS= /D _CRT_SECURE_NO_WARNINGS /nologo /W3
      7 set LDFLAGS=/link /NOIMPLIB /NOEXP /LTCG git2.lib Advapi32.lib Winhttp.lib Ole32.lib Rpcrt4.lib Crypt32.lib zlib.lib pcre.lib
      8 
      9 :: common shared sources
     10 set COMPATSRC=reallocarray.c strlcat.c strlcpy.c
     11 
     12 :: main
     13 set "ARG=%~1"
     14 
     15 if "%ARG%"=="" (
     16   call :build_target stagit
     17   echo -----
     18   call :build_target stagit-index
     19   goto :eof
     20 )
     21 
     22 if /I "%ARG%"=="stagit" (
     23   call :build_target stagit
     24   goto :eof
     25 )
     26 
     27 if /I "%ARG%"=="stagit-index" (
     28   call :build_target stagit-index
     29   goto :eof
     30 )
     31 
     32 if /I "%ARG%"=="clean" (
     33   call :clean
     34   goto :eof
     35 )
     36 
     37 if /I "%ARG%"=="clean-all" (
     38   call :clean_all
     39   goto :eof
     40 )
     41 
     42 :: call help
     43 echo Comando desconocido: %ARG%
     44 call :show_help
     45 goto :eof
     46 
     47 :: success msg
     48 :success_msg
     49 powershell -Command "Write-Host 'Build success: %BIN%.' -ForegroundColor Green"
     50 goto:eof
     51 
     52 :: failure msg
     53 :failure_msg
     54 powershell -Command "Write-Host 'Build failed: %BIN% not found.' -ForegroundColor Red"
     55 goto :eof
     56 
     57 :: compilation function
     58 :build_target
     59 set SRC=%1.c
     60 set BIN=%1.exe
     61 echo Building %BIN%...
     62 %CC% /Fe:%BIN% %CFLAGS% %SRC% %COMPATSRC% %LDFLAGS%
     63 if exist %BIN% (
     64   call :success_msg
     65 ) else (
     66   call :failure_msg
     67 )
     68 goto :eof
     69 
     70 :: clean function
     71 :clean
     72 echo Cleaning *.obj...
     73 del /q *.obj 2>nul
     74 goto :eof
     75 
     76 :: clean all function
     77 :clean_all
     78 echo Cleaning *.obj and *.exe...
     79 del /q *.obj *.exe 2>nul
     80 goto :eof
     81 
     82 :: help function
     83 :show_help
     84   echo Unknown command: %1
     85   echo Usage:
     86   echo   build.bat               - build all
     87   echo   build.bat stagit        - build stagit.exe
     88   echo   build.bat stagit-index  - build stagit-index.exe
     89   echo   build.bat clean         - delete .obj files
     90   echo   build.bat clean-all     - delete .obj and .exe files
     91   echo.
     92   echo Required libraries:
     93   echo   [MSVC/Windows SDK]
     94   echo     Advapi32.lib Winhttp.lib Ole32.lib Rpcrt4.lib Crypt32.lib
     95   echo   [External]
     96   echo     git2.lib zlib.lib pcre.lib
     97   echo.
     98   echo Tip: I used and recommend VCPKG to install the external libraries.
     99 goto :eof
    100 
    101 endlocal
    102