James E. King, III | 4d651ab | 2017-02-19 22:19:55 -0500 | [diff] [blame^] | 1 | :: |
| 2 | :: Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | :: you may not use this file except in compliance with the License. |
| 4 | :: You may obtain a copy of the License at |
| 5 | :: |
| 6 | :: http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | :: |
| 8 | :: Unless required by applicable law or agreed to in writing, software |
| 9 | :: distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | :: See the License for the specific language governing permissions and |
| 12 | :: limitations under the License. |
| 13 | :: |
| 14 | |
| 15 | :: |
| 16 | :: Detect the compiler edition we're building in. |
| 17 | :: Set the COMPILER environment variable to one of: |
| 18 | :: vc100 = Visual Studio 2010 |
| 19 | :: vc110 = Visual Studio 2012 |
| 20 | :: vc120 = Visual Studio 2013 |
| 21 | :: vc140 = Visual Studio 2015 |
| 22 | :: vc150 = Visual Studio 2017 |
| 23 | :: |
| 24 | :: Honors any existing COMPILER environment variable |
| 25 | :: setting instead of overwriting it, to allow it |
| 26 | :: to be forced if needed. |
| 27 | :: |
| 28 | :: Sets ERRORLEVEL to 0 if COMPILER can be determined, |
| 29 | :: to 1 if it cannot. |
| 30 | :: |
| 31 | |
| 32 | IF DEFINED COMPILER ( |
| 33 | ECHO [warn ] using existing environment variable COMPILER |
| 34 | EXIT /B 0 |
| 35 | ) |
| 36 | |
| 37 | CALL :CHECK 16 |
| 38 | IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc100) |
| 39 | CALL :CHECK 17 |
| 40 | IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc110) |
| 41 | CALL :CHECK 18 |
| 42 | IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc120) |
| 43 | CALL :CHECK 19.00 |
| 44 | IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc140) |
| 45 | CALL :CHECK 19.10 |
| 46 | IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc150) |
| 47 | |
| 48 | IF NOT DEFINED COMPILER ( |
| 49 | ECHO [error] unable to determine the compiler edition |
| 50 | EXIT /B 1 |
| 51 | ) |
| 52 | |
| 53 | ECHO [info ] detected compiler edition %COMPILER% |
| 54 | EXIT /B 0 |
| 55 | |
| 56 | :CHECK |
| 57 | cl /? 2>&1 | findstr /C:"Version %1%." > nul |
| 58 | EXIT /B %ERRORLEVEL% |