RFR: JDK-8266396: Allow VSCMD_DEBUG to work as intended [v3]

John Neffenger jgneff at openjdk.java.net
Thu May 13 20:30:19 UTC 2021


On Tue, 11 May 2021 01:17:32 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`. ��
>
> John Neffenger has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Skip sending telemetry to fix "file in use" error

I wrote a Bash shell script, included below, that can help in reviewing this pull request. It isolates the call to `vcvarsall.bat`, making it easier to experiment with different choices, such as:

- leaving `VSCMD_SKIP_SENDTELEMETRY` undefined,
- adding the `/q` option to `cmd`,
- removing `2>&1` to use the default standard error, or
- discarding standard output with `> /dev/null`.


#!/bin/bash
# Tests the Visual Studio 'vcvarsall.bat' batch file
trap exit INT TERM
set -o errexit

# Path to 'vcvarsall.bat' batch file
vsroot="C:\\Program Files (x86)\\Microsoft Visual Studio"
vcfile="2019\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat"
vcpath="$vsroot\$vcfile"

# Windows command interpreter and options
#   /C  Carries out the command specified by string and then terminates
#   /Q  Turns echo off
command="cmd /c"

# Skips calling PowerShell script to send telemetry
export VSCMD_SKIP_SENDTELEMETRY="1"
printf "VSCMD_SKIP_SENDTELEMETRY="%s"\n" "$VSCMD_SKIP_SENDTELEMETRY"

# VSCMD_DEBUG undefined
unset VSCMD_DEBUG
printf "Testing VSCMD_DEBUG="%s"\n" "$VSCMD_DEBUG"
$command "$vcpath" x86 > 0-debug.log 2>&1
$command "$vcpath" x64 >> 0-debug.log 2>&1

# VSCMD_DEBUG = 1 (basic), 2 (detailed), and 3 (trace)
for n in 1 2 3; do
    export VSCMD_DEBUG="$n"
    printf "Testing VSCMD_DEBUG="%s"\n" "$VSCMD_DEBUG"
    $command "$vcpath" x86 > $n-debug.log 2>&1
    $command "$vcpath" x64 >> $n-debug.log 2>&1
done


I run the script under Cygwin on Windows and evaluate its output as follows:


$ ./vcvarstest.sh
VSCMD_SKIP_SENDTELEMETRY="1"
Testing VSCMD_DEBUG=""
Testing VSCMD_DEBUG="1"
Testing VSCMD_DEBUG="2"
Testing VSCMD_DEBUG="3"
$ wc -l *.log
    10 0-debug.log
    92 1-debug.log
   508 2-debug.log
  5690 3-debug.log
  6300 total

-------------

PR: https://git.openjdk.java.net/jfx/pull/488


More information about the openjfx-dev mailing list