lundi 25 juillet 2016

CMD not executing path assignments in if statement

Windows 10, latest updates.

Here's a the contents of a .cmd file (I've deleted the bottom part - irrelevant to the question):

echo off
set BUILD=%1%
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
REM                     set path to bare minimum
REM
set PATH=c:\devtools\bin;c:\devtools\qt5r\bin;c:\devtools\qt5r\lib;%PATH%
REM                     compiler, qt bins
REM
if "%BUILD%" == "-b" (
   echo on
   echo -b flag detected
   echo off
   set LIBPATH=
   set LIB=
   set INCLUDE=
REM                     clear these
REM

   set QT5SRC=c:\devtools\qt5
   set PATH=%PATH%;c:\devtools\Python27;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin
REM                     paths for python, perl
REM
   set PATH=%QT5SRC%\qtbase\bin;%QT5SRC%\gnuwin32\bin;%QT5SRC%\qtrepotools\bin;%PATH%
REM                     additional paths for qt build
REM
   set _PARAMS=-opensource -skip qtwebengine -opensource -opengl dynamic -nomake examples -nomake tests
REM                     change configure parameters here
REM
   doskey doconfig=configure -prefix c:\devtools\qt5r -debug-and-release %_PARAMS%
REM                     use this command to configure
REM
) else (
    set QT5SRC=
    doskey doconfig=
)

So, the issue is this: the 'set PATH' statements in the if block don't work. (run with a '-b' flag). I'm pretty sure they execute - the %_PARAMS% variable is set, and so is the %QT5SRC% variable. But the resulting path is the last value set before the if block.

I tried reducing this to a simplified example, but that worked ( :( ).

I finally wound up just making two separate .cmd files for the different environment scenarios.

Would like to find out why this isn't working, though. Seems weird.

Aucun commentaire:

Enregistrer un commentaire