@echo off

REM This script assumes we run it from the root of the repository.

SET ROOT=%CD%

SET FREETYPE_ROOT=%ROOT%\src\dependencies\freetype-2.12.1

SET INCS=
SET INCS=%INCS% -I%ROOT%\src\dependencies\freetype_build
SET INCS=%INCS% -I%FREETYPE_ROOT%\include

SET FILES=
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftsystem.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftinit.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftdebug.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftbase.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftbbox.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftglyph.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftbitmap.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\sfnt\sfnt.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\truetype\truetype.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\smooth\smooth.c
SET FILES=%FILES% %FREETYPE_ROOT%\src\psnames\psnames.c

if not exist "%ROOT%\build" mkdir %ROOT%\build
cd %ROOT%\build
if not exist "%ROOT%\build\freetype" mkdir %ROOT%\build\freetype
cd %ROOT%\build\freetype

del *.obj
cl -c -nologo -Zi -DFT2_BUILD_LIBRARY %INCS% %FILES%
lib -nologo -OUT:"freetype.lib" *.obj

cd %ROOT%\build
copy freetype\freetype.lib freetype.lib
