JDK-8266396 : Save VSCMD_DEBUG output in Windows build
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: build
  • Affected Version: openjfx17
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2021-05-01
  • Updated: 2022-01-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
NOTE: Although the original bug report could be closed as "Not an Issue," it was difficult enough to track down the true source of the error that it's worth making a code changes to help anyone else who hits the problem.

ORIGINAL DESCRIPTION

The build of JavaFX on Windows fails with the messages:

  FAILURE: Build failed with an exception.

  * Where:
  Script 'C:\cygwin64\home\john\src\jfx\buildSrc\win.gradle' line: 105

  * What went wrong:
  A problem occurred evaluating script.
  > FAIL: WINSDK_DIR not defined

SYSTEM / OS / JAVA RUNTIME INFORMATION

Microsoft Windows 10 Pro Version 10.0.19042

  $ uname -srm
  CYGWIN_NT-10.0 3.2.0(0.340/5/3) x86_64

Oracle OpenJDK 15.0.2

  $ java --version
  openjdk 15.0.2 2021-01-19
  OpenJDK Runtime Environment (build 15.0.2+7-27)
  OpenJDK 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)

Apache Ant 1.10.9

  $ ant -version
  Apache Ant(TM) version 1.10.9 compiled on September 27 2020

Gradle 6.3

  $ gradle --version

  ------------------------------------------------------------
  Gradle 6.3
  ------------------------------------------------------------

  Build time:   2020-03-24 19:52:07 UTC
  Revision:     bacd40b727b0130eeac8855ae3f9fd9a0b207c60

  Kotlin:       1.3.70
  Groovy:       2.5.10
  Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
  JVM:          15.0.2 (Oracle Corporation 15.0.2+7-27)
  OS:           Windows 10 10.0 amd64

STEPS TO REPRODUCE

Follow the instructions for building JavaFX on Windows found here:

Building OpenJFX
https://wiki.openjdk.java.net/display/OpenJFX/Building+OpenJFX

Run a build. For example, I ran:

  $ gradle sdk jmods javadoc

EXPECTED RESULTS

The build succeeds:

  BUILD SUCCESSFUL in 7m 11s
  139 actionable tasks: 139 executed

ACTUAL RESULT

The build fails:

  FAILURE: Build failed with an exception.

  * Where:
  Script 'C:\cygwin64\home\john\src\jfx\buildSrc\win.gradle' line: 105

  * What went wrong:
  A problem occurred evaluating script.
  > FAIL: WINSDK_DIR not defined
  ...
  BUILD FAILED in 11s

SOURCE CODE FOR AN EXECUTABLE TEST CASE

None.

WORKAROUND

I was able to work around the problem by manually creating the file 'windows_tools.properties' as instructed in the section below:

Missing paths issue
https://wiki.openjdk.java.net/display/OpenJFX/Building+OpenJFX#BuildingOpenJFX-Missingpathsissue

The following files are attached to this bug report:

  windows_tools.properties - the file I used
  windows_tools.properties.txt - a version that's easier to read

Comments
Changed to Enhancement (from Bug) and changed Summary from: Fix Windows build error: WINSDK_DIR not defined to: Add VSCMD_DEBUG to genVSproperties.bat environment
04-05-2021

Glad you solved your problem. Yes, go ahead and repurpose this bug. As long as the proposed fix is non-intrusive, and doesn't change any default behavior, that seems OK. We can evaluate it when you submit the PR.
04-05-2021

Sorry for wasting your time on this, Kevin. In an attempt to salvage our time and this bug report, I'd like to use it to add one line to the 'win.gradle' file that would have been a big help. Is it okay to repurpose a non-bug bug report into one that helps prevent others from wasting their time, too? The error occurs as follows. The Windows build makes the sequence of nested calls to the batch files shown below: buildSrc/genVSproperties.bat ↳ "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" ↳ "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" ↳ "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\vsdevcmd\core\winsdk.bat" Or using Cygwin notation: buildSrc/genVSproperties.bat ↳ "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat" ↳ "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat" ↳ "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/vsdevcmd/core/winsdk.bat" The 'winsdk.bat' file runs the following command at label 'GetWin10SdkDirHelper' and uses the command output to set the 'WindowsSdkDir' variable: ------------------------------------------------------------------------ $ reg query \ "HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0" \ /v "InstallationFolder" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0 InstallationFolder REG_SZ C:\Program Files (x86)\Windows Kits\10\ ------------------------------------------------------------------------ The 'reg' command fails with ERRORLEVEL=9009 ('reg' is not recognized as an internal or external command) when 'C:/Windows/System32' is not in the PATH. By default, the command fails silently because 'GetWin10SdkDirHelper' is called with all output redirected to 'nul' as follows: call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node > nul 2>&1 When the environment variable VSCMD_DEBUG is equal to "3", though, all error messages are printed: call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node As this error seems to be common [1] [2] [3], I'd like to add the VSCMD_DEBUG environment variable to the 'win.gradle' file with an empty value ("") and with a comment on its use. Having that line right in the Gradle file, rather than buried four levels deep in calls to batch files, might have helped me find the source of the problem much sooner. All of the builds on Windows work fine even with a minimal PATH consisting of just the following locations: /home/john/opt/gradle-6.3/bin :/home/john/opt/apache-ant-1.10.5/bin :/home/john/opt/jdk-15.0.2/bin :/home/john/opt/cmake-3.13.3-win64-x64/bin :/usr/sbin:/usr/bin:/sbin:/bin :/cygdrive/c/Windows/System32 The build invokes 'powershell.exe' in addition to 'reg.exe', though, so it's better to add the following additional entry to the end. The builds seem to work fine even without it, though. :/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0 Just to be safe, it's probably best to keep the entire default Windows PATH setting and add the Gradle, Apache Ant, OpenJDK, and CMake locations to the front. I'll attach two new build environment files that work, in addition to the one already attached that fails. They are: jfxbuild.env - the environment that fails with "WINSDK_DIR not defined" jfxbuild1.env - an environment that works (minimal PATH) jfxbuild2.env - an environment that works (full default PATH) [1]: https://stackoverflow.com/a/21041353 [2]: https://stackoverflow.com/a/9725056 [3]: https://schrievkrom.wordpress.com/2011/01/25/error-cannot-determine-the-location-of-the-vs-common-tools-folder/
04-05-2021

I think it's my PATH environment variable. I started to suspect the following two lines soon after I uploaded the 'jfxbuild.env' file as an attachment: syspath=/usr/sbin:/usr/bin:/sbin:/bin ... export PATH=$gradle/bin:$ant/bin:$jdk/bin:$cmake/bin:$syspath That's what I do for Linux and macOS, and I think the shortened path worked for me before (maybe a year ago) even on Windows. Without those lines, though, my path on Windows contains the following locations by default: /home/john/bin /usr/local/bin /usr/bin /bin /cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath /cygdrive/c/WINDOWS/system32 /cygdrive/c/WINDOWS /cygdrive/c/WINDOWS/System32/Wbem /cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0 /cygdrive/c/WINDOWS/System32/OpenSSH /cygdrive/c/WINDOWS/system32/config/systemprofile/AppData/Local/Microsoft/WindowsApps I'll run a bunch of builds on Windows to see whether perhaps both of my new bug reports can be closed. I'll post my results later today. If it is just my PATH setting, that will be a big relief. Thank you for your help and patience, Kevin!
03-05-2021

The following indicates that when genVSproperties.bat ran vcvars32.bat , %WindowsSdkDir% didn't get defined. WINDOWS_SDK_DIR=@@ENDOFLINE@@ Not sure why that happened. I would check to see if any other WINDOWS or Visual Studio env vars are set in your shell.
03-05-2021

> Is this file the one generated by win.gradle, or is it the one you manually edited. I manually created the attached file 'windows_tools.properties' to work around the problem on my system. > Can you run the following and attach the output? I ran the following command under a Cygwin SSH session and attached the output file to this bug report: $ /cygdrive/c/Windows/System32/cmd /q /c buildSrc\\genVSproperties.bat > genVSproperties.txt
03-05-2021

I tried a fresh installation of VS 2019 Community on my system and it worked for me as expected. Perhaps you have some setting in your shell environment that is affecting this?
03-05-2021

[~jgneff] Can you run the following and attach the output? cmd /c buildSrc\\genVSproperties.bat This is what win.gradle does to get the various Visual Studio and Windows sdk properties.
03-05-2021

I see this in the attached "windows_tools.properties" file, which looks correct to me: WINDOWS_SDK_DIR=C:/Program Files (x86)/Windows Kits/10 Is this file the one generated by win.gradle, or is it the one you manually edited.
03-05-2021

I also attached a screenshot, called 'Visual_Studio_Installation_Details.png', showing the installation details panel of the Visual Studio Installer program on my system, in case I'm missing some necessary component.
01-05-2021

I attached the environment file that I source before each build, called 'jfxbuild.env', which has always included the VS150COMNTOOLS environment variable. Its contents are: #!/bin/bash # Sets up environment for building JavaFX syspath=/usr/sbin:/usr/bin:/sbin:/bin # Visual Studio Community 2019 export VS150COMNTOOLS="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build" # export VCTargetsPath="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Microsoft\\VC\\v160\\" cmake=$HOME/opt/cmake-3.20.0-windows-x86_64 jdk=$HOME/opt/jdk-15.0.2 ant=$HOME/opt/apache-ant-1.10.9 gradle=$HOME/opt/gradle-6.3 export CMAKE_HOME=$(cygpath -m $cmake) export JAVA_HOME=$(cygpath -m $jdk) export ANT_HOME=$(cygpath -m $ant) export GRADLE_HOME=$(cygpath -m $gradle) export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) # JDK_HOME and PATH are required by the build export JDK_HOME="$JAVA_HOME" export PATH=$gradle/bin:$ant/bin:$jdk/bin:$cmake/bin:$syspath export TERM=cygwin
01-05-2021

After the fix for JDK-8255713, WINSDK_DIR should be set automatically if VS150COMNTOOLS is set to point to the build directory. For example, running in a Cygwin shell, you might set this before the build: export VS150COMNTOOLS="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build" If you didn't set the above before doing the build, can you try a clean build again (with the "build" directory removed) with that set?
01-05-2021