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"=="VS2019" goto VS2019Vars
|
---|
14 | if /I "%1"=="VS2017" goto VS2017Vars
|
---|
15 | if /I "%1"=="VS2015" goto VS2015Vars
|
---|
16 | if /I "%1"=="VS2013" goto VS2013Vars
|
---|
17 | if /I "%1"=="VS2012" goto VS2012Vars
|
---|
18 |
|
---|
19 | :set_vsvars
|
---|
20 | if defined VCINSTALLDIR goto :EOF
|
---|
21 | call %* > vswhereInfo
|
---|
22 | for /f "usebackq tokens=1* delims=: " %%i in (vswhereInfo) do (
|
---|
23 | if /i "%%i"=="installationPath" (
|
---|
24 | call "%%j\VC\Auxiliary\Build\vcvars32.bat"
|
---|
25 | )
|
---|
26 | )
|
---|
27 | del vswhereInfo
|
---|
28 | goto :EOF
|
---|
29 |
|
---|
30 | :read_vsvars
|
---|
31 | @rem Do nothing if already found, otherwise call vsvars32.bat if there
|
---|
32 | if defined VCINSTALLDIR goto :EOF
|
---|
33 | set GET_VSVARS_BAT_CHECK_DIR=%*
|
---|
34 | set GET_VSVARS_BAT_CHECK_DIR=%GET_VSVARS_BAT_CHECK_DIR:"=%
|
---|
35 | if exist "%GET_VSVARS_BAT_CHECK_DIR%\vsvars32.bat" call "%GET_VSVARS_BAT_CHECK_DIR%\vsvars32.bat"
|
---|
36 | :vsvars_done
|
---|
37 | goto :EOF
|
---|
38 |
|
---|
39 |
|
---|
40 | :ToolNotInstall
|
---|
41 | set SCRIPT_ERROR=1
|
---|
42 | goto :EOF
|
---|
43 |
|
---|
44 | REM NOTE: This file will find the most recent Visual Studio installation
|
---|
45 | REM apparent from the environment.
|
---|
46 | REM To use an older version, modify your environment set up.
|
---|
47 | REM (Or invoke the relevant vsvars32 file beforehand).
|
---|
48 |
|
---|
49 | :main
|
---|
50 | if defined VCINSTALLDIR goto :done
|
---|
51 | :VS2019Vars
|
---|
52 | if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
|
---|
53 | if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools" (
|
---|
54 | call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version 16,17
|
---|
55 | ) else (
|
---|
56 | call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version 16,17
|
---|
57 | )
|
---|
58 | )
|
---|
59 | if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
|
---|
60 | if exist "%ProgramFiles%\Microsoft Visual Studio\2019\BuildTools" (
|
---|
61 | call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version 16,17
|
---|
62 | ) else (
|
---|
63 | call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -version 16,17
|
---|
64 | )
|
---|
65 | )
|
---|
66 | if /I "%1"=="VS2019" goto ToolNotInstall
|
---|
67 |
|
---|
68 | :VS2017Vars
|
---|
69 | if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
|
---|
70 | if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools" (
|
---|
71 | call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version 15,16
|
---|
72 | ) else (
|
---|
73 | call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version 15,16
|
---|
74 | )
|
---|
75 | )
|
---|
76 | if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
|
---|
77 | if exist "%ProgramFiles%\Microsoft Visual Studio\2017\BuildTools" (
|
---|
78 | call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version 15,16
|
---|
79 | ) else (
|
---|
80 | call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -version 15,16
|
---|
81 | )
|
---|
82 | )
|
---|
83 | if /I "%1"=="VS2017" goto ToolNotInstall
|
---|
84 |
|
---|
85 | :VS2015Vars
|
---|
86 | if defined VS140COMNTOOLS (call :read_vsvars "%VS140COMNTOOLS%") else (if /I "%1"=="VS2015" goto ToolNotInstall)
|
---|
87 |
|
---|
88 | :VS2013Vars
|
---|
89 | if defined VS120COMNTOOLS ( call :read_vsvars "%VS120COMNTOOLS%") else (if /I "%1"=="VS2013" goto ToolNotInstall)
|
---|
90 |
|
---|
91 | :VS2012Vars
|
---|
92 | if defined VS110COMNTOOLS (call :read_vsvars "%VS110COMNTOOLS%") else (if /I "%1"=="VS2012" goto ToolNotInstall)
|
---|
93 |
|
---|
94 | if defined VS100COMNTOOLS call :read_vsvars "%VS100COMNTOOLS%"
|
---|
95 | if defined VS90COMNTOOLS call :read_vsvars "%VS90COMNTOOLS%"
|
---|
96 | if defined VS80COMNTOOLS call :read_vsvars "%VS80COMNTOOLS%"
|
---|
97 | if defined VS71COMNTOOLS call :read_vsvars "%VS71COMNTOOLS%"
|
---|
98 |
|
---|
99 | :done
|
---|
100 | set GET_VSVARS_BAT_CHECK_DIR=
|
---|