From d57ef135cc3ef5dc164e6a0dbc96082970f411f9 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett (MSFT)" Date: Thu, 30 Apr 2020 15:06:13 -0700 Subject: [PATCH] On second thought, embed the third-party notices in the package (#5673) This commit introduces a NOTICE.html file that will be embedded into the package. It will be stamped down with the real notices during a branded release build (as part of the build pipeline.) It, in part, reverts some of the really good work in determining the commit hash at build time. That work will be preserved in history. This is more compliant with our duties to the OSS we consume. --- NOTICE.md | 2 +- build/scripts/Generate-ThirdPartyNotices.ps1 | 14 +++++++++++++ src/cascadia/CascadiaPackage/NOTICE.html | 16 ++++++++++++++ src/cascadia/CascadiaResources.build.items | 5 +++++ src/cascadia/TerminalApp/TerminalPage.cpp | 9 ++++---- src/cascadia/TerminalApp/TerminalPage.h | 1 + src/cascadia/TerminalApp/TerminalPage.idl | 2 -- src/cascadia/TerminalApp/TerminalPage.xaml | 2 +- .../TerminalApp/lib/TerminalAppLib.vcxproj | 4 ---- tools/GenerateCommitHashHeader.ps1 | 21 ------------------- 10 files changed, 42 insertions(+), 34 deletions(-) create mode 100644 build/scripts/Generate-ThirdPartyNotices.ps1 create mode 100644 src/cascadia/CascadiaPackage/NOTICE.html delete mode 100644 tools/GenerateCommitHashHeader.ps1 diff --git a/NOTICE.md b/NOTICE.md index f15c440cc..f5b54b426 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -181,7 +181,7 @@ SOFTWARE. ``` -## {fmt} +## {fmt} **Source**: https://github.com/fmtlib/fmt diff --git a/build/scripts/Generate-ThirdPartyNotices.ps1 b/build/scripts/Generate-ThirdPartyNotices.ps1 new file mode 100644 index 000000000..16c456525 --- /dev/null +++ b/build/scripts/Generate-ThirdPartyNotices.ps1 @@ -0,0 +1,14 @@ +[CmdletBinding()] +Param( + [Parameter(Position=0, Mandatory=$true)][string]$MarkdownNoticePath, + [Parameter(Position=1, Mandatory=$true)][string]$OutputPath +) + +@" + + Third-Party Notices + + $(ConvertFrom-Markdown $MarkdownNoticePath | Select -Expand Html) + + +"@ | Out-File -Encoding UTF-8 $OutputPath -Force diff --git a/src/cascadia/CascadiaPackage/NOTICE.html b/src/cascadia/CascadiaPackage/NOTICE.html new file mode 100644 index 000000000..f272cda84 --- /dev/null +++ b/src/cascadia/CascadiaPackage/NOTICE.html @@ -0,0 +1,16 @@ + + Placeholder 3rd-party Notices + +

Windows Terminal (Dev)

+

+ This is a development build of Windows Terminal. The third-party notices + for this project can be found on + the + project's GitHub page. +

+

+ During a branded release build, this file is replaced with the content of + NOTICES.md from the root of the repository. +

+ + diff --git a/src/cascadia/CascadiaResources.build.items b/src/cascadia/CascadiaResources.build.items index 49996fc9c..6e54d09f8 100644 --- a/src/cascadia/CascadiaResources.build.items +++ b/src/cascadia/CascadiaResources.build.items @@ -1,6 +1,11 @@ + + + true + %(FileName)%(Extension) + true diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index d7a15836f..d9e58dda2 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -18,8 +18,6 @@ #include "TabRowControl.h" #include "DebugTapConnection.h" -#include "CurrentCommitHash.h" // For the about dialog's ThirdPartyNotices link - using namespace winrt; using namespace winrt::Windows::Foundation::Collections; using namespace winrt::Windows::UI::Xaml; @@ -256,10 +254,11 @@ namespace winrt::TerminalApp::implementation return RS_(L"ApplicationVersionUnknown"); } - winrt::hstring TerminalPage::ThirdPartyNoticesLink() + void TerminalPage::_ThirdPartyNoticesOnClick(const IInspectable& /*sender*/, const Windows::UI::Xaml::RoutedEventArgs& /*eventArgs*/) { - winrt::hstring link{ fmt::format(L"https://github.com/microsoft/terminal/blob/{}/NOTICE.md", CurrentCommitHash) }; - return link; + std::filesystem::path currentPath{ wil::GetModuleFileNameW(nullptr) }; + currentPath.replace_filename(L"NOTICE.html"); + ShellExecute(nullptr, nullptr, currentPath.c_str(), nullptr, nullptr, SW_SHOW); } // Method Description: diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index ff561f164..daf81e7ee 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -108,6 +108,7 @@ namespace winrt::TerminalApp::implementation void _FeedbackButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); void _AboutButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); void _CloseWarningPrimaryButtonOnClick(Windows::UI::Xaml::Controls::ContentDialog sender, Windows::UI::Xaml::Controls::ContentDialogButtonClickEventArgs eventArgs); + void _ThirdPartyNoticesOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); void _HookupKeyBindings(TerminalApp::AppKeyBindings bindings) noexcept; void _RegisterActionCallbacks(); diff --git a/src/cascadia/TerminalApp/TerminalPage.idl b/src/cascadia/TerminalApp/TerminalPage.idl index ec7e261ba..dc4b7820d 100644 --- a/src/cascadia/TerminalApp/TerminalPage.idl +++ b/src/cascadia/TerminalApp/TerminalPage.idl @@ -17,8 +17,6 @@ namespace TerminalApp String ApplicationDisplayName { get; }; String ApplicationVersion { get; }; - String ThirdPartyNoticesLink { get; }; - event Windows.Foundation.TypedEventHandler TitleChanged; event Windows.Foundation.TypedEventHandler LastTabClosed; event Windows.Foundation.TypedEventHandler SetTitleBarContent; diff --git a/src/cascadia/TerminalApp/TerminalPage.xaml b/src/cascadia/TerminalApp/TerminalPage.xaml index 384721615..7e8138843 100644 --- a/src/cascadia/TerminalApp/TerminalPage.xaml +++ b/src/cascadia/TerminalApp/TerminalPage.xaml @@ -42,7 +42,7 @@ the MIT License. See LICENSE in the project root for license information. --> NavigateUri="https://go.microsoft.com/fwlink/?linkid=2125418" /> + Click="_ThirdPartyNoticesOnClick" /> diff --git a/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj b/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj index 056786e14..a552e6cec 100644 --- a/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj +++ b/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj @@ -330,8 +330,4 @@ - - - - diff --git a/tools/GenerateCommitHashHeader.ps1 b/tools/GenerateCommitHashHeader.ps1 deleted file mode 100644 index 4606017ce..000000000 --- a/tools/GenerateCommitHashHeader.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -# This script gets the current git commit hash and places it in a header file stamped to a wstring_view -# If we're unable to retrieve the hash, we'll return the hard coded string "master" instead. - -$filePath = "Generated Files\CurrentCommitHash.h" - -Write-Output "constexpr std::wstring_view CurrentCommitHash{ L`"" | Out-File -FilePath $filePath -Encoding ASCII -NoNewline - -# Let's see if we're on a build agent that can give us the commit hash through this predefined variable. -$hash = $env:Build_SourceVersion -if (-not $hash) -{ - # Otherwise attempt to invoke git to get the commit. - $hash = git rev-parse HEAD - if ($LASTEXITCODE -or -not $hash) - { - $hash = "master" - } -} - -$hash | Out-File -FilePath $filePath -Encoding ASCII -Append -NoNewline -Write-Output "`" };" | Out-File -FilePath $filePath -Encoding ASCII -Append -NoNewline