RFR: JDK-8266396: Add VSCMD_DEBUG for solving WINSDK_DIR build error
John Neffenger
jgneff at openjdk.java.net
Thu May 6 20:46:55 UTC 2021
On Thu, 6 May 2021 20:39:11 GMT, John Neffenger <jgneff at openjdk.org> wrote:
> The Windows build calls a series of batch files to get the Visual Studio paths and environment variables. The batch files are a black box: any messages they print are discarded. If anything goes wrong, the only signs are a vague Gradle exception and a corrupted properties file.
>
> This has been causing problems for years. There are at least 49 messages on the mailing since 2017 that discuss the exception and ways to work around it.
>
> This pull request lets you enable the batch file messages, shedding light on their internal workings and allowing you to catch any errors at their source. Specifically, it adds the variable `VSCMD_DEBUG` to the environment of `genVSproperties.bat` and documents its use.
>
> ### Before
>
> For example, if your `PATH` environment variable is missing `C:/Windows/System32`, like mine was, you'll see the following errors:
>
>
> $ gradle sdk
> Dependency verification is an incubating feature.
>
> FAILURE: Build failed with an exception.
>
> * Where:
> Script 'C:\cygwin64\home\john\src\jfx\buildSrc\win.gradle' line: 108
>
> * What went wrong:
> A problem occurred evaluating script.
>> FAIL: WINSDK_DIR not defined
>
> ︙
>
> BUILD FAILED in 4s
>
>
> *Me:* What's a `WINSDK_DIR`? The Wiki says, "This means that you will have to define these paths manually." I guess this is normal. ️
>
> ### After
>
> With this change, you can set the debug level to "3" in the `win.gradle` file and get a better picture of the problem:
>
>
> $ gradle sdk
> Dependency verification is an incubating feature.
>
>> Configure project :
> 'reg' is not recognized as an internal or external command,
> operable program or batch file.
> 'reg' is not recognized as an internal or external command,
> operable program or batch file.
> 'reg' is not recognized as an internal or external command,
> operable program or batch file.
>
> ︙
>
> 'powershell.exe' is not recognized as an internal or external command,
> operable program or batch file.
>
> FAILURE: Build failed with an exception.
>
> * Where:
> Script 'C:\cygwin64\home\john\src\jfx\buildSrc\win.gradle' line: 108
>
> * What went wrong:
> A problem occurred evaluating script.
>> FAIL: WINSDK_DIR not defined
>
> ︙
>
> BUILD FAILED in 3s
>
>
> *Me:* Oh, it's just a "command not found" error. I'll check my `PATH`.
### Notes
The sequence of nested calls to the batch files is shown below, where `C:/Program Files (x86)/Microsoft Visual Studio` is the root directory of the Visual Studio files:
buildSrc/genVSproperties.bat
↳ "2019/Community/VC/Auxiliary/Build/vcvarsall.bat"
↳ "2019/Community/Common7/Tools/VsDevCmd.bat"
↳ "2019/Community/Common7/Tools/vsdevcmd/core/winsdk.bat"
The file `VsDevCmd.bat` calls `powershell.exe` to send telemetry to Microsoft when `VSCMD_DEBUG` is defined. To avoid sending telemetry, define the environment variable `VSCMD_SKIP_SENDTELEMETRY`. For example, in Cygwin you can define:
export VSCMD_SKIP_SENDTELEMETRY=1
This pull request sets `VSCMD_DEBUG` to the empty string (""). In batch files, setting a variable to the empty string is equivalent to leaving the variable undefined. Furthermore, setting the value in Gradle to the string "3" is the same as setting the value to the number 3. To verify, I replaced `genVSproperties.bat` with this batch file:
@echo off
if defined VSCMD_DEBUG (
echo VSCMD_DEBUG is defined 1>&2
) else (
echo VSCMD_DEBUG is not defined 1>&2
)
if "%VSCMD_DEBUG%" NEQ "" (
echo VSCMD_DEBUG = "%VSCMD_DEBUG%" 1>&2
) else (
echo VSCMD_DEBUG is the empty string "%VSCMD_DEBUG%" 1>&2
)
We could instead set the default value to "3". In that case, I get two error messages during the Windows build due to following registry query failing on my system:
$ reg query "HKLM\SOFTWARE\Microsoft\VisualStudio\VSPerf" \
-------------
PR: https://git.openjdk.java.net/jfx/pull/488
More information about the openjfx-dev
mailing list