]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/get_vsvars.bat
9f3759b2a98c1c07fbaeeec4369c7c2b58c88c2a
[mirror_edk2.git] / BaseTools / get_vsvars.bat
1 @REM @file
2 @REM Windows batch file to find the Visual Studio set up script
3 @REM
4 @REM Copyright (c) 2013-2014, ARM Limited. All rights reserved.
5
6 @REM SPDX-License-Identifier: BSD-2-Clause-Patent
7 @REM
8
9
10 @echo off
11 set SCRIPT_ERROR=0
12 if "%1"=="" goto main
13 if /I "%1"=="VS2017" goto VS2017Vars
14 if /I "%1"=="VS2015" goto VS2015Vars
15 if /I "%1"=="VS2013" goto VS2013Vars
16 if /I "%1"=="VS2012" goto VS2012Vars
17
18 :set_vsvars
19 for /f "usebackq tokens=1* delims=: " %%i in (`%*`) do (
20 if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
21 )
22 goto :EOF
23
24 :read_vsvars
25 @rem Do nothing if already found, otherwise call vsvars32.bat if there
26 if defined VCINSTALLDIR goto :EOF
27 set GET_VSVARS_BAT_CHECK_DIR=%*
28 set GET_VSVARS_BAT_CHECK_DIR=%GET_VSVARS_BAT_CHECK_DIR:"=%
29 if exist "%GET_VSVARS_BAT_CHECK_DIR%\vsvars32.bat" call "%GET_VSVARS_BAT_CHECK_DIR%\vsvars32.bat"
30 :vsvars_done
31 goto :EOF
32
33
34 :ToolNotInstall
35 set SCRIPT_ERROR=1
36 goto :EOF
37
38 REM NOTE: This file will find the most recent Visual Studio installation
39 REM apparent from the environment.
40 REM To use an older version, modify your environment set up.
41 REM (Or invoke the relevant vsvars32 file beforehand).
42
43 :main
44 if defined VCINSTALLDIR goto :done
45 :VS2017Vars
46 if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
47 if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools" (
48 call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools
49 ) else (
50 call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
51 )
52 )
53 if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
54 if exist "%ProgramFiles%\Microsoft Visual Studio\2017\BuildTools" (
55 call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools
56 ) else (
57 call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
58 )
59 )
60 if /I "%1"=="VS2017" goto ToolNotInstall
61
62 :VS2015Vars
63 if defined VS140COMNTOOLS (call :read_vsvars "%VS140COMNTOOLS%") else (if /I "%1"=="VS2015" goto ToolNotInstall)
64
65 :VS2013Vars
66 if defined VS120COMNTOOLS ( call :read_vsvars "%VS120COMNTOOLS%") else (if /I "%1"=="VS2013" goto ToolNotInstall)
67
68 :VS2012Vars
69 if defined VS110COMNTOOLS (call :read_vsvars "%VS110COMNTOOLS%") else (if /I "%1"=="VS2012" goto ToolNotInstall)
70
71 if defined VS100COMNTOOLS call :read_vsvars "%VS100COMNTOOLS%"
72 if defined VS90COMNTOOLS call :read_vsvars "%VS90COMNTOOLS%"
73 if defined VS80COMNTOOLS call :read_vsvars "%VS80COMNTOOLS%"
74 if defined VS71COMNTOOLS call :read_vsvars "%VS71COMNTOOLS%"
75
76 :done
77 set GET_VSVARS_BAT_CHECK_DIR=