-
Notifications
You must be signed in to change notification settings - Fork 3
/
build_base.bat
98 lines (75 loc) · 2.82 KB
/
build_base.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@ECHO off
SetLocal EnableDelayedExpansion
IF NOT EXIST bin mkdir bin
IF NOT EXIST bin\int mkdir bin\int
IF NOT EXIST bin\int\base mkdir bin\int\base
IF NOT EXIST bin\int\opt mkdir bin\int\opt
del /S /Q bin\int\opt\*
IF EXIST bin\codebase.lib del /Q bin\codebase.lib
REM call vcvarsall.bat x64
SET cc=clang
REM ------------------
REM Options
REM ------------------
SET Use_Render2D=false
SET Use_Physics2D=false
SET Use_UI=false
SET backend=BACKEND_D3D11
REM ==============
if %cc% == cl.exe (
SET compiler_flags=/Zc:preprocessor /wd4090 /wd5105 /nologo /DEBUG /c
SET include_flags=/I.\source\ /I.\third_party\include\ /I.\third_party\source\
SET output_flag=/Fo.\bin\int
SET defines=/D_DEBUG /D_CRT_SECURE_NO_WARNINGS /D%backend%
SET ar=lib.exe /out:bin\codebase.lib
)
if %cc% == clang (
SET compiler_flags=-c -Wall -Wvarargs -Werror -Wno-unused-function -Wno-format-security -Wno-incompatible-pointer-types-discards-qualifiers -Wno-unused-but-set-variable -Wno-int-to-void-pointer-cast
SET include_flags=-Isource -Ithird_party/include -Ithird_party/source
SET output_flag=-obin/int
SET defines=-D_DEBUG -D_CRT_SECURE_NO_WARNINGS -D%backend%
SET ar=llvm-ar -rc bin/codebase.lib
)
REM ==============
REM SET compiler_flags=!compiler_flags! -fsanitize=address
REM ==============
REM optional layers
if %Use_Render2D% == true (
ECHO Optional Layer Selected: Render2D
SET c_filenames=!c_filenames! source\opt\render_2d.c
%cc% %compiler_flags% source\opt\render_2d.c %defines% %include_flags% %output_flag%/opt/render_2d.obj
)
if %Use_Physics2D% == true (
ECHO Optional Layer Selected: Physics2D
SET c_filenames=!c_filenames! source\opt\phys_2d.c
%cc% %compiler_flags% source\opt\phys_2d.c %defines% %include_flags% %output_flag%/opt/phys_2d.obj
)
if %Use_UI% == true (
ECHO Optional Layer Selected: UI
SET c_filenames=!c_filenames! source\opt\ui.c
%cc% %compiler_flags% source\opt\ui.c %defines% %include_flags% %output_flag%/opt/ui.obj
)
REM ==============
REM ------------------
REM Main Project
REM ------------------
REM ==============
FOR %%f in (source\base\*.c) do (
%cc% %compiler_flags% %%~dpf/%%~nf.c %defines% %include_flags% %output_flag%/base/%%~nf.obj
)
FOR %%f in (source\impl\*.c) do (
%cc% %compiler_flags% %%~dpf/%%~nf.c %defines% %include_flags% %output_flag%/base/%%~nf.obj
)
FOR %%f in (source\core\*.c) do (
%cc% %compiler_flags% %%~dpf/%%~nf.c %defines% %include_flags% %output_flag%/base/%%~nf.obj
)
FOR %%f in (source\os\*.c) do (
%cc% %compiler_flags% %%~dpf/%%~nf.c %defines% %include_flags% %output_flag%/base/%%~nf.obj
)
REM ==============
REM Gets list of all C files
SET obj_filenames=
FOR %%f in (bin\int\base\*.obj) do SET obj_filenames=!obj_filenames! %%f
FOR %%f in (bin\int\opt\*.obj) do SET obj_filenames=!obj_filenames! %%f
ECHO Building codebase.lib...
%ar% %obj_filenames%