Skip to content

Commit

Permalink
MSVC build: Try MSYS2 flex and bison if winflexbison is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
pal1000 committed Nov 2, 2023
1 parent 86df5c1 commit 68f6450
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
18 changes: 12 additions & 6 deletions buildscript/modules/envdump.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,21 @@ echo CMake %%a>>"%devroot%\%projectname%\buildinfo\msvc.txt"
@IF %toolchain%==msvc IF EXIST "%devroot%\spirv-tools\build\%abi%\bin\" for /f tokens^=1-2^ eol^= %%a IN ('type "%devroot%\spirv-tools\build\%abi%\lib\pkgconfig\SPIRV-Tools.pc"') do @IF /I "%%a"=="Version:" echo SPIRV Tools %%b>>"%devroot%\%projectname%\buildinfo\msvc.txt"

@rem Get flex and bison version
@IF %toolchain%==msvc IF "%flexstate%"=="1" set PATH=%devroot%\flexbison\;%PATH%
@IF %toolchain%==msvc IF NOT "%flexstate%"=="0" IF NOT "%flexstate%"=="" set exitloop=1
@IF %toolchain%==msvc IF NOT "%flexstate%"=="0" IF NOT "%flexstate%"=="" for /f delims^=^ eol^= %%a IN ('where changelog.md 2^>nul') do @for /f tokens^=3^ skip^=6^ eol^= %%b IN ('type "%%~a"') do @if defined exitloop (
@IF %toolchain%==msvc IF %flexstate%==1 set PATH=%devroot%\flexbison\;%PATH%
@IF %toolchain%==msvc IF NOT %flexstate%==0 set exitloop=1
@IF %toolchain%==msvc IF NOT %flexstate%==0 for /f delims^=^ eol^= %%a IN ('where changelog.md 2^>nul') do @for /f tokens^=3^ skip^=6^ eol^= %%b IN ('type "%%~a"') do @if defined exitloop (
set "exitloop="
echo Winflexbison package %%b>>"%devroot%\%projectname%\buildinfo\msvc.txt"
)
@IF %toolchain%==msvc IF NOT "%flexstate%"=="0" IF NOT "%flexstate%"=="" for /f tokens^=2^ eol^= %%a IN ('win_flex --version') do @echo flex %%a>>"%devroot%\%projectname%\buildinfo\msvc.txt"
@IF %toolchain%==msvc IF NOT "%flexstate%"=="0" IF NOT "%flexstate%"=="" set exitloop=1
@IF %toolchain%==msvc IF NOT "%flexstate%"=="0" IF NOT "%flexstate%"=="" for /f tokens^=4^ eol^= %%a IN ('win_bison --version') do @if defined exitloop (
@IF %toolchain%==msvc IF NOT %flexstate%==0 for /f tokens^=2^ eol^= %%a IN ('win_flex --version 2^>nul') do @echo flex %%a>>"%devroot%\%projectname%\buildinfo\msvc.txt"
@IF %toolchain%==msvc IF NOT %flexstate%==0 for /f tokens^=2^ eol^= %%a IN ('flex --version 2^>nul') do @echo flex %%a>>"%devroot%\%projectname%\buildinfo\msvc.txt"
@IF %toolchain%==msvc IF NOT %flexstate%==0 set exitloop=1
@IF %toolchain%==msvc IF NOT %flexstate%==0 for /f tokens^=4^ eol^= %%a IN ('win_bison --version 2^>nul') do @if defined exitloop (
set "exitloop="
echo Bison %%a>>"%devroot%\%projectname%\buildinfo\msvc.txt"
)
@IF %toolchain%==msvc IF NOT %flexstate%==0 set exitloop=1
@IF %toolchain%==msvc IF NOT %flexstate%==0 for /f tokens^=4^ eol^= %%a IN ('bison --version 2^>nul') do @if defined exitloop (
set "exitloop="
echo Bison %%a>>"%devroot%\%projectname%\buildinfo\msvc.txt"
)
Expand Down
8 changes: 6 additions & 2 deletions buildscript/modules/winflexbison.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
@setlocal
@rem winflexbison. Can have all states.
@if NOT EXIST "%devroot%\flexbison\" IF %msysstate% GTR 0 (
@mklink /J "%devroot%\flexbison" "%msysloc%\usr\bin"
@echo.
)
@set flexstate=2
@CMD /C EXIT 0
@where /q win_flex.exe
@if NOT "%ERRORLEVEL%"=="0" set flexstate=1
@IF %flexstate%==1 IF NOT EXIST "%devroot%\flexbison\win_flex.exe" set flexstate=0
@endlocal&set flexstate=%flexstate%
@IF %flexstate%==1 IF NOT EXIST "%devroot%\flexbison\*lex.exe" set flexstate=0
@endlocal&set flexstate=%flexstate%

0 comments on commit 68f6450

Please sign in to comment.