-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.cmd
136 lines (108 loc) · 4.08 KB
/
bootstrap.cmd
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
@REM ----------------------------------------------------------------------
@REM |
@REM | bootstrap.cmd
@REM |
@REM | David Brownell <[email protected]>
@REM | 2019-05-21 08:07:40
@REM |
@REM ----------------------------------------------------------------------
@REM |
@REM | Copyright David Brownell 2019-22
@REM | Distributed under the Boost Software License, Version 1.0. See
@REM | accompanying file LICENSE_1_0.txt or copy at
@REM | http://www.boost.org/LICENSE_1_0.txt.
@REM |
@REM ----------------------------------------------------------------------
@echo off
IF "%~1"=="" (
echo.
echo This script bootstraps common library enlistment and setup.
echo.
echo Usage:
echo %0 ^<common code dir^> ["/name=<custom environment name>"] [Optional Setup.cmd args]*
echo.
exit /B -1
)
set _COMMON_CODE_DIR=%~1
shift /1
if "%DEVELOPMENT_ENVIRONMENT_REPOSITORY_ACTIVATED_FLAG%" NEQ "" (
echo.
echo ERROR: Please run this from a standard ^(non-activated^) command prompt.
echo.
exit /B -1
)
REM Bootstrap enlistment and setup of Common_Environment, and then invoke
REM enlistment and setup once python is available.
IF NOT EXIST "%_COMMON_CODE_DIR%\Common\Environment" (
git clone -b release_ https://github.com/davidbrownell/Common_Environment_v3.git "%_COMMON_CODE_DIR%\Common\Environment.tmp"
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
move "%_COMMON_CODE_DIR%\Common\Environment.tmp" "%_COMMON_CODE_DIR%\Common\Environment"
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
)
REM Note that the following loop has been crafted to work around batch's crazy
REM expansion rules. Modify at your own risk!
set _BOOTSTRAP_NAME=
set _BOOTSTRAP_CLA=
:GetRemainingArgs_Begin
if "%~1"=="" goto :GetRemainingArgs_End
set _ARG=%~1
if "%_ARG:~,6%"=="/name=" goto :GetRemainingArgs_Name1
if "%_ARG:~,6%"=="-name=" goto :GetRemainingArgs_Name1
if "%_ARG:~,9%"=="/name_EQ_" goto :GetRemainingArgs_Name2
if "%_ARG:~,9%"=="-name_EQ_" goto :GetRemainingArgs_Name2
REM If here, we are looking at an arg that should be passed to the script
set _BOOTSTRAP_CLA=%_BOOTSTRAP_CLA% "%_ARG%"
goto :GetRemainingArgs_Continue
:GetRemainingArgs_Name1
REM If here, we are looking at a name argument
set _BOOTSTRAP_NAME=%_ARG:~6%
goto :GetRemainingArgs_Continue
:GetRemainingArgs_Name2
REM If here, we are looking at a name argument
set _BOOTSTRAP_NAME=%_ARG:~9%
goto :GetRemainingArgs_Continue
:GetRemainingArgs_Continue
shift /1
goto :GetRemainingArgs_Begin
:GetRemainingArgs_End
set _BOOTSTRAP_NAME_ARG=
if "%_BOOTSTRAP_NAME%" NEQ "" (
set _BOOTSTRAP_NAME_ARG="/name=%_BOOTSTRAP_NAME%"
)
REM This works around a strange problem when attempting to invoke a command file using
REM a relative path.
pushd "%_COMMON_CODE_DIR%"
set _COMMON_CODE_ABSOLUTE_DIR=%CD%
popd
call "%_COMMON_CODE_ABSOLUTE_DIR%\Common\Environment\Setup.cmd" %_BOOTSTRAP_NAME_ARG%
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
REM Write the environment activation and python execution statements to a temporary
REM file so this environment remains unactivated (by doing this, the current script
REM can be invoked multiple times from the same environment).
set _ACTIVATE_CMD=Activate.cmd
if "%_BOOTSTRAP_NAME%" NEQ "" (
set _ACTIVATE_CMD=Activate.%_BOOTSTRAP_NAME%.cmd
)
(
echo @echo off
echo.
echo call "%_COMMON_CODE_DIR%\Common\Environment\%_ACTIVATE_CMD%" python36
echo if %%ERRORLEVEL%% NEQ 0 exit /B %%ERRORLEVEL%%
echo.
echo call %~dp0Setup.cmd Enlist "%_COMMON_CODE_DIR%" /recurse %_BOOTSTRAP_CLA%
echo if %%ERRORLEVEL%% NEQ 0 exit /B %%ERRORLEVEL%%
echo.
echo call %~dp0Setup.cmd /recurse %_BOOTSTRAP_CLA%
echo if %%ERRORLEVEL%% NEQ 0 exit /B %%ERRORLEVEL%%
) >bootstrap_tmp.cmd
cmd /C bootstrap_tmp.cmd
set _ERRORLEVEL=%ERRORLEVEL%
del bootstrap_tmp.cmd
set _ACTIVATE_CMD=
set _ARG=
set _BOOTSTRAP_CLA=
set _BOOTSTRAP_NAME=
set _BOOTSTRAP_NAME_ARG=
set _COMMON_CODE_DIR=
set _COMMON_CODE_ABSOLUTE_DIR=
if %_ERRORLEVEL% NEQ 0 exit /B %_ERRORLEVEL%