-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild.bat
105 lines (87 loc) · 2.66 KB
/
build.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
99
100
101
102
103
104
105
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
CD /D %~dp0
CALL vcenv.bat
SET SAUCES=""
:PARSEPARAMS
IF "%~1"=="" GOTO START
IF "%~1"=="/SAUCES" (
SET SAUCES=%~2
SHIFT
)
SHIFT
GOTO :PARSEPARAMS
:START
set DIR=build
set GLFW=third_party\glfw\src
set TINYCTHREAD=third_party\tinycthread\source
set THIRD_PARTY_SRC= %GLFW%\context.c^
%GLFW%\init.c^
%GLFW%\input.c^
%GLFW%\monitor.c^
%GLFW%\vulkan.c^
%GLFW%\window.c^
%GLFW%\win32_init.c^
%GLFW%\win32_joystick.c^
%GLFW%\win32_monitor.c^
%GLFW%\win32_time.c^
%GLFW%\win32_thread.c^
%GLFW%\win32_window.c^
%GLFW%\wgl_context.c^
%GLFW%\egl_context.c^
%GLFW%\osmesa_context.c^
%TINYCTHREAD%\tinycthread.c^
third_party\miniz.c
:: set CFLAGS=/Z7 /W1 /D_GLFW_WIN32 /Ithird_party\glfw\include /I%TINYCTHREAD% /DTHREADED^
:: /D_CRT_SECURE_NO_WARNINGS
set CFLAGS=/O2 /W1 /D_GLFW_WIN32 /Ithird_party\glfw\include /I%TINYCTHREAD% /DTHREADED^
/D_CRT_SECURE_NO_WARNINGS
set sources=%THIRD_PARTY_SRC% candle.c
set subdirs=components systems formats utils vil ecs
FOR %%a IN (%subdirs%) DO @IF EXIST "%%a" (
FOR %%f IN (%%a\*.c) DO @IF EXIST "%%f" set sources=!sources! %%f
)
mkdir %DIR%\components
mkdir %DIR%\systems
mkdir %DIR%\utils
mkdir %DIR%\formats
mkdir %DIR%\vil
mkdir %DIR%\ecs
mkdir %DIR%\%GLFW%
mkdir %DIR%\%TINYCTHREAD%
IF NOT EXIST %DIR%\datescomp.exe (
cl buildtools\datescomp.c /Fe%DIR%\datescomp.exe /Fo%DIR%\datescomp.obj /O2
)
set objects=
FOR %%f IN (!sources!) DO @IF EXIST "%%f" (
set src=%DIR%\%%f
CALL set object=%%src:.c=.obj%%
%DIR%\datescomp.exe %%f !object! || (
cl /c "%%f" /Fo"!object!" %CFLAGS% || (
echo Error compiling %%f
GOTO END
)
)
CALL set objects=!objects! !object!
)
%DIR%\datescomp.exe buildtools\packager.c %DIR%\packager.exe || (
cl buildtools\packager.c %DIR%\third_party\miniz.obj /Fo%DIR%\packager.obj /Fe%DIR%\packager.exe /O2
)
set LIBS=gdi32.lib opengl32.lib kernel32.lib user32.lib shell32.lib candle\%DIR%\candle.lib candle\%DIR%\res.res
set RES=
FOR /d %%f IN (..\*.candle) DO (
call %%f\build.bat
set /p PLUGIN_LIBS=<%%f\build\libs
set LIBS=!LIBS! !PLUGIN_LIBS!
set /p PLUGIN_RES=<%%f\build\res
for %%S IN (!PLUGIN_RES!) DO (
set RES=!RES! %%f\%%~S
)
)
CALL %DIR%\packager.exe ..\!SAUCES! !RES!
mkdir %DIR%
echo !LIBS! > %DIR%\libs
ECHO 1 RCDATA "%DIR%\data.zip" > %DIR%\res.rc
rc %DIR%\res.rc
lib !objects! /out:"%DIR%\candle.lib"
:END