[scripts] package.cmd: remove comment regarding MSVC_CL

I think it's actually a good thing that these are set separately instead
of being duplicated across all of the IF EXIST blocks.

The reason why the old value of a variable is used inside an IF
statement is because cmd does variable expansion right after reading a
line, prior to any parsing being done. E.g. you can swap two variables
like so:
    SET "X=%Y%" & SET "Y=%X%"
During parsing, if a newline is reached while inside parentheses,
another line is read. As a consequence, the entire IF/FOR block is
read and expanded before being executed. The following script
(with ECHO deliberately left ON) demonstrates this behavior:
    SET X=123
    IF "" == "" (ECHO START
        SET X=456
        ECHO %X%)

To the solution to this is to enable delayed expansion:
    SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
Then replace %s with !s and the variables will be expanded after
parsing is done:
    SET "MSVC_CL=!MSVC32_DIR!\bin\HostX86\x86\cl.exe"
    SET "MSVC_CL64_CROSS=!MSVC64_DIR!\bin\HostX86\x64\cl.exe"
    SET "MSVC_CL64_NATIVE=!MSVC64_DIR!\bin\HostX64\x64\cl.exe"
This commit is contained in:
Egor 2022-08-11 15:34:56 +03:00
parent 6a4758deba
commit 49243fb43f

View File

@ -146,9 +146,6 @@ ECHO - 64-bit: MSVC %MSVC64_YEAR% (%MSVC64_VERSION%)
ECHO. ECHO.
:: MSVC 2017+ uses a different directory layout. :: MSVC 2017+ uses a different directory layout.
:: NOTE: This must be set here, since you can't use a variable
:: set in a block within the same block. (It'll have the previous
:: value for some reason.)
SET MSVC_CL= SET MSVC_CL=
FOR %%I IN (2017 2019 2022) DO ( FOR %%I IN (2017 2019 2022) DO (
IF "%MSVC64_YEAR%" == "%%I" ( IF "%MSVC64_YEAR%" == "%%I" (