From 68f6450046c156c7b5d6d8f8e4717cd87888e78b Mon Sep 17 00:00:00 2001 From: pal1000 Date: Thu, 2 Nov 2023 18:56:54 +0200 Subject: [PATCH] MSVC build: Try MSYS2 flex and bison if winflexbison is missing --- buildscript/modules/envdump.cmd | 18 ++++++++++++------ buildscript/modules/winflexbison.cmd | 8 ++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/buildscript/modules/envdump.cmd b/buildscript/modules/envdump.cmd index 4d449dde..30ef9d76 100644 --- a/buildscript/modules/envdump.cmd +++ b/buildscript/modules/envdump.cmd @@ -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" ) diff --git a/buildscript/modules/winflexbison.cmd b/buildscript/modules/winflexbison.cmd index 0892768f..0f844d56 100644 --- a/buildscript/modules/winflexbison.cmd +++ b/buildscript/modules/winflexbison.cmd @@ -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% \ No newline at end of file +@IF %flexstate%==1 IF NOT EXIST "%devroot%\flexbison\*lex.exe" set flexstate=0 +@endlocal&set flexstate=%flexstate%