1
0
mirror of https://github.com/simh/simh.git synced 2026-01-26 20:12:23 +00:00

Visual Studio Projects: Add extensive support for Visual Studio 2022

- Pre-Pre-Build-Event.cmd now dynamically determines the available
  compiler version along with any alternate toolset which may be part
  of the build environment and makes the appropriate windows-build
  library support available for linking.
- build_vstudio.bat now supports VS2022 and will dynamically adjust
  the converted VS2008 project files to leverage any available XP build
  support which might be installed so that the generated executables
  will support all versions of Windows from XP onward.  The VS2008
  generated executables automatically support all versions of Windows
  from XP onward.
This commit is contained in:
Mark Pizzolato
2022-11-24 11:11:52 -10:00
parent 45c6599577
commit f98a4ca93a
5 changed files with 176 additions and 15 deletions

View File

@@ -58,7 +58,7 @@ in this directory.
The installer for Visual Studio 2008 SP1 is available from:
http://download.microsoft.com/download/E/8/E/E8EEB394-7F42-4963-A2D8-29559B738298/VS2008ExpressWithSP1ENUX1504728.iso
https://download.microsoft.com/download/E/8/E/E8EEB394-7F42-4963-A2D8-29559B738298/VS2008ExpressWithSP1ENUX1504728.iso
Then install Visual Studio Express Visual C++ by executing VCExpress\setup.exe
on that DVD image. No need to install "Silverlight Runtime" or
@@ -66,6 +66,9 @@ on that DVD image. No need to install "Silverlight Runtime" or
you may be prompted to install an older version of .NET Framework which should
be installed.
Visual Studio Express 2008 will build executables that will run on all Windows
versions from XP onward with equivalent functionality.
Note: VS2008 can readily coexist on Windows systems that also have later
versions of Visual Studio installed.
@@ -76,4 +79,37 @@ conversion process.
If you have a version of Visual Studio installed and want to build all the
simulators from a command prompt, the file build_vstudio.bat in the root
of the simh source tree will do that without any furthur interaction.
of the simh source tree will do that without any furthur interaction.
Almost all newer Visual Studio versions after VS2008 will build executables
that only run on the system that built it or one running the same OS.
If you're using Visual Studio Community 2022, and you follow these
installation instructions, you can also build simulator executables which
will run on all versions of Windows from XP onward if you install as
indicated here and you use the build_vstudio.bat file to perform the
project conversions. Once projects are converted, they can be used in
the Visual Studio 2022 IDE for further development.
- New install
- In the "Workloads" pane, check "Desktop development with C++" workload's
checkbox, if not already checked.
- Click on the tab labeled "Individual components"
- In the "Individual components" pane:
- Enter "XP" in the "Search components (Ctrl-Q)" field.
- Locate the "Compilers, build tools and runtimes" heading
- Select "C++ for Windows XP Support for VS 2017 (v141) tools [Deprecated]" checkbox.
- Continue to customize your VS 2022 installation as needed.
- Click on "Install" in the lower right hand corner
- Modifying an existing VS2022 installation
- Click on the Visual Studio 2022 `Modify` button.
- In the "Modifying --" window, click on "Individual Components"
- Click on the tab labeled "Individual components"
- In the "Individual components" pane:
- Enter "XP" in the "Search components (Ctrl-Q)" field.
- Locate the "Compilers, build tools and runtimes" heading
- Select "C++ for Windows XP Support for VS 2017 (v141) tools [Deprecated]" checkbox.
- Continue to customize your VS 2022 installation as needed.
- Click on the "Modify" button in the lower right corner of the Window.

View File

@@ -0,0 +1,26 @@
# This script converts Visual Studio 2022 upgraded VS2008 projects to produce VS2022
# projects that will build executables that will run on all versions of windows since XP
#
ForEach ($arg in ($args))
{
if (-not (Test-Path -Path $arg -PathType Any)) {if (-not (Get-Item -Path $arg -ErrorAction Ignore)) {Write-Host "No such file: $arg"; continue; }}
ForEach ($file in (Get-Item -Path $arg))
{
$string = Get-Content -Path $file -Raw
if ($string.Contains("<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>")) {Write-Host "$file - already converted"; continue; }
Write-Host "Processing: $file"
$string = $string.Replace(
"<Keyword>Win32Proj</Keyword>
",
"<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
")
$string = $string.Replace("<PlatformToolset>v143</PlatformToolset>","<PlatformToolset>v141_xp</PlatformToolset>")
$string = $string.Replace(
' Label="LocalAppDataPlatform" />
',' Label="LocalAppDataPlatform" />
<Import Project="simh.props" />
')
$string | Out-File -Force -FilePath "$file" -Encoding utf8
}
}

View File

@@ -30,7 +30,11 @@ rem Everything implicitly requires BUILD to also be set to have
rem any meaning, it always gets set.
set _X_BUILD=BUILD
set _X_REQUIRED_WINDOWS_BUILD=20221109
call :FindVCVersion _VC_VER
call :FindVCVersion _VC_VER _MSVC_VER _MSVC_TOOLSET_VER _MSVC_TOOLSET_DIR
echo _VC_VER=%_VC_VER%
echo _MSVC_VER=%_MSVC_VER%
echo _MSVC_TOOLSET_VER=%_MSVC_TOOLSET_VER%
echo _MSVC_TOOLSET_DIR=%_MSVC_TOOLSET_DIR%
set _PDB=%~dpn1.pdb
if exist "%_PDB%" del/q "%_PDB%"
@@ -118,7 +122,7 @@ ren ..\..\windows-build-windows-build windows-build
if errorlevel 1 goto _notice3
if exist ../../windows-build-windows-build goto _notice3
:_check_files
call :FindVCVersion _VC_VER
call :FindVCVersion _VC_VER _MSVC_VER _MSVC_TOOLSET_VER _MSVC_TOOLSET_DIR
if not exist ..\..\windows-build goto _notice1
if not exist ..\..\windows-build/lib goto _notice2
set _X_WINDOWS_BUILD=
@@ -138,6 +142,10 @@ set _X_LAST_WINDOWS_BUILD=
if not exist ../../windows-build/lib/VisualCVersionSupport.txt goto _find_vc_support
set _X_VC_VER=
if "%_MSVC_TOOLSET_VER%" EQU "v140" set _VC_VER=2015
if "%_MSVC_TOOLSET_VER%" EQU "v141" set _VC_VER=2017
if "%_MSVC_TOOLSET_VER%" EQU "v142" set _VC_VER=2019
if "%_MSVC_TOOLSET_VER%" EQU "v143" set _VC_VER=2022
for /F "usebackq tokens=2*" %%i in (`findstr /C:"_VC_VER=%_VC_VER% " ..\..\windows-build\lib\VisualCVersionSupport.txt`) do SET _X_VC_VER=%%i %%j
if "%_X_VC_VER%" neq "" echo Library support for %_X_VC_VER% is available
if "%_X_VC_VER%" neq "" goto _done_libsdl
@@ -150,7 +158,7 @@ for /F "usebackq tokens=2*" %%i in (`findstr /C:"_VC_VER=%_VC_VER% " "%_X_VC_VER
echo Enabling Library support for %_X_VC_VER%
call "%_X_VC_VER_DIR%\Install-Library-Support.cmd"
:_done_libsdl
call :FindVCVersion _VC_VER
call :FindVCVersion _VC_VER _MSVC_VER _MSVC_TOOLSET_VER _MSVC_TOOLSET_DIR
if not exist "..\..\windows-build\libpng-1.6.18\projects\Release Library" goto _setup_library
if not exist "..\..\windows-build\libpng-1.6.18\projects\Release Library\VisualC.version" set _LIB_VC_VER=9
if exist "..\..\windows-build\libpng-1.6.18\projects\Release Library\VisualC.version" for /f "usebackq delims=." %%v in (`type "..\..\windows-build\libpng-1.6.18\projects\Release Library\VisualC.version"`) do set _LIB_VC_VER=%%v
@@ -314,10 +322,10 @@ goto _ProjectInfo
:_notice4
echo *********************************
echo *********************************
echo ** Visual Studio Version: %_VC_VER% **
echo ** Visual Studio Version: %_VC_VER% **
echo ** Visual Studio Version: %_VC_VER% **
echo ** Visual Studio Version: %_VC_VER% **
echo ** Visual Studio Version: %_VC_VER% Compiler Version: %_MSVC_VER% Toolset Version: %_MSVC_TOOLSET_VER% **
echo ** Visual Studio Version: %_VC_VER% Compiler Version: %_MSVC_VER% Toolset Version: %_MSVC_TOOLSET_VER% **
echo ** Visual Studio Version: %_VC_VER% Compiler Version: %_MSVC_VER% Toolset Version: %_MSVC_TOOLSET_VER% **
echo ** Visual Studio Version: %_VC_VER% Compiler Version: %_MSVC_VER% Toolset Version: %_MSVC_TOOLSET_VER% **
echo *****************************************************
echo *****************************************************
echo ** Windows Build support for your Microsoft **
@@ -446,13 +454,29 @@ exit /B 0
:FindVCVersion
call :WhichInPath cl.exe _VC_CL_
for /f "tokens=3-9 delims=\" %%a in ("%_VC_CL_%") do call :VCCheck _VC_VER_NUM_ "%%a" "%%b" "%%c" "%%d" "%%e" "%%f" "%%g"
for /f "tokens=3-10 delims=\" %%a in ("%_VC_CL_%") do call :VCCheck _VC_VER_NUM_ "%%a" "%%b" "%%c" "%%d" "%%e" "%%f" "%%g" "%%h"
for /f "delims=." %%a in ("%_VC_VER_NUM_%") do set %1=%%a
set _VC_CL_STDERR_=%TEMP%\cl_stderr%RANDOM%.tmp
set VS_UNICODE_OUTPUT=
"%_VC_CL_%" /? 2>"%_VC_CL_STDERR_%" 1>NUL
for /f "usebackq tokens=4-9" %%a in (`findstr Version "%_VC_CL_STDERR_%"`) do call :MSVCCheck _MSVC_VER_NUM_ "%%a" "%%b" "%%c" "%%d" "%%e"
if "%4" NEQ "" set %4=%_MSVC_TOOLSET_%
if "%_MSVC_TOOLSET_%" NEQ "" set _MSVC_TOOLSET_=v%_MSVC_TOOLSET_:~0,2%%_MSVC_TOOLSET_:~3,1%
if "%3" NEQ "" set %3=%_MSVC_TOOLSET_%
set _MSVC_TOOLSET_=
set %2=%_MSVC_VER_NUM_%
set _MSVC_VER_NUM_=
for /f "delims=." %%a in ("%_MSVC_VER_NUM_%") do set %2=%%a
del %_VC_CL_STDERR_%
set _VC_CL_STDERR_=
set _VC_CL=
exit /B 0
:: Scan the elements of the file path of cl.exe to determine the Visual
:: Studio Version and potentially the toolset version
:VCCheck
set _VC_TMP=%1
set _VC_TOOLSET=
:_VCCheck_Next
shift
set _VC_TMP_=%~1
@@ -463,11 +487,37 @@ if "%_VC_NUM_%" neq "" set %_VC_TMP%=%~1
if "%_VC_NUM_%" neq "" goto _VCCheck_Done
goto _VCCheck_Next
:_VCCheck_Done
set _VC_TMP=_MSVC_TOOLSET_
:_VCTSCheck_Next
shift
set _VC_TMP_=%~1
if "%_VC_TMP_%" equ "" goto _VCTSCheck_Done
call :IsNumeric _VC_NUM_ %_VC_TMP_%
if "%_VC_NUM_%" neq "" set %_VC_TMP%=%~1
if "%_VC_NUM_%" neq "" goto _VCTSCheck_Done
goto _VCTSCheck_Next
:_VCTSCheck_Done
set _VC_TMP_=
set _VC_TMP=
set _VC_NUM_=
exit /B 0
:MSVCCheck
set _MSVC_TMP=%1
:_MSVCCheck_Next
shift
set _MSVC_TMP_=%~1
if "%_MSVC_TMP_%" equ "" goto _VCCheck_Done
call :IsNumeric _MSVC_NUM_ %_MSVC_TMP_%
if "%_MSVC_NUM_%" neq "" set %_MSVC_TMP%=%~1
if "%_MSVC_NUM_%" neq "" goto _MSVCCheck_Done
goto _MSVCCheck_Next
:_MSVCCheck_Done
set _MSVC_TMP_=
set _MSVC_TMP=
set _MSVC_NUM_=
exit /B 0
:CheckDirectoryVCSupport
set _VC_Check_Path=%~3%~2/
set _VC_Check_Path=%_VC_Check_Path:/=\%