Alexei Frolov | d0e6954 | 2020-01-21 14:22:24 -0800 | [diff] [blame] | 1 | @echo off |
| 2 | :: Copyright 2020 The Pigweed Authors |
| 3 | :: |
| 4 | :: Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | :: use this file except in compliance with the License. You may obtain a copy of |
| 6 | :: the License at |
| 7 | :: |
| 8 | :: https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | :: |
| 10 | :: Unless required by applicable law or agreed to in writing, software |
| 11 | :: distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | :: WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | :: License for the specific language governing permissions and limitations under |
| 14 | :: the License. |
| 15 | |
| 16 | :: Pigweed Windows environment setup. |
| 17 | |
Rob Mohr | 3700b7a | 2020-02-21 14:26:18 -0800 | [diff] [blame^] | 18 | :: If PW_CHECKOUT_ROOT is set, use it. Users should not set this variable. |
| 19 | :: It's used because when one batch script invokes another the Powershell magic |
| 20 | :: below doesn't work. To reinforce that users should not be using |
| 21 | :: PW_CHECKOUT_ROOT, it is cleared here after it is used, and other pw tools |
| 22 | :: will complain if they see that variable set. |
| 23 | :: TODO(mohrr) find out a way to do this without PW_CHECKOUT_ROOT. |
| 24 | if "%PW_CHECKOUT_ROOT%"=="" ( |
| 25 | :: Calls a Powershell script that determines the correct PW_ROOT directory and |
| 26 | :: exports it as an environment variable. |
| 27 | for /F "usebackq tokens=1" %%i in (`powershell %%~dp0..\..\pw_env_setup\env_setup.ps1`) do set PW_ROOT=%%i |
| 28 | ) ELSE ( |
| 29 | set PW_ROOT=%PW_CHECKOUT_ROOT% |
| 30 | set PW_CHECKOUT_ROOT= |
| 31 | ) |
Alexei Frolov | d0e6954 | 2020-01-21 14:22:24 -0800 | [diff] [blame] | 32 | |
Rob Mohr | 2cc32ec | 2020-02-05 10:55:12 -0800 | [diff] [blame] | 33 | set shell_file="%PW_ROOT%\pw_env_setup\.env_setup.bat" |
Alexei Frolov | b8aadc3 | 2020-01-23 10:46:14 -0800 | [diff] [blame] | 34 | |
| 35 | if not exist %shell_file% ( |
Rob Mohr | 2cc32ec | 2020-02-05 10:55:12 -0800 | [diff] [blame] | 36 | call python %PW_ROOT%\pw_env_setup\py\pw_env_setup\env_setup.py --pw-root %PW_ROOT% --shell-file %shell_file% |
Alexei Frolov | b8aadc3 | 2020-01-23 10:46:14 -0800 | [diff] [blame] | 37 | ) |
| 38 | |
| 39 | call %shell_file% |