2016-09-06 15:31:41 -04:00
|
|
|
:: Usage:
|
2017-02-27 02:16:48 -05:00
|
|
|
:: call get-gcc-version.bat version architecture
|
2016-09-06 15:31:41 -04:00
|
|
|
|
|
|
|
setlocal
|
|
|
|
|
2017-02-27 02:16:48 -05:00
|
|
|
set VarVersion=%~1
|
|
|
|
if "%VarVersion%"=="" (
|
|
|
|
echo.
|
|
|
|
echo Parameter error.
|
|
|
|
exit /B 1
|
|
|
|
)
|
|
|
|
|
|
|
|
set VarArchitecture=%~2
|
|
|
|
if "%VarArchitecture%"=="" (
|
2016-09-06 15:31:41 -04:00
|
|
|
echo.
|
|
|
|
echo Parameter error.
|
|
|
|
exit /B 1
|
|
|
|
)
|
|
|
|
|
|
|
|
set GCCVersion=
|
2017-02-27 02:16:48 -05:00
|
|
|
set GCCArchitecture=
|
2016-09-06 15:31:41 -04:00
|
|
|
|
|
|
|
call "%~dp0find-in-path.bat" GCCPath gcc.exe
|
|
|
|
if "%GCCPath%"=="" (
|
|
|
|
echo.
|
|
|
|
echo Cannot find gcc.exe in PATH.
|
|
|
|
goto exit
|
|
|
|
)
|
|
|
|
|
|
|
|
gcc --version >"%~dp0gccversion.tmp"
|
|
|
|
for /F "tokens=1*" %%A in (%~sdp0gccversion.tmp) do (
|
|
|
|
if "%%A"=="gcc" (
|
|
|
|
call :find_version %%B
|
2017-02-27 02:16:48 -05:00
|
|
|
call :find_architecture %%B
|
2016-09-06 15:31:41 -04:00
|
|
|
goto exit
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
:exit
|
|
|
|
if exist "%~dp0gccversion.tmp" del /Q "%~dp0gccversion.tmp"
|
|
|
|
|
2017-02-27 02:16:48 -05:00
|
|
|
endlocal & set %VarVersion%=%GCCVersion%& set %VarArchitecture%=%GCCArchitecture%
|
2016-09-06 15:31:41 -04:00
|
|
|
goto :EOF
|
|
|
|
|
|
|
|
:find_version
|
2017-02-27 02:16:48 -05:00
|
|
|
:loop_version
|
2016-09-06 15:31:41 -04:00
|
|
|
if "%2" NEQ "" (
|
|
|
|
shift
|
2017-02-27 02:16:48 -05:00
|
|
|
goto loop_version
|
2016-09-06 15:31:41 -04:00
|
|
|
)
|
|
|
|
set GCCVersion=%1
|
2017-02-27 02:16:48 -05:00
|
|
|
goto :EOF
|
|
|
|
|
|
|
|
:find_architecture
|
|
|
|
:loop_architecture
|
|
|
|
if "%7" NEQ "" (
|
|
|
|
shift
|
|
|
|
goto loop_architecture
|
|
|
|
)
|
|
|
|
set _Architecture=%1
|
|
|
|
if "%_Architecture:~1,4%"=="i686" set GCCArchitecture=x86
|
|
|
|
if "%_Architecture:~1,6%"=="x86_64" set GCCArchitecture=x64
|
|
|
|
goto :EOF
|