-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests_setup.bat
45 lines (31 loc) · 1.16 KB
/
tests_setup.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
:: Windows setup script for building rlpencoding library and it's unit tests
@echo off
setlocal
SET BASEDIR=%~dp0
:: Source command
SET SOURCE=source
:: Call function GETPARENT to get the environment
CALL :GETPARENT PARENT
:: Check which shell environment is executing the script and
:: depending on the shell environment change source command
IF /I "%PARENT%" == "powershell" (
SET SOURCE=source
) ELSE IF /I "%PARENT%" == "pwsh" (
SET SOURCE=source
) ELSE IF /I "%PARENT%" == "WindowsTerminal" (
SET SOURCE=.
)
echo [Running]: Script under %PARENT% environment
:: Execute the config configuration
CALL %BASEDIR%/scripts/windows/config.bat
:: Execute the build script
CALL %BASEDIR%/scripts/windows/build.bat
:: Execute the tests script
CALL %BASEDIR%/scripts/windows/tests.bat
endlocal
GOTO :EOF
:: Function to get the environment
:GETPARENT
SET "PSCMD=$ppid=$pid;while($i++ -lt 3 -and ($ppid=(Get-CimInstance Win32_Process -Filter ('ProcessID='+$ppid)).ParentProcessId)) {}; (Get-Process -EA Ignore -ID $ppid).Name"
for /f "tokens=*" %%i in ('powershell -noprofile -command "%PSCMD%"') do SET %1=%%i
GOTO :EOF