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.
This commit is contained in:
Dustin L. Howett (MSFT) 2020-04-30 15:06:13 -07:00 committed by GitHub
parent 7612044363
commit d57ef135cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 42 additions and 34 deletions

View file

@ -181,7 +181,7 @@ SOFTWARE.
```
## {fmt}
## {fmt}
**Source**: https://github.com/fmtlib/fmt

View file

@ -0,0 +1,14 @@
[CmdletBinding()]
Param(
[Parameter(Position=0, Mandatory=$true)][string]$MarkdownNoticePath,
[Parameter(Position=1, Mandatory=$true)][string]$OutputPath
)
@"
<html>
<head><title>Third-Party Notices</title></head>
<body>
$(ConvertFrom-Markdown $MarkdownNoticePath | Select -Expand Html)
</body>
</html>
"@ | Out-File -Encoding UTF-8 $OutputPath -Force

View file

@ -0,0 +1,16 @@
<html>
<head><title>Placeholder 3rd-party Notices</title></head>
<body>
<h1>Windows Terminal (Dev)</h1>
<p>
This is a development build of Windows Terminal. The third-party notices
for this project can be found on
<a href="https://github.com/microsoft/terminal/blob/master/NOTICE.md">the
project's GitHub page</a>.
</p>
<p>
During a branded release build, this file is replaced with the content of
<code>NOTICES.md</code> from the root of the repository.
</p>
</body>
</html>

View file

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<!-- License Info -->
<Content Include="$(OpenConsoleDir)src\cascadia\CascadiaPackage\NOTICE.html">
<DeploymentContent>true</DeploymentContent>
<Link>%(FileName)%(Extension)</Link>
</Content>
<!-- Images -->
<Content Include="$(OpenConsoleDir)res\terminal\images$(WindowsTerminalAssetSuffix)\**\*">
<DeploymentContent>true</DeploymentContent>

View file

@ -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<std::wstring>(nullptr) };
currentPath.replace_filename(L"NOTICE.html");
ShellExecute(nullptr, nullptr, currentPath.c_str(), nullptr, nullptr, SW_SHOW);
}
// Method Description:

View file

@ -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();

View file

@ -17,8 +17,6 @@ namespace TerminalApp
String ApplicationDisplayName { get; };
String ApplicationVersion { get; };
String ThirdPartyNoticesLink { get; };
event Windows.Foundation.TypedEventHandler<Object, String> TitleChanged;
event Windows.Foundation.TypedEventHandler<Object, LastTabClosedEventArgs> LastTabClosed;
event Windows.Foundation.TypedEventHandler<Object, Windows.UI.Xaml.UIElement> SetTitleBarContent;

View file

@ -42,7 +42,7 @@ the MIT License. See LICENSE in the project root for license information. -->
NavigateUri="https://go.microsoft.com/fwlink/?linkid=2125418" />
<HyperlinkButton
x:Uid="AboutDialog_ThirdPartyNoticesLink"
NavigateUri="{x:Bind ThirdPartyNoticesLink}" />
Click="_ThirdPartyNoticesOnClick" />
</StackPanel>
</ContentDialog>

View file

@ -330,8 +330,4 @@
<Target Name="_TerminalAppGenerateUserSettingsH" Inputs="..\userDefaults.json" Outputs="Generated Files\userDefaults.h" BeforeTargets="BeforeClCompile">
<Exec Command="powershell.exe -noprofile ExecutionPolicy Unrestricted $(OpenConsoleDir)\tools\GenerateHeaderForJson.ps1 -JsonFile ..\userDefaults.json -OutPath '&quot;Generated Files\userDefaults.h&quot;' -VariableName UserSettingsJson" />
</Target>
<!-- Get the hash of the current git commit this build is on.-->
<Target Name="_GenerateCurrentCommitHashH" Inputs="..\..\..\..\NOTICE.md;..\..\..\..\tools\GenerateCommitHashHeader.ps1" Outputs="Generated Files\CurrentCommitHash.h" BeforeTargets="BeforeClCompile">
<Exec Command="powershell.exe -noprofile -ExecutionPolicy Unrestricted $(OpenConsoleDir)\tools\GenerateCommitHashHeader.ps1" />
</Target>
</Project>

View file

@ -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