From 498030c738eb86347d88b5d8be681bf94a5de047 Mon Sep 17 00:00:00 2001 From: Jon Wiswall Date: Mon, 10 Jul 2023 12:32:48 -0700 Subject: [PATCH 1/4] Add tooling to difference current and updated output --- README.md | 12 +++++++++ build_prior_projection.cmd | 47 +++++++++++++++++++++++++++++++++ prepare_versionless_diffs.cmd | 49 +++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 build_prior_projection.cmd create mode 100644 prepare_versionless_diffs.cmd diff --git a/README.md b/README.md index 91e20bb19..938eee10a 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,15 @@ If you really want to build it yourself, the simplest way to do so is to run the * Build the x64 Release configuration of the `prebuild` and `cppwinrt` projects only. Do not attempt to build anything else just yet. * Run `build_projection.cmd` in the dev command prompt. * Switch to the x64 Debug configuration in Visual Studio and build all projects as needed. + +## Comparing Outputs + +Comparing the output of the prior release and your current changes will help show the impact of any updates. Starting from +a dev command prompt at the root of the repo: + +* Run `build_projection.cmd` in the dev command prompt +* Run `build_prior_projection.cmd` in the dev command prompt as well +* Run `prepare_versionless_diffs.cmd` which removes version stamps on both current and prior projection +* Use a directory-level differencing tool to compare `_build\$(arch)\$(flavor)\winrt` and `_reference\$(arch)\$(flavor)\winrt` + + diff --git a/build_prior_projection.cmd b/build_prior_projection.cmd new file mode 100644 index 000000000..4695b98cc --- /dev/null +++ b/build_prior_projection.cmd @@ -0,0 +1,47 @@ +@echo off + +setlocal ENABLEDELAYEDEXPANSION + +set target_platform=%1 +set target_configuration=%2 +if "%target_platform%"=="" set target_platform=x64 + +if /I "%target_platform%" equ "all" ( + if "%target_configuration%"=="" ( + set target_configuration=all + ) + call %0 x86 !target_configuration! + call %0 x64 !target_configuration! + call %0 arm !target_configuration! + call %0 arm64 !target_configuration! + goto :eof +) + +if /I "%target_configuration%" equ "all" ( + call %0 %target_platform% Debug + call %0 %target_platform% Release + goto :eof +) + +if "%target_configuration%"=="" ( + set target_configuration=Debug +) + +set reference_output=%~p0\_reference\%target_platform%\%target_configuration% +if exist "%reference_output%" ( + echo Removing existing reference projections + rmdir /s /q "%reference_output%" +) + +mkdir %reference_output%\package +nuget install Microsoft.Windows.CppWinRT -o %reference_output%\package +set reference_cppwinrt= +for /F "delims=" %%a in ('dir /s /b %reference_output%\package\cppwinrt.exe') DO set reference_cppwinrt=%%a +if "%reference_cppwinrt%"=="" ( + echo Could not find the reference cppwinrt.exe under %reference_output%\package + goto :EOF +) + +echo Generating reference projection from %reference_cppwinrt% to %reference_output%\cppwinrt +%reference_cppwinrt% -in local -out %reference_output% -verbose +echo. diff --git a/prepare_versionless_diffs.cmd b/prepare_versionless_diffs.cmd new file mode 100644 index 000000000..da4a43c94 --- /dev/null +++ b/prepare_versionless_diffs.cmd @@ -0,0 +1,49 @@ +@echo off + +setlocal ENABLEDELAYEDEXPANSION + +set target_platform=%1 +set target_configuration=%2 +if "%target_platform%"=="" set target_platform=x64 + +if /I "%target_platform%" equ "all" ( + if "%target_configuration%"=="" ( + set target_configuration=all + ) + call %0 x86 !target_configuration! + call %0 x64 !target_configuration! + call %0 arm !target_configuration! + call %0 arm64 !target_configuration! + goto :eof +) + +if /I "%target_configuration%" equ "all" ( + call %0 %target_platform% Debug + call %0 %target_platform% Release + goto :eof +) + +if "%target_configuration%"=="" ( + set target_configuration=Debug +) + +set reference_output=%~p0\_reference\%target_platform%\%target_configuration% +set build_output=%~p0\_build\%target_platform%\%target_configuration% + +echo Removing version stamps from %reference_output%\winrt +pushd %reference_output%\winrt +for /r %%i in (*.h) do call :filter_version %%i +popd + +echo Removing version stamps from %build_output%\winrt +pushd %build_output%\winrt +for /r %%i in (*.h) do call :filter_version %%i +popd + +goto :EOF + +:filter_version +copy /y %1 %temp%\filtered.h >nul +findstr /v /c:CPPWINRT_VERSION /c:"was generated by" %temp%\filtered.h > %1 +goto :EOF + From 88323fb34efda61e5f5e7341d4d1a034b58456d9 Mon Sep 17 00:00:00 2001 From: Jon Wiswall Date: Tue, 11 Jul 2023 13:17:23 -0700 Subject: [PATCH 2/4] Update readme. Turns out the cppwinrt project depends on prebuild already --- README.md | 6 ++---- build_projection.cmd | 9 ++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 938eee10a..2dcfdd69c 100644 --- a/README.md +++ b/README.md @@ -15,18 +15,16 @@ If you really want to build it yourself, the simplest way to do so is to run the * Open a dev command prompt pointing at the root of the repo. * Open the `cppwinrt.sln` solution. -* Build the x64 Release configuration of the `prebuild` and `cppwinrt` projects only. Do not attempt to build anything else just yet. +* Build the x64 Release configuration of the `cppwinrt` project only. Do not attempt to build anything else just yet. * Run `build_projection.cmd` in the dev command prompt. * Switch to the x64 Debug configuration in Visual Studio and build all projects as needed. ## Comparing Outputs Comparing the output of the prior release and your current changes will help show the impact of any updates. Starting from -a dev command prompt at the root of the repo: +a dev command prompt at the root of the repo _after_ following the above build instructions: * Run `build_projection.cmd` in the dev command prompt * Run `build_prior_projection.cmd` in the dev command prompt as well * Run `prepare_versionless_diffs.cmd` which removes version stamps on both current and prior projection * Use a directory-level differencing tool to compare `_build\$(arch)\$(flavor)\winrt` and `_reference\$(arch)\$(flavor)\winrt` - - diff --git a/build_projection.cmd b/build_projection.cmd index 9480b5ec0..778fa7aca 100644 --- a/build_projection.cmd +++ b/build_projection.cmd @@ -27,6 +27,13 @@ if "%target_configuration%"=="" ( set target_configuration=Debug ) +set cppwinrt_exe=%~p0\_build\x64\Release\cppwinrt.exe + +if not exist "%cppwinrt_exe%" ( + echo Remember to build the "prebuild" and then "cppwinrt" projects for Release x64 first + goto :eof +) + echo Building projection into %target_platform% %target_configuration% -%~p0\_build\x64\Release\cppwinrt.exe -in local -out %~p0\_build\%target_platform%\%target_configuration% -verbose +%cppwinrt_exe% -in local -out %~p0\_build\%target_platform%\%target_configuration% -verbose echo. From 57f6f910a89db35ef323d9bb35cf8daa5c631860 Mon Sep 17 00:00:00 2001 From: Jon Wiswall Date: Tue, 11 Jul 2023 13:17:47 -0700 Subject: [PATCH 3/4] Use powershell instead of findstr --- prepare_versionless_diffs.cmd | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/prepare_versionless_diffs.cmd b/prepare_versionless_diffs.cmd index da4a43c94..468645657 100644 --- a/prepare_versionless_diffs.cmd +++ b/prepare_versionless_diffs.cmd @@ -32,18 +32,10 @@ set build_output=%~p0\_build\%target_platform%\%target_configuration% echo Removing version stamps from %reference_output%\winrt pushd %reference_output%\winrt -for /r %%i in (*.h) do call :filter_version %%i +powershell -Command "gci -r -include *.h,*.ixx | %%{ (get-content $_) -replace 'was generated by.*|CPPWINRT_VERSION.*','' | set-content $_ }" popd echo Removing version stamps from %build_output%\winrt pushd %build_output%\winrt -for /r %%i in (*.h) do call :filter_version %%i +powershell -Command "gci -r -include *.h,*.ixx | %%{ (get-content $_) -replace 'was generated by.*|CPPWINRT_VERSION.*','' | set-content $_ }" popd - -goto :EOF - -:filter_version -copy /y %1 %temp%\filtered.h >nul -findstr /v /c:CPPWINRT_VERSION /c:"was generated by" %temp%\filtered.h > %1 -goto :EOF - From 8b1011e517536f87d1683fdc2be0f03afd4ec768 Mon Sep 17 00:00:00 2001 From: Jon Wiswall Date: Tue, 11 Jul 2023 13:19:16 -0700 Subject: [PATCH 4/4] Speed up invoke-webrequest with less progress --- build_prior_projection.cmd | 5 ++++- build_test_all.cmd | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build_prior_projection.cmd b/build_prior_projection.cmd index 4695b98cc..c7bdf2f64 100644 --- a/build_prior_projection.cmd +++ b/build_prior_projection.cmd @@ -33,8 +33,11 @@ if exist "%reference_output%" ( rmdir /s /q "%reference_output%" ) +if not exist ".\.nuget" mkdir ".\.nuget" +if not exist ".\.nuget\nuget.exe" powershell -Command "$ProgressPreference = 'SilentlyContinue' ; Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile .\.nuget\nuget.exe" + mkdir %reference_output%\package -nuget install Microsoft.Windows.CppWinRT -o %reference_output%\package +.\.nuget\nuget.exe install Microsoft.Windows.CppWinRT -o %reference_output%\package set reference_cppwinrt= for /F "delims=" %%a in ('dir /s /b %reference_output%\package\cppwinrt.exe') DO set reference_cppwinrt=%%a if "%reference_cppwinrt%"=="" ( diff --git a/build_test_all.cmd b/build_test_all.cmd index 6f7e24033..681f8c682 100644 --- a/build_test_all.cmd +++ b/build_test_all.cmd @@ -10,7 +10,7 @@ if "%target_configuration%"=="" set target_configuration=Release if "%target_version%"=="" set target_version=1.2.3.4 if not exist ".\.nuget" mkdir ".\.nuget" -if not exist ".\.nuget\nuget.exe" powershell -Command "Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile .\.nuget\nuget.exe" +if not exist ".\.nuget\nuget.exe" powershell -Command "$ProgressPreference = 'SilentlyContinue' ; Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile .\.nuget\nuget.exe" call .nuget\nuget.exe restore cppwinrt.sln" call .nuget\nuget.exe restore natvis\cppwinrtvisualizer.sln