diff options
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | USAGE.md | 27 | ||||
-rw-r--r-- | build.bat | 100 |
3 files changed, 130 insertions, 10 deletions
@@ -13,16 +13,9 @@ Only core features of C99 were used: - long long; - restrict keyword; -# Compile flags +# Compilation. -``` -# clang gcc --std=c99 -lm -ffast-math - -# cl (i guess right now) - -/std:c99 /fp:fast -``` +Check [USAGE.md](USAGE.md). # Ungrateful @@ -45,7 +38,7 @@ Todo: - Random; - Noises; - Compression; -- Wide strings, u16/u32; +- Wide strings (internal); - Sorting; - Memory debugging; diff --git a/USAGE.md b/USAGE.md new file mode 100644 index 0000000..706b9c3 --- /dev/null +++ b/USAGE.md @@ -0,0 +1,27 @@ +# How to compile and use + +Note: it is early in development and there is no v1! + +It is build in a logic of unity-build, so all you need is to provide to a compiler the include folder and link path. + +So, for compiling you need to run build.bat / build.sh. Dependencies right now are just bash (build script) and gcc. + +It will create include folder and copy all of the headers, create lib folder and put the libs in here. + +# Usage + +- Don't use *_internal.h files, as they are only for implementation and could add fun things as windows.h + +# MSVC + +Here are warnings you should disable: + +``` +/wd4244 +``` + +Also here are defines: + +``` +/D _CRT_SECURE_NO_WARNINGS /D _UNICODE /D UNICODE +``` diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..1b8e58d --- /dev/null +++ b/build.bat @@ -0,0 +1,100 @@ +@echo off + +:: /GS - is sequrity check for buffer overruns. +:: /Oi - generate intrinsic functions (aka inline intrinsic). +:: /O1 /O2 - minimize size, minimize speed. +:: /Ox - subset of /O2, doesnt include. + +:: /GL - whole program optimizations. +:: /LTCG - link time codegen. it is linker option. +:: /cgthreads1 8 - how much thread cl.exe can use. + +:: /F {0} - sets stack size. + +:: outputs +:: /Fa{path} - asm file path. +:: /Fd{path} - pdb file path. +:: /Fe{path} - exe file path. +:: /Fo{path} - obj file path. + +:: /MT - defines _MT. uses LIBCMT.lib to resolve runtime symbols. +:: /MTd - defines _MT _DEBUG, uses LIBCMT.lib. +:: /MD - defines _MT _DLL. uses MSVCRT.lib. +:: /MDd - defines _MT _DLL _DEBUG. uses MSVCRT.lib. +:: /LD - implies /MT unless specified /MD. +:: /LDd - ... + +setlocal + +set "cc=cl.exe" +set "ar=lib.exe" + +set "bin_dir=bin\" +set "src_dir=src\" +set "obj_dir=obj\" +set "inc_dir=include\" +set "lib_dir=lib\" + +set "warn=/wd4244" +set "cdefines=/D _CRT_SECURE_NO_WARNINGS /D _UNICODE /D UNICODE" + +set "cflags=/nologo /std:c11 /utf-8 /W4 /WX- /diagnostics:column /TC /Zi /fp:fast" + +:: +:: ------------ +:: + +set "flag=/D DEBUG /MTd /Od /GS /MP" +set "_flag=/D NDEBUG /MT /Ox /GS- /MP /cgthreads8 /GL" + +:: +:: ------------ +:: + +if exist %bin_dir% ( rmdir /s /q %bin_dir% ) +if exist %obj_dir% ( rmdir /s /q %obj_dir% ) +if exist %inc_dir% ( rmdir /s /q %inc_dir% ) +if exist %lib_dir% ( rmdir /s /q %lib_dir% ) + +if not exist %bin_dir% ( mkdir %bin_dir% ) +if not exist %obj_dir% ( mkdir %obj_dir% ) +if not exist %inc_dir% ( mkdir %inc_dir% ) +if not exist %lib_dir% ( mkdir %lib_dir% ) + +%cc% %cflags% %warn% %flag% /c %src_dir%ungrateful.c /Fo%obj_dir%ungrateful.obj /Fd%obj_dir%ungrateful.pdb %cdefines% +%cc% %cflags% %warn% %flag% /I %src_dir% /c %src_dir%cynic.c /Fo%obj_dir%cynic.obj /Fd%obj_dir%cynic.pdb %cdefines% + +%ar% /nologo /OUT:lib\ungrateful.lib %obj_dir%ungrateful.obj +%ar% /nologo /OUT:lib\cynic.lib %obj_dir%cynic.obj + +for %%f in ("%src_dir%*.h") do ( + copy "%%f" "%inc_dir%%%~nxf" 1>nul +) + +echo: + +set "link_param=/link %lib_dir%ungrateful.lib" +for %%f in ("tests\un\*.c") do ( + %cc% %cflags% %warn% %flag% %cdefines% %%f /I%inc_dir% /Fo%obj_dir% /Fd%bin_dir% /Fe%bin_dir% %link_param% +) + +set "link_param=/link %lib_dir%ungrateful.lib %lib_dir%cynic.lib" +for %%f in ("tests\cyn\*.c") do ( + %cc% %cflags% %warn% %flag% %cdefines% %%f /I%inc_dir% /Fo%obj_dir% /Fd%bin_dir% /Fe%bin_dir% %link_param% +) + +echo: + +for %%f in ("%bin_dir%*.exe") do ( + %%f + + if %errorlevel% == 0 ( + echo [DONE] %%f + ) else ( + echo [FAIL] %%f + ) +) + +echo: +echo Done! +endlocal |