Skip to content

Commit

Permalink
feat: Add Skia generic builder
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Feb 23, 2024
1 parent 52e12a2 commit 160613b
Show file tree
Hide file tree
Showing 46 changed files with 673 additions and 558 deletions.
78 changes: 28 additions & 50 deletions build/ci/.azure-devops-skia-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ jobs:
ArtifactName: skia-gtk-samples-app-$(XAML_FLAVOR_BUILD)
ArtifactType: Container

- powershell: dotnet msbuild src/SamplesApp/SamplesApp.Skia.WPF/SamplesApp.Skia.WPF.csproj /r /m /p:Configuration=Release /detailedsummary /m /bl:$(build.artifactstagingdirectory)\build-wpf.binlog
displayName: Build WPF Head

- task: PublishBuildArtifacts@1
retryCountOnTaskFailure: 3
condition: always()
inputs:
PathtoPublish: $(Build.SourcesDirectory)\src\SamplesApp\SamplesApp.Skia.WPF\bin\Release\net7.0-windows
ArtifactName: skia-wpf-samples-app-$(XAML_FLAVOR_BUILD)
ArtifactType: Container

- powershell: dotnet msbuild src/SamplesApp/UnoIslandsSamplesApp.Skia.WPF/UnoIslandsSamplesApp.Skia.Wpf.csproj /r /m /p:Configuration=Release /detailedsummary /m /bl:$(build.artifactstagingdirectory)\build-wpf-islands.binlog
displayName: Build WPF Islands Head

Expand All @@ -81,26 +70,15 @@ jobs:
ArtifactName: uno-islands-skia-wpf-samples-app-$(XAML_FLAVOR_BUILD)
ArtifactType: Container

- powershell: dotnet publish src/SamplesApp/SamplesApp.Skia.Linux.FrameBuffer/SamplesApp.Skia.Linux.FrameBuffer.csproj -c Release -f net7.0 /bl:$(build.artifactstagingdirectory)\build-framebuffer.binlog
displayName: Build Framebuffer Head
- powershell: dotnet publish src/SamplesApp/SamplesApp.Skia.Generic/SamplesApp.Skia.Generic.csproj -c Release -f net7.0 /bl:$(build.artifactstagingdirectory)\build-x11.binlog
displayName: Build Generic Skia Head

- task: PublishBuildArtifacts@1
retryCountOnTaskFailure: 3
condition: always()
inputs:
PathtoPublish: $(Build.SourcesDirectory)\src\SamplesApp\SamplesApp.Skia.Linux.FrameBuffer\bin\Release\net7.0
ArtifactName: skia-framebuffer-samples-app-$(XAML_FLAVOR_BUILD)
ArtifactType: Container

- powershell: dotnet publish src/SamplesApp/SamplesApp.Skia.X11/SamplesApp.Skia.X11.csproj -c Release -f net7.0 /bl:$(build.artifactstagingdirectory)\build-x11.binlog
displayName: Build X11 Head

- task: PublishBuildArtifacts@1
retryCountOnTaskFailure: 3
condition: always()
inputs:
PathtoPublish: $(Build.SourcesDirectory)\src\SamplesApp\SamplesApp.Skia.X11\bin\Release\net7.0
ArtifactName: skia-x11-samples-app-$(XAML_FLAVOR_BUILD)
PathtoPublish: $(Build.SourcesDirectory)\src\SamplesApp\SamplesApp.Skia.Generic\bin\Release\net7.0
ArtifactName: skia-generic-samples-app-$(XAML_FLAVOR_BUILD)
ArtifactType: Container

- task: PublishBuildArtifacts@1
Expand Down Expand Up @@ -243,8 +221,8 @@ jobs:
## WPF
##

- job: Skia_Wpf_Screenshot_Tests
displayName: 'Run Skia WPF Snapshot Tests'
- job: Skia_Windows_Screenshot_Tests
displayName: 'Run Skia Windows Snapshot Tests'
timeoutInMinutes: 60

pool:
Expand All @@ -254,7 +232,7 @@ jobs:
condition: and(succeeded(), eq(variables['UNO_UWP_BUILD'], 'false'))

variables:
SamplesAppArtifactName: skia-wpf-samples-app-WinUI
SamplesAppArtifactName: skia-generic-samples-app-WinUI
SamplesAppArtifactPath: $(build.sourcesdirectory)/build/$(SamplesAppArtifactName)

UNO_UWP_BUILD: ${{ parameters.UNO_UWP_BUILD }}
Expand All @@ -270,9 +248,9 @@ jobs:

- script: |
cd $(SamplesAppArtifactPath)
dotnet SamplesApp.Skia.Wpf.dll --auto-screenshots=$(build.artifactstagingdirectory)/screenshots/skia-wpf-screenshots
dotnet SamplesApp.Skia.Generic.dll --auto-screenshots=$(build.artifactstagingdirectory)/screenshots/skia-windows-screenshots
displayName: Run Skia WPF Snapshot Tests
displayName: Run Skia Windows Snapshot Tests
- task: PublishBuildArtifacts@1
condition: always()
Expand All @@ -282,8 +260,8 @@ jobs:
ArtifactName: uitests-results
ArtifactType: Container

- job: Skia_Wpf_Runtime_Tests_Build
displayName: 'Run Skia WPF Runtime Tests'
- job: Skia_Windows_Runtime_Tests_Build
displayName: 'Run Skia Windows Runtime Tests'
timeoutInMinutes: 60

pool:
Expand All @@ -292,7 +270,7 @@ jobs:
dependsOn: Skia_Tests_Build

variables:
SamplesAppArtifactName: skia-wpf-samples-app-$(XAML_FLAVOR_BUILD)
SamplesAppArtifactName: skia-generic-samples-app-$(XAML_FLAVOR_BUILD)
SamplesAppArtifactPath: $(build.sourcesdirectory)/build/$(SamplesAppArtifactName)

UNO_UWP_BUILD: ${{ parameters.UNO_UWP_BUILD }}
Expand All @@ -308,16 +286,16 @@ jobs:

- script: |
cd $(SamplesAppArtifactPath)
dotnet SamplesApp.Skia.Wpf.dll --runtime-tests=$(build.sourcesdirectory)/build/skia-wpf-runtime-tests-results.xml
dotnet SamplesApp.Skia.Generic.dll --runtime-tests=$(build.sourcesdirectory)/build/skia-windows-runtime-tests-results.xml
displayName: Run Skia WPF $(XAML_FLAVOR_BUILD) Runtime Tests
displayName: Run Skia Windows $(XAML_FLAVOR_BUILD) Runtime Tests
- task: PublishTestResults@2
condition: always()
inputs:
testRunTitle: 'Skia WPF $(XAML_FLAVOR_BUILD) Runtime Tests'
testRunTitle: 'Skia Windows $(XAML_FLAVOR_BUILD) Runtime Tests'
testResultsFormat: 'NUnit'
testResultsFiles: '$(build.sourcesdirectory)/build/skia-wpf-runtime-tests-results.xml'
testResultsFiles: '$(build.sourcesdirectory)/build/skia-windows-runtime-tests-results.xml'
failTaskOnFailedTests: true

- job: Uno_Islands_Skia_Wpf_Runtime_Tests_Build
Expand Down Expand Up @@ -362,8 +340,8 @@ jobs:
## X11
##

- job: Skia_X11_Screenshot_Tests
displayName: 'Run Skia X11 Snapshot Tests'
- job: Skia_Linux_Screenshot_Tests
displayName: 'Run Skia Linux Snapshot Tests'
timeoutInMinutes: 60

pool:
Expand All @@ -373,7 +351,7 @@ jobs:
condition: and(succeeded(), eq(variables['UNO_UWP_BUILD'], 'false'))

variables:
SamplesAppArtifactName: skia-x11-samples-app-WinUI
SamplesAppArtifactName: skia-linux-samples-app-WinUI
SamplesAppArtifactPath: $(build.sourcesdirectory)/build/$(SamplesAppArtifactName)
UNO_UWP_BUILD: ${{ parameters.UNO_UWP_BUILD }}
XAML_FLAVOR_BUILD: ${{ parameters.XAML_FLAVOR_BUILD }}
Expand All @@ -389,9 +367,9 @@ jobs:

- script: |
cd $(build.sourcesdirectory)/build/$(SamplesAppArtifactName)
xvfb-run --auto-servernum --server-args='-screen 0 1280x1024x24' sh -c '{ fluxbox & } ; dotnet SamplesApp.Skia.X11.dll --auto-screenshots=$(build.artifactstagingdirectory)/screenshots/skia-x11-screenshots'
xvfb-run --auto-servernum --server-args='-screen 0 1280x1024x24' sh -c '{ fluxbox & } ; dotnet SamplesApp.Skia.Generic.dll --auto-screenshots=$(build.artifactstagingdirectory)/screenshots/skia-linux-screenshots'
displayName: Run Skia X11 Snapshot Tests
displayName: Run Skia Linux Snapshot Tests
- task: PublishBuildArtifacts@1
condition: always()
Expand All @@ -401,8 +379,8 @@ jobs:
ArtifactName: uitests-results
ArtifactType: Container

- job: Skia_X11_Runtime_Tests_Build
displayName: 'Run Skia X11 Runtime Tests'
- job: Skia_Linux_Runtime_Tests_Build
displayName: 'Run Skia Linux Runtime Tests'
timeoutInMinutes: 60

pool:
Expand All @@ -411,7 +389,7 @@ jobs:
dependsOn: Skia_Tests_Build

variables:
SamplesAppArtifactName: skia-x11-samples-app-$(XAML_FLAVOR_BUILD)
SamplesAppArtifactName: skia-linux-samples-app-$(XAML_FLAVOR_BUILD)
SamplesAppArtifactPath: $(build.sourcesdirectory)/build/$(SamplesAppArtifactName)

UNO_UWP_BUILD: ${{ parameters.UNO_UWP_BUILD }}
Expand All @@ -431,7 +409,7 @@ jobs:

- script: |
cd $(SamplesAppArtifactPath)
xvfb-run --auto-servernum --server-args='-screen 0 1280x1024x24' sh -c '{ fluxbox & } ; dotnet SamplesApp.Skia.X11.dll --runtime-tests=$(build.sourcesdirectory)/build/skia-x11-runtime-tests-results.xml'
xvfb-run --auto-servernum --server-args='-screen 0 1280x1024x24' sh -c '{ fluxbox & } ; dotnet SamplesApp.Skia.Generic.dll --runtime-tests=$(build.sourcesdirectory)/build/skia-linux-runtime-tests-results.xml'
displayName: Run Skia $(XAML_FLAVOR_BUILD) Runtime Tests
env:
Expand All @@ -441,7 +419,7 @@ jobs:
- task: PublishTestResults@2
condition: always()
inputs:
testRunTitle: 'Skia X11 $(XAML_FLAVOR_BUILD) Runtime Tests'
testRunTitle: 'Skia Linux $(XAML_FLAVOR_BUILD) Runtime Tests'
testResultsFormat: 'NUnit'
testResultsFiles: '$(build.sourcesdirectory)/build/skia-x11-runtime-tests-results.xml'
failTaskOnFailedTests: true
testResultsFiles: '$(build.sourcesdirectory)/build/skia-linux-runtime-tests-results.xml'
failTaskOnFailedTests: true
16 changes: 8 additions & 8 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"sdk": {
"version": "7.0.302",
"allowPrerelease": false,
"rollForward": "latestFeature"
},
"tools": {
"dotnet": "7.0.302"
},
//"sdk": {
// "version": "7.0.302",
// "allowPrerelease": false,
// "rollForward": "latestFeature"
//},
//"tools": {
// "dotnet": "7.0.302"
//},
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "3.0.44",
"Microsoft.Build.NoTargets": "3.7.56"
Expand Down
47 changes: 47 additions & 0 deletions src/SamplesApp/SamplesApp.Skia.Generic/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#nullable enable

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Uno.UI.Runtime.Skia;

namespace SkiaSharpExample
{
class MainClass
{
static SamplesApp.App? _app;

[STAThread]
public static void Main(string[] args)
{
SamplesApp.App.ConfigureLogging(); // Enable tracing of the host

var host = SkiaHostBuilder.Create()
.App(() => _app = new SamplesApp.App())
.AfterInit(() =>
{
if (_app is not null && OperatingSystem.IsWindows())
{
_app.MainWindowActivated += delegate
{
var windowContent = System.Windows.Application.Current.Windows[0].Content;
Assert.IsInstanceOfType(windowContent, typeof(System.Windows.UIElement));
var windowContentAsUIElement = (System.Windows.UIElement)windowContent;
Assert.IsTrue(windowContentAsUIElement.IsFocused);
};
}
})
.UseX11()
.UseLinuxFrameBuffer()
.UseWindows(b => b
.WpfApplication(() =>
{
// optional app creation
return new System.Windows.Application();
}))
.UseMacOS()
.Build();

host.Run();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"profiles": {
"SamplesApp.Skia.Generic": {
"commandName": "Project",
"nativeDebugging": false,
"environmentVariables": {
//"COREHOST_TRACE": "1",
//"COREHOST_TRACE_VERBOSITY": "4"
// "DOTNET_ADDITIONAL_DEPS": "C:\\Program Files\\dotnet\\shared\\Microsoft.WindowsDesktop.App\\8.0.2\\Microsoft.WindowsDesktop.App.deps.json"
}
},
"WSL": {
"commandName": "WSL2",
"distributionName": ""
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetSkiaPreviousAndCurrent)</TargetFrameworks>
<RollForward>Major</RollForward>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<Import Project="../../targetframework-override.props" />

<PropertyGroup>
<OutputType>Exe</OutputType>

<!-- Required in CI to avoid dependency issues -->
<PreBuildUnoUITasks>true</PreBuildUnoUITasks>

<!--
Enable implicit dotnet runtime forward rolling, as the specifed target framework
project may run with only a later version of the .NET runtime installed.
-->
<RollForward>Major</RollForward>

<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

<ItemGroup>
<!-- Required to use WPF types in the head-->
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WPF" />
</ItemGroup>

<ItemGroup>
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

<ItemGroup Label="AssemblyInfo">
<AssemblyAttribute Include="System.Runtime.InteropServices.ComVisibleAttribute">
<_Parameter1>false</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Windows.ThemeInfo">
<_Parameter1>System.Windows.ResourceDictionaryLocation.None</_Parameter1>
<_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
<_Parameter2>System.Windows.ResourceDictionaryLocation.SourceAssembly</_Parameter2>
<_Parameter2_IsLiteral>true</_Parameter2_IsLiteral>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<PackageReference Include="SkiaSharp" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\SourceGenerators\System.Xaml\Uno.Xaml.csproj" />
<ProjectReference Include="..\..\Uno.Foundation\Uno.Foundation.Skia.csproj" />
<ProjectReference Include="..\..\Uno.UI.Runtime.Skia.Linux.FrameBuffer\Uno.UI.Runtime.Skia.Linux.FrameBuffer.csproj" />
<ProjectReference Include="..\..\Uno.UI.Runtime.Skia.MacOS\Uno.UI.Runtime.Skia.MacOS.csproj" />
<ProjectReference Include="..\..\Uno.UI.Runtime.Skia.Wpf\Uno.UI.Runtime.Skia.Wpf.csproj" />
<ProjectReference Include="..\..\Uno.UI.Runtime.Skia.X11\Uno.UI.Runtime.Skia.X11.csproj" />
<ProjectReference Include="..\..\Uno.UI\Uno.UI.Skia.csproj" />
<ProjectReference Include="..\..\Uno.UWP\Uno.Skia.csproj" />
<ProjectReference Include="..\SamplesApp.Skia\SamplesApp.Skia.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Program.cs" />
</ItemGroup>

<Import Project="..\..\..\build\nuget\*.Skia.Gtk.props" />
<Import Project="..\..\..\build\nuget\*.Skia.Gtk.targets" />

<PropertyGroup>
<UnoUIMSBuildTasksPath>$(MSBuildThisFileDirectory)..\..\SourceGenerators\Uno.UI.Tasks\bin\$(Configuration)_Shadow</UnoUIMSBuildTasksPath>
</PropertyGroup>

<Import Project="..\..\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets" Condition="'$(SkipUnoResourceGeneration)' == '' " />
<Import Project="..\..\..\build\nuget\uno.winui.runtime-replace.targets" />

<Target Name="_ValidatePublishedItems" AfterTargets="Publish">
<ItemGroup>
<_validationPath Include="Uno.Fonts.Fluent/Fonts/uno-fluentui-assets.ttf" />
<_validationPath Include="Uno.UI.RuntimeTests/Assets/Fonts/uno-fluentui-assets-runtimetest01.ttf" />
</ItemGroup>

<Error Condition="!exists('$(PublishDir)%(_validationPath.Identity)')" Text="Failed to find published filed: %(_validationPath.Identity)" />
</Target>

<Target Name="TestBefore" BeforeTargets="_CheckForTransitiveWindowsDesktopDependencies">
<ItemGroup>
<TransitiveFrameworkReference Remove="Microsoft.WindowsDesktop.App.WPF" />
</ItemGroup>
</Target>

<Target Name="TestBefore2" BeforeTargets="GenerateBuildRuntimeConfigurationFiles">
<ItemGroup>
<_RuntimeFrameworkToRemove Include="@(RuntimeFramework)" Condition="'%(Identity)'=='Microsoft.WindowsDesktop.App'" />
<RuntimeFramework Remove="@(_RuntimeFrameworkToRemove)" />
</ItemGroup>
</Target>
</Project>
Loading

0 comments on commit 160613b

Please sign in to comment.