Different build script

This commit is contained in:
bumbread 2022-06-07 00:17:14 +11:00
parent b7c72f49ea
commit 3dba3a64aa
5 changed files with 48 additions and 16 deletions

View File

@ -1,23 +1,54 @@
@echo off @echo off
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
set CIABATTA_OPTIONS=-Iinc -Wall -g -gcodeview -nodefaultlibs -D_CRT_SECURE_NO_WARNINGS :: Make sure that if I ctrl+c out of the script the dir is popped
set PLATFORM=win32 :: If there's anything that requires user input, this script will break
if NOT "%1"=="fast" ( :: in that case I recommend you removing the 'echo y' part.
:: although you will have to confirm termination of the script twice
if "%~1" neq "_start_" (
pushd %~pd0
echo y | cmd /c "%~f0" _start_ %*
popd
exit /b
)
shift /1
del ciabatta.lib set CIABATTA_OPTIONS=-Iinc -Wall -g -gcodeview -nodefaultlibs -D_CRT_SECURE_NO_WARNINGS
set PLATFORM=win
if "%1"=="fast" (
goto :skip_crt_compilation
)
:: For each C file in code/ we check whether it's OS-dependent.
:: If so, we check whether the platform is the chosen one. If not, we ignore
:: that file (set ok=0). Otherwise we compile it.
:: Man, batch files are sure scary, when you try to do something serious
:: it took me a lot of time to figure out how to write this if it breaks
:: im gonna be seriously disappointed :kekw:
del ciabatta.lib 2> nul
for /R code %%F in (*.c) do ( for /R code %%F in (*.c) do (
set ok=1
set os_dependent=0
set is_cur_os=0
echo %%F | findstr /c:"%~pd0code\os" > nul
if !errorlevel! neq 1 (
set os_dependent=1
)
echo %%F | findstr /c:"%~pd0code\os\%PLATFORM%" > nul
if !errorlevel! neq 1 (
set is_cur_os=1
)
if "!os_dependent!"=="1" if "!is_cur_os!"=="0" (
set ok=0
)
if "!ok!"=="1" (
echo %%F echo %%F
clang -c -o build\%%~nF.obj %%F %CIABATTA_OPTIONS% clang -c -o build\%%~nF.obj %%F %CIABATTA_OPTIONS%
) )
for /R platform\%PLATFORM% %%F in (*.c) do (
echo %%F
clang -c -o build\%%~nF.obj %%F %CIABATTA_OPTIONS%
) )
llvm-ar rc ciabatta.lib build\*.obj llvm-ar rc ciabatta.lib build\*.obj
del build\*.obj del build\*.obj
)
:skip_crt_compilation
echo Compiling test.. echo Compiling test..
clang test\test.c ciabatta.lib -std=c11 -lkernel32 -luser32 -lshell32 -nostdlib %CIABATTA_OPTIONS% clang test\test.c ciabatta.lib -std=c11 -lkernel32 -luser32 -lshell32 -nostdlib %CIABATTA_OPTIONS%

View File

@ -72,3 +72,4 @@ void *realloc(void *ptr, size_t size) {
void *buffer = HeapReAlloc(_heap, 0, ptr, size); void *buffer = HeapReAlloc(_heap, 0, ptr, size);
return buffer; return buffer;
} }