2020-01-21 22:22:24 +00:00
|
|
|
@echo off
|
|
|
|
:: Copyright 2020 The Pigweed Authors
|
|
|
|
::
|
|
|
|
:: Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
|
|
:: use this file except in compliance with the License. You may obtain a copy of
|
|
|
|
:: the License at
|
|
|
|
::
|
|
|
|
:: https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
::
|
|
|
|
:: Unless required by applicable law or agreed to in writing, software
|
|
|
|
:: distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
:: WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
:: License for the specific language governing permissions and limitations under
|
|
|
|
:: the License.
|
|
|
|
|
|
|
|
:: Pigweed Windows environment setup.
|
|
|
|
|
2020-02-21 22:26:18 +00:00
|
|
|
:: If PW_CHECKOUT_ROOT is set, use it. Users should not set this variable.
|
|
|
|
:: It's used because when one batch script invokes another the Powershell magic
|
|
|
|
:: below doesn't work. To reinforce that users should not be using
|
|
|
|
:: PW_CHECKOUT_ROOT, it is cleared here after it is used, and other pw tools
|
|
|
|
:: will complain if they see that variable set.
|
|
|
|
:: TODO(mohrr) find out a way to do this without PW_CHECKOUT_ROOT.
|
|
|
|
if "%PW_CHECKOUT_ROOT%"=="" (
|
2020-03-10 23:48:26 +00:00
|
|
|
:: ~dp0 is the batchism for the directory in which a .bat file resides.
|
|
|
|
set PW_ROOT=%~dp0
|
|
|
|
) else (
|
2020-02-21 22:26:18 +00:00
|
|
|
set PW_ROOT=%PW_CHECKOUT_ROOT%
|
|
|
|
set PW_CHECKOUT_ROOT=
|
|
|
|
)
|
2020-01-21 22:22:24 +00:00
|
|
|
|
2020-03-10 23:48:26 +00:00
|
|
|
:: Allow forcing a specific Python version through the environment variable
|
2020-03-09 23:43:40 +00:00
|
|
|
:: PW_BOOTSTRAP_PYTHON. Otherwise, use the system Python if one exists.
|
|
|
|
if not "%PW_BOOTSTRAP_PYTHON%" == "" (
|
|
|
|
set python="%PW_BOOTSTRAP_PYTHON%"
|
|
|
|
) else (
|
|
|
|
where python >NUL 2>&1
|
|
|
|
if %ERRORLEVEL% EQU 0 (
|
|
|
|
set python=python
|
|
|
|
) else (
|
|
|
|
echo.
|
|
|
|
echo Error: no system Python present
|
|
|
|
echo.
|
|
|
|
echo Pigweed's bootstrap process requires a local system Python.
|
|
|
|
echo Please install Python on your system, add it to your PATH
|
|
|
|
echo and re-try running bootstrap.
|
|
|
|
goto finish
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2020-03-10 23:48:26 +00:00
|
|
|
set _pw_start_script=%PW_ROOT%\pw_env_setup\py\pw_env_setup\windows_env_start.py
|
2020-02-05 18:55:12 +00:00
|
|
|
set shell_file="%PW_ROOT%\pw_env_setup\.env_setup.bat"
|
2020-01-23 18:46:14 +00:00
|
|
|
|
2020-03-10 23:48:26 +00:00
|
|
|
:: If PW_SKIP_BOOTSTRAP is set, only run the activation stage instead of the
|
|
|
|
:: complete env_setup.
|
|
|
|
if "%PW_SKIP_BOOTSTRAP%" == "" (
|
|
|
|
call %python% %_pw_start_script% --bootstrap
|
2020-03-09 23:43:40 +00:00
|
|
|
call %python% %PW_ROOT%\pw_env_setup\py\pw_env_setup\env_setup.py^
|
|
|
|
--pw-root %PW_ROOT%^
|
|
|
|
--shell-file %shell_file%
|
2020-03-10 23:48:26 +00:00
|
|
|
) else (
|
|
|
|
if exist %shell_file% (
|
|
|
|
call %python% %_pw_start_script%
|
|
|
|
) else (
|
|
|
|
call %python% %_pw_start_script% --no-shell-file
|
|
|
|
goto finish
|
|
|
|
)
|
2020-01-23 18:46:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
call %shell_file%
|
2020-03-09 23:43:40 +00:00
|
|
|
|
|
|
|
:finish
|