diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 40fb3797..fdab50a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ defaults: shell: bash jobs: - build: + cmake-unix: runs-on: ${{ matrix.os }} strategy: matrix: @@ -22,7 +22,7 @@ jobs: - pdp8 pdp9 pdq3 rtvax1000 s3 sage scelbi sds sel32 sigma ssem swtp6800mp-a swtp6800mp-a2 tt2500 tx-0 - uc15 vax vax730 vax750 vax780 vax8200 vax8600 vaxstation3100m30 vaxstation3100m38 vaxstation3100m76 vaxstation4000m60 vaxstation4000vlc steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install dependencies if: ${{runner.os == 'macOS'}} run: sh -ex .travis/deps.sh osx @@ -33,3 +33,30 @@ jobs: env: SIM: ${{matrix.simulators}} run: make LTO=1 OPTIMIZE=-O3 $SIM + + cmake-vs2022xp: + name: VS 2022 XP-compatible + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [windows-latest] + + steps: + - uses: actions/checkout@v3 + - name: Install v141_xp (XP toolkit) + shell: pwsh + run: | + $packageParams = @( "--productId", "Microsoft.VisualStudio.Product.Enterprise", + "--channelId", "VisualStudio.17.Release", + "--add", "Microsoft.VisualStudio.Component.VC.v141.x86.x64", + "--add", "Microsoft.VisualStudio.Component.WinXP", + "--no-includeRecommended", + "--includeOptional", + "--quiet", + "--locale en-US" ) -join " " + choco install visualstudio2022-workload-nativedesktop --package-parameters $packageParams + + - name: vs2022-xp build + shell: cmd + build_vstudio.bat diff --git a/Visual Studio Projects/0ReadMe_Projects.txt b/Visual Studio Projects/0ReadMe_Projects.txt index a2497742..cfed9b00 100644 --- a/Visual Studio Projects/0ReadMe_Projects.txt +++ b/Visual Studio Projects/0ReadMe_Projects.txt @@ -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. \ No newline at end of file +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. + diff --git a/Visual Studio Projects/ConvertToXPProject.ps1 b/Visual Studio Projects/ConvertToXPProject.ps1 new file mode 100644 index 00000000..c5663ef4 --- /dev/null +++ b/Visual Studio Projects/ConvertToXPProject.ps1 @@ -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("10.0")) {Write-Host "$file - already converted"; continue; } + Write-Host "Processing: $file" + $string = $string.Replace( +"Win32Proj +", +"Win32Proj + 10.0 +") + $string = $string.Replace("v143","v141_xp") + $string = $string.Replace( +' Label="LocalAppDataPlatform" /> + ',' Label="LocalAppDataPlatform" /> + + ') + $string | Out-File -Force -FilePath "$file" -Encoding utf8 + } +} diff --git a/Visual Studio Projects/Pre-Build-Event.cmd b/Visual Studio Projects/Pre-Build-Event.cmd index b69a932e..f20d6e42 100644 --- a/Visual Studio Projects/Pre-Build-Event.cmd +++ b/Visual Studio Projects/Pre-Build-Event.cmd @@ -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:/=\% diff --git a/build_vstudio.bat b/build_vstudio.bat index 5b7f4669..24324f76 100644 --- a/build_vstudio.bat +++ b/build_vstudio.bat @@ -6,6 +6,12 @@ :: otherwise the installed Visual Studio tools will be used :: prefering newer Visual Studio versions over older ones. :: +:: If this is invoked with Visual Studio 2022 installed along with +:: the "C++ for Windows XP Support for VS 2017 (v141) tools" option +:: installed, then the project files will be converted, if needed +:: to leverage the available support so that the executables created +:: will run on all versions of Windows from XP onward. +:: :: If this procedure is invoked from a Developer command prompt :: then the tool chain provided with the command prompt is used :: to build the simh projects. @@ -52,6 +58,15 @@ if not "%_VC_VER%" == "" goto GotVC if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" call "%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" call :FindVCVersion _VC_VER if not "%_VC_VER%" == "" goto GotVC +if exist "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat" call "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat" +call :FindVCVersion _VC_VER +if not "%_VC_VER%" == "" goto GotVC +if exist "%ProgramFiles%\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars32.bat" call "%ProgramFiles%\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars32.bat" +call :FindVCVersion _VC_VER +if not "%_VC_VER%" == "" goto GotVC +if exist "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat" call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat" +call :FindVCVersion _VC_VER +if not "%_VC_VER%" == "" goto GotVC if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat" call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat" call :FindVCVersion _VC_VER if not "%_VC_VER%" == "" goto GotVC @@ -169,8 +184,15 @@ goto _NextProject :_DoMSBuild if "%_X_SLN_VERSION%" == "10.00" echo Converting the VS2008 projects to VS%_VC_VER%, this will take several (3-5) minutes & DevEnv /Upgrade "%_BUILD_PROJECT_DIR%Simh.sln" -if "%_BUILD_PROJECTS%" == "" MSBuild /nologo "%_BUILD_PROJECT_DIR%Simh.sln" /maxCpuCount:%_BUILD_PARALLEL% /Target:Rebuild /Property:Configuration=%_BUILD_CONFIG% /Property:Platform=Win32 & goto :EOF - +if not "%_VC_VER%" == "2022" goto _RunBuild +if not exist "%ProgramFiles%\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v150\Platforms\x64\PlatformToolsets\v141_xp" goto _RunBuild +for /F "usebackq tokens=1" %%a in (`findstr /C:"10.0" "%_BUILD_PROJECT_DIR%BuildROMs.vcxproj"`) do SET _X_PROJS_CONVERTED=%%a +if not "%_X_PROJS_CONVERTED%" == "" goto _RunBuild +echo Converting the VS2022 projects to generate XP compatible binaries +Powershell -NoLogo -File "%~dp0\Visual Studio Projects\ConvertToXPProject.ps1" "%~dp0\Visual Studio Projects\*.vcxproj" +set _X_PROJS_CONVERTED= +:_RunBuild +if "%_BUILD_PROJECTS%" == "" MSBuild /nologo "%_BUILD_PROJECT_DIR%Simh.sln" /maxCpuCount:%_BUILD_PARALLEL% /Target:Rebuild /Property:Configuration=%_BUILD_CONFIG% /Property:Platform=Win32 /fileLogger "/fileLoggerParameters:LogFile=%_BUILD_PROJECT_DIR%Build-VS%_VC_VER%.log" & goto :EOF set _BUILD_PROJECTS=%_BUILD_PROJECTS:~1% set _REBUILD_PROJECTS=%_REBUILD_PROJECTS:~1% -MSBuild /nologo "%_BUILD_PROJECT_DIR%Simh.sln" /maxCpuCount:%_BUILD_PARALLEL% /Target:%_REBUILD_PROJECTS% /Property:Configuration=%_BUILD_CONFIG% /Property:Platform=Win32 & goto :EOF +MSBuild /nologo "%_BUILD_PROJECT_DIR%Simh.sln" /maxCpuCount:%_BUILD_PARALLEL% /Target:%_REBUILD_PROJECTS% /Property:Configuration=%_BUILD_CONFIG% /Property:Platform=Win32 "/fileLoggerParameters:LogFile=%_BUILD_PROJECT_DIR%Build-VS%_VC_VER%.log" & goto :EOF