James E. King, III | 07f5997 | 2017-03-10 06:18:33 -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 | :: gcc = MinGW / MSYS2 and gcc toolchain |
| 19 | :: vc100 = Visual Studio 2010 |
| 20 | :: vc110 = Visual Studio 2012 |
| 21 | :: vc120 = Visual Studio 2013 |
| 22 | :: vc140 = Visual Studio 2015 |
| 23 | :: vc150 = Visual Studio 2017 |
| 24 | :: |
| 25 | :: Honors any existing COMPILER environment variable |
| 26 | :: setting instead of overwriting it, to allow it |
| 27 | :: to be forced if needed. |
| 28 | :: |
| 29 | :: Sets ERRORLEVEL to 0 if COMPILER can be determined, |
| 30 | :: to 1 if it cannot. |
| 31 | :: |
| 32 | |
| 33 | IF DEFINED COMPILER ( |
| 34 | ECHO [warn ] using existing environment variable COMPILER |
| 35 | EXIT /B 0 |
| 36 | ) |
| 37 | |
| 38 | IF NOT "%PROFILE:~0,4%" == "MSVC" ( |
| 39 | SET COMPILER=gcc |
| 40 | ) ELSE ( |
| 41 | CALL :CHECK 16 |
| 42 | IF !ERRORLEVEL! == 0 (SET COMPILER=vc100) |
| 43 | CALL :CHECK 17 |
| 44 | IF !ERRORLEVEL! == 0 (SET COMPILER=vc110) |
| 45 | CALL :CHECK 18 |
| 46 | IF !ERRORLEVEL! == 0 (SET COMPILER=vc120) |
| 47 | CALL :CHECK 19.00 |
| 48 | IF !ERRORLEVEL! == 0 (SET COMPILER=vc140) |
| 49 | CALL :CHECK 19.10 |
| 50 | IF !ERRORLEVEL! == 0 (SET COMPILER=vc150) |
| 51 | ) |
| 52 | |
| 53 | IF NOT DEFINED COMPILER ( |
| 54 | ECHO [error] unable to determine the compiler edition |
| 55 | EXIT /B 1 |
| 56 | ) |
| 57 | |
| 58 | ECHO [info ] detected compiler edition %COMPILER% |
| 59 | EXIT /B 0 |
| 60 | |
| 61 | :CHECK |
| 62 | cl /? 2>&1 | findstr /C:"Version %1%." > nul |
| 63 | EXIT /B |