blob: 6da99978cd98b50da0f02f458a705c4f6dc252c3 [file] [log] [blame]
Alexei Frolovd0e69542020-01-21 14:22:24 -08001@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 Mohr3700b7a2020-02-21 14:26:18 -080018:: 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.
24if "%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 Frolovd0e69542020-01-21 14:22:24 -080032
Rob Mohr2cc32ec2020-02-05 10:55:12 -080033set shell_file="%PW_ROOT%\pw_env_setup\.env_setup.bat"
Alexei Frolovb8aadc32020-01-23 10:46:14 -080034
35if not exist %shell_file% (
Rob Mohr2cc32ec2020-02-05 10:55:12 -080036 call python %PW_ROOT%\pw_env_setup\py\pw_env_setup\env_setup.py --pw-root %PW_ROOT% --shell-file %shell_file%
Alexei Frolovb8aadc32020-01-23 10:46:14 -080037)
38
39call %shell_file%