-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun_all_examples.cmd
More file actions
196 lines (166 loc) · 4.29 KB
/
Copy pathrun_all_examples.cmd
File metadata and controls
196 lines (166 loc) · 4.29 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
SET ScriptPath=%~n0[%~x0]
SET ScriptDir=%~dp0
IF DEFINED SIS_CMAKE_BUILD_DIR (
SET CMakeDir=%SIS_CMAKE_BUILD_DIR%
) ELSE (
SET CMakeDir=%ScriptDir%_build
)
SET ListOnly=0
SET RunMake=1
SET SkipInteractive=0
SET BuildConfig=Release
IF DEFINED CMAKE_BUILD_TYPE SET BuildConfig=%CMAKE_BUILD_TYPE%
:: #########################################################
:: command-line handling
:parse_args
IF "%~1"=="" GOTO args_done
IF /I "%~1"=="--help" GOTO show_help
IF /I "%~1"=="-l" (
SET ListOnly=1
GOTO next_arg
)
IF /I "%~1"=="--list-only" (
SET ListOnly=1
GOTO next_arg
)
IF /I "%~1"=="-M" (
SET RunMake=0
GOTO next_arg
)
IF /I "%~1"=="--no-make" (
SET RunMake=0
GOTO next_arg
)
IF /I "%~1"=="--skip-interactive" (
SET SkipInteractive=1
GOTO next_arg
)
ECHO %ScriptPath%: unrecognised argument '%~1'; use --help for usage 1>&2
EXIT /B 1
:next_arg
SHIFT
GOTO parse_args
:args_done
:: #########################################################
:: main()
SET status=0
IF %RunMake% NEQ 0 (
IF %ListOnly% EQU 0 (
ECHO Executing build and then running all example programs
CALL :do_build
IF ERRORLEVEL 1 SET status=1
)
) ELSE (
IF NOT EXIST "%CMakeDir%\CMakeCache.txt" (
ECHO %ScriptPath%: cannot run in '--no-make' mode without a previous successful build step 1>&2
EXIT /B 1
)
)
IF %status% EQU 0 (
IF NOT EXIST "%CMakeDir%\examples" (
ECHO %ScriptPath%: examples build tree not found at '%CMakeDir%\examples' 1>&2
ENDLOCAL
EXIT /B 1
)
IF %ListOnly% NEQ 0 (
ECHO Listing all example programs
) ELSE (
ECHO Running all example programs
)
FOR /F "usebackq delims=" %%f IN (`DIR /A:-D /B /S "%CMakeDir%\examples\*.exe" 2^>NUL`) DO (
CALL :is_skipped_interactive "%%~nxf"
IF !skip_example! EQU 1 (
IF !ListOnly! NEQ 0 (
ECHO would skip %%f: (interactive; --skip-interactive)
) ELSE (
ECHO.
ECHO skipping %%f: (interactive; --skip-interactive)
)
) ELSE IF !ListOnly! NEQ 0 (
ECHO would execute %%f:
) ELSE (
ECHO.
ECHO executing %%f:
CALL "%%f"
IF ERRORLEVEL 1 (
SET status=1
GOTO examples_done
)
)
)
)
:examples_done
IF !status! NEQ 0 (
ENDLOCAL
EXIT /B 1
)
ENDLOCAL
EXIT /B 0
:: #########################################################
:: helpers
:is_skipped_interactive
SET skip_example=0
IF %SkipInteractive% EQU 0 EXIT /B 0
IF NOT EXIST "%ScriptDir%.github\ci_skip_interactive_examples.txt" EXIT /B 0
SET "exe_name=%~n1"
FOR /F "usebackq eol=# tokens=1" %%s IN ("%ScriptDir%.github\ci_skip_interactive_examples.txt") DO (
SET "skip_name=%%s"
SET "skip_name=!skip_name: =!"
IF /I "!skip_name!"=="%exe_name%" SET skip_example=1
IF /I "!skip_name!"=="%~nx1" SET skip_example=1
)
EXIT /B 0
:do_build
IF DEFINED SIS_CMAKE_MAKE_COMMAND (
PUSHd "%CMakeDir%"
CALL %SIS_CMAKE_MAKE_COMMAND%
SET build_status=!ERRORLEVEL!
POPD
EXIT /B !build_status!
)
IF EXIST "%CMakeDir%\Makefile" (
PUSHd "%CMakeDir%"
IF DEFINED MSYSTEM (
mingw32-make.exe
) ELSE (
make
)
SET build_status=!ERRORLEVEL!
POPD
EXIT /B !build_status!
)
cmake --build "%CMakeDir%" --config %BuildConfig%
EXIT /B %ERRORLEVEL%
:show_help
IF EXIST "%ScriptDir%.sis\script_info_lines.txt" (
type "%ScriptDir%.sis\script_info_lines.txt"
)
ECHO.
ECHO Runs all (matching) example programs
ECHO.
ECHO %ScriptPath% [ ... flags/options ... ]
ECHO.
ECHO Flags/options:
ECHO.
ECHO behaviour:
ECHO.
ECHO -l
ECHO --list-only
ECHO lists the target programs but does not execute them
ECHO.
ECHO -M
ECHO --no-make
ECHO does not execute CMake and make before running examples
ECHO.
ECHO --skip-interactive
ECHO skips examples listed in .github/ci_skip_interactive_examples.txt
ECHO (GUI / desktop-interactive programs unsuitable for headless CI)
ECHO.
ECHO standard flags:
ECHO.
ECHO --help
ECHO displays this help and terminates
EXIT /B 0
:: ############################# end of file ############################ ::