-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtranspileToGLSL.bat
More file actions
142 lines (114 loc) · 4.04 KB
/
transpileToGLSL.bat
File metadata and controls
142 lines (114 loc) · 4.04 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
@echo off
@set "OUT_DIR=docs"
rem this generates %OUT_DIR%/docs and %OUT_DIR%/include from docs_src
rem skip downto MAIN to have functions on top
GOTO:MAIN
:transpile
SETLOCAL ENABLEDELAYEDEXPANSION
set FILE_NAME=%~1
set SUB_CATEGORY=%~2
echo #define SUB_CATEGORY %SUB_CATEGORY% > input
echo #define COPYRIGHT 0 >> input
echo #include "docs_src/common.hlsl" >> input
type docs_src\%FILE_NAME%.hlsl >> input
cl /EP /C input > %OUT_DIR%\docs\%FILE_NAME%_%SUB_CATEGORY%.hlsl
echo #define SUB_CATEGORY %SUB_CATEGORY% > input
echo #include "include/s2h_glsl.hlsl" >> input
echo #include "docs_src/common.hlsl" >> input
type docs_src\%FILE_NAME%.hlsl >> input
cl /EP /C input > %OUT_DIR%\docs\%FILE_NAME%_%SUB_CATEGORY%.glsl
ENDLOCAL
EXIT /B 0
GATHER
:MAIN
@set "CURRENT=%cd%"
@rem xcopy include\s2h.hlsl docs\include\ /y
@rem find the latest Visual Studio installation
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%VSWHERE%" set "VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%vswhere%" (
echo "vswhere not found. Visual Studio installation required"
exit /b 1
)
for /f "usebackq tokens=*" %%i in (`
"%VSWHERE%" -latest -products * ^
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^
-property installationPath
`) do (
set "VSINSTALL=%%i"
)
@rem set up the VS environment (this make the 'cl' command visible)
if exist "%VSINSTALL%\VC\Auxiliary\Build\vcvarsall.bat" (
call "%VSINSTALL%\VC\Auxiliary\Build\vcvarsall.bat" x64
) else (
echo "Visual Studio (VC++) not found"
exit /b 1
)
@rem /P is to run the preprocessor
@rem /E is to run the preprocessor to stdout
@rem /EP is to run the preprocessor to stdout, no adding #line
@rem /C is to keep comments
@rem > to redirect to a file
@rem >> to redirect to a file
@rem xcopy dest*
@rem echo f | xcopy /y src dest
@rem >2 NUL to supress error messages e.g. folder already exists
@mkdir %OUT_DIR% 2> NUL
@mkdir docs\include 2> NUL
@mkdir docs\docs 2> NUL
@rem todo: refactor to have less repetition
@type include\s2h_glsl.hlsl > input
@type include\s2h.hlsl >> input
@cl /EP /C input > %OUT_DIR%\include\s2h.glsl
@cl /EP /C include\s2h.hlsl > %OUT_DIR%\include\s2h.hlsl
@type include\s2h_glsl.hlsl > input
@type include\s2h_scatter.hlsl >> input
@cl /EP /C input > %OUT_DIR%\include\s2h_scatter.glsl
@cl /EP /C include\s2h_scatter.hlsl > %OUT_DIR%\include\s2h_scatter.hlsl
@type include\s2h_glsl.hlsl > input
@type include\s2h_3d.hlsl >> input
@cl /EP /C input > %OUT_DIR%\include\s2h_3d.glsl
@cl /EP /C include\s2h_3d.hlsl > %OUT_DIR%\include\s2h_3d.hlsl
rem 0..7 = let subGather = "printTxt|printDatatype|shapes|radio|button|checkbox|slider|sliderRGB";
call:transpile gather_docs 0
call:transpile gather_docs 1
call:transpile gather_docs 2
call:transpile gather_docs 3
call:transpile gather_docs 4
call:transpile gather_docs 5
call:transpile gather_docs 6
call:transpile scatter_docs 0
call:transpile scatter_docs 1
call:transpile scatter_docs 2
call:transpile scatter_docs 3
call:transpile scatter_docs 4
call:transpile scatter_docs 5
call:transpile scatter_docs 6
call:transpile scatter_docs 7
call:transpile 2d_docs 0
call:transpile 2d_docs 1
call:transpile 2d_docs 2
call:transpile 2d_docs 3
call:transpile 2d_docs 4
call:transpile 2d_docs 5
call:transpile 2d_docs 6
call:transpile 2d_docs 7
call:transpile 2d_docs 8
call:transpile 2d_docs 9
call:transpile 2d_docs 10
call:transpile 3d_docs 0
call:transpile 3d_docs 1
call:transpile 3d_docs 2
call:transpile 3d_docs 3
call:transpile 3d_docs 4
call:transpile 3d_docs 5
call:transpile ui_docs 0
call:transpile ui_docs 1
call:transpile ui_docs 2
call:transpile ui_docs 3
call:transpile ui_docs 4
call:transpile ui_docs 5
call:transpile intro 0
@rem cleanup =============================================
cd %CURRENT%
@del input