Skip to content

Commit

Permalink
8289174: JavaFX build fails on Windows when VS150COMNTOOLS is not set
Browse files Browse the repository at this point in the history
Reviewed-by: nlisker, mhanl, lkostyra, prr
  • Loading branch information
kevinrushforth committed Aug 14, 2024
1 parent dc8f607 commit a8f7850
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 133 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,6 @@ jobs:
ANT_DIR: "apache-ant-1.10.5"
ANT_FILENAME: "apache-ant-1.10.5.tar.gz"
ANT_URL: "https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.tar.gz"
# FIXME: hard-code the location of VS 2022 for now
VS150COMNTOOLS: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build"

steps:
- name: Checkout the source
Expand Down Expand Up @@ -379,15 +377,10 @@ jobs:
- name: Setup environment
run: |
echo "VS150COMNTOOLS=$env:VS150COMNTOOLS"
echo "dir ...\VC\Tools\MSVC"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC"
echo "dir VS150COMNTOOLS"
dir "$env:VS150COMNTOOLS"
# echo "dir ...\VC\Tools\MSVC"
# dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC"
# echo "dir VS150COMNTOOLS"
# dir "$env:VS150COMNTOOLS"
$env:Path = "$HOME\cygwin\cygwin64\bin;$HOME\cygwin\cygwin64\bin;$env:Path" ;
$env:JAVA_HOME = "$HOME\bootjdk\jdk-$env:BOOT_JDK_VERSION" ;
Expand Down
13 changes: 6 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void setupTools(String name, Closure loader, Closure processor) {
// then generate it. Once generated, we need to read the properties file to
// help us define the defaults for this block of properties
File propFile = file("$buildDir/${name}.properties");
if (!propFile.exists()) {
if (!propFile.exists() || propFile.length() == 0) {
// Create the properties file
propFile.getParentFile().mkdirs();
propFile.createNewFile();
Expand Down Expand Up @@ -952,7 +952,6 @@ void ant(String conf, // platform configuration
"INCLUDE" : WINDOWS_VS_INCLUDE,
"LIB" : WINDOWS_VS_LIB,
"LIBPATH" : WINDOWS_VS_LIBPATH,
"DXSDK_DIR" : WINDOWS_DXSDK_DIR,
"PATH" : WINDOWS_VS_PATH
]);
commandLine "cmd", "/s", "/c", '"' + String.join(" ", cmdArgs) + '"'
Expand Down Expand Up @@ -5389,7 +5388,7 @@ compileTargets { t ->
}
if (IS_WINDOWS) {
from ("${graphicsProject.buildDir}/libs/prismD3D/${t.name}/${library(targetProperties.prismD3D.lib)}");
targetProperties.VS2017DLLs.each { vslib ->
targetProperties.VSDLLs.each { vslib ->
from ("$vslib");
}
targetProperties.WinSDKDLLs.each { winsdklib ->
Expand All @@ -5404,7 +5403,7 @@ compileTargets { t ->
inputFiles.include("*.dylib")
inputFiles.include("*.so")
// FIXME: if we ever need to strip on Windows platforms, we must
// exclude the Microsoft DLLs (VS2017DLLNames and WinSDKDLLNames)
// exclude the Microsoft DLLs (VSDLLNames and WinSDKDLLNames)

inputFiles.each { file ->
exec {
Expand All @@ -5421,7 +5420,7 @@ compileTargets { t ->
inputFiles.include("*.dylib")
inputFiles.include("*.so")
// FIXME: if we ever need to sign on Windows platforms, we must
// exclude the Microsoft DLLs (VS2017DLLNames and WinSDKDLLNames)
// exclude the Microsoft DLLs (VSDLLNames and WinSDKDLLNames)

inputFiles.each { file ->
exec {
Expand Down Expand Up @@ -5496,7 +5495,7 @@ compileTargets { t ->
inputFiles.include("*.dylib")
inputFiles.include("*.so")
// FIXME: if we ever need to sign on Windows platforms, we must
// exclude the Microsoft DLLs (VS2017DLLNames and WinSDKDLLNames)
// exclude the Microsoft DLLs (VSDLLNames and WinSDKDLLNames)

inputFiles.each { file ->
exec {
Expand Down Expand Up @@ -5549,7 +5548,7 @@ compileTargets { t ->
inputFiles.include("*.dylib")
inputFiles.include("*.so")
// FIXME: if we ever need to sign on Windows platforms, we must
// exclude the Microsoft DLLs (VS2017DLLNames and WinSDKDLLNames)
// exclude the Microsoft DLLs (VSDLLNames and WinSDKDLLNames)

inputFiles.each { file ->
exec {
Expand Down
88 changes: 39 additions & 49 deletions buildSrc/genVSproperties.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REM Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
REM Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved.
REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
REM
REM This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,79 +21,69 @@ REM Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
REM or visit www.oracle.com if you need additional information or have any
REM questions.

REM Windows bat file that runs vcvars32.bat for Visual Studio 2003
REM and echos out a property file with the values of the environment
REM variables we want, e.g. PATH, INCLUDE, LIB, and LIBPATH.
setlocal ENABLEDELAYEDEXPANSION

REM Windows bat file that runs vcvars64.bat for Visual Studio
REM and echoes out a property file with the values of the environment
REM variables we want, e.g. PATH, INCLUDE, LIB, and LIBPATH.

REM Clean out the current settings
set INCLUDE=
set LIB=
set LIBPATH=

REM Run the vsvars32.bat (12.0) / vcvars32.bat (15.0) file, sending it's output to neverland.
REM The current officially supported Visual Studio version is 15.0.
REM Handling of 11.0 and 14.0 is excluded here.
REM The previous officially supported VS version was 12.0
REM So, the search order is 150, then 120, then 100
set VSVER=150
set "VSVARS32FILE=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars32.bat"
if not "%VS150COMNTOOLS%"=="" (
set "VS150COMNTOOLS=%VS150COMNTOOLS%"
REM The current officially supported Visual Studio version is VS 2022

REM Try the following in order of priority:
REM 1. The VSCOMNTOOLS env var
REM 2. The legacy VS150COMNTOOLS env var
REM 3. Look in standard locations for Visual Studio (2022,2019,2017)


set AUXBUILD=VC\Auxiliary\Build

if not "%VSCOMNTOOLS%"=="" (
set "VSTOOLSDIR=%VSCOMNTOOLS%"
) else if not "%VS150COMNTOOLS%"=="" (
set "VSTOOLSDIR=%VS150COMNTOOLS%"
) else (
if exist "%VSVARS32FILE%" set "VS150COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build"
for %%a in (2022, 2019, 2017) do (
set year=%%a
for %%b in (Enterprise, Professional, Community, BuildTools) do (
set edition=%%b
for %%c in ("Program Files", "Program Files (x86)") do (
set ProgramFiles=%%~c
set "TMPDIR=C:\!ProgramFiles!\Microsoft Visual Studio\!year!\!edition!\%AUXBUILD%"
if exist "!TMPDIR!" (
set "VSTOOLSDIR=!TMPDIR!"
goto FOUNDVS
)
)
)
)
)
set VSVARSDIR=%VS150COMNTOOLS%
if "%VSVARSDIR%"=="" set VSVER=120
if "%VSVARSDIR%"=="" set VSVARSDIR=%VS120COMNTOOLS%
if "%VSVARSDIR%"=="" set VSVER=100
if "%VSVARSDIR%"=="" set VSVARSDIR=%VS100COMNTOOLS%

REM We shouldn't depend on VSVARS32 as it's 32-bit only.
REM However, this var is still used somewhere in FX (e.g.
REM to build media), so we set it here.

if "%VSVER%"=="100" set VSVARS32=%VSVARSDIR%\vsvars32.bat
if "%VSVER%"=="120" set VSVARS32=%VSVARSDIR%\vsvars32.bat
if "%VSVER%"=="150" set VSVARS32=%VSVARSDIR%\vcvars32.bat
call "%VSVARS32%" > NUL
:FOUNDVS

if "%VSVER%"=="100" set VCVARSALL=%VCINSTALLDIR%\vcvarsall.bat
if "%VSVER%"=="120" set VCVARSALL=%VCINSTALLDIR%\vcvarsall.bat
if "%VSVER%"=="150" set VCVARSALL=%VSVARSDIR%\vcvarsall.bat
call "%VCVARSALL%" %VCARCH% > NUL
if "%VSTOOLSDIR%"=="" exit
if not exist "%VSTOOLSDIR%" exit

REM Some vars are reset by vcvarsall.bat, so save them here.
set TEMPDEVENVDIR=%DEVENVDIR%
set TEMPVCINSTALLDIR=%VCINSTALLDIR%
set TEMPVSINSTALLDIR=%VSINSTALLDIR%
if NOT "%WINSDKPATH%"=="" call "%WINSDKPATH%\Bin\SetEnv.Cmd" %SDKARCH% %CONF% > NUL
set DEVENVDIR=%TEMPDEVENVDIR%
set VSINSTALLDIR=%TEMPVSINSTALLDIR%
set VCINSTALLDIR=%TEMPVCINSTALLDIR%
call "%VSTOOLSDIR%\vcvars64.bat" > NUL

REM Create some vars that are not set with VS Express 2008
REM Set legacy MSVCDIR variable in case some Makefiles still need it
if "%MSVCDIR%"=="" set MSVCDIR=%VCINSTALLDIR%
REM Try using exe, com might be hanging in ssh environment?
REM set DEVENVCMD=%DEVENVDIR%\devenv.exe
set DEVENVCMD=%DEVENVDIR%\devenv.com

REM Adjust for lack of devenv in express editions. This needs more work.
REM VCExpress is the correct executable, but cmd line is different...
if not exist "%DEVENVCMD%" set DEVENVCMD=%DEVENVDIR%\VCExpress.exe

REM Echo out a properties file
echo ############################################################
echo # DO NOT EDIT: This is a generated file.
echo windows.vs.DEVENVDIR=%DEVENVDIR%@@ENDOFLINE@@
echo windows.vs.DEVENVCMD=%DEVENVCMD%@@ENDOFLINE@@
echo windows.vs.VCINSTALLDIR=%VCINSTALLDIR%@@ENDOFLINE@@
echo windows.vs.VSINSTALLDIR=%VSINSTALLDIR%@@ENDOFLINE@@
echo windows.vs.MSVCDIR=%MSVCDIR%@@ENDOFLINE@@
echo windows.vs.INCLUDE=%INCLUDE%@@ENDOFLINE@@
echo windows.vs.LIB=%LIB%@@ENDOFLINE@@
echo windows.vs.LIBPATH=%LIBPATH%@@ENDOFLINE@@
echo windows.vs.PATH=%PARFAIT_PATH%;%PATH%@@ENDOFLINE@@
echo windows.vs.VER=%VSVER%@@ENDOFLINE@@
echo windows.vs.VC_TOOLS_INSTALL_DIR=%VCToolsInstallDir%@@ENDOFLINE@@
echo windows.vs.VC_TOOLS_REDIST_DIR=%VCToolsRedistDir%@@ENDOFLINE@@
echo WINDOWS_SDK_DIR=%WindowsSdkDir%@@ENDOFLINE@@
Expand Down
Loading

1 comment on commit a8f7850

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.