diff --git a/scripts/azure-templates-bootstrapper.yml b/scripts/azure-templates-bootstrapper.yml index 4e9736538e9..5fe77fc96b6 100644 --- a/scripts/azure-templates-bootstrapper.yml +++ b/scripts/azure-templates-bootstrapper.yml @@ -188,13 +188,6 @@ jobs: - pwsh: Remove-Item "$env:AGENT_TOOLSDIRECTORY/dotnet" -Recurse -Force -ErrorAction SilentlyContinue displayName: Cleanup existing versions of .NET condition: and(succeeded(), eq(variables['DOWNLOAD_EXTERNALS'], '')) - - task: UseDotNet@2 - condition: and(succeeded(), eq(variables['DOWNLOAD_EXTERNALS'], '')) - inputs: - packageType: 'sdk' - version: 3.1.x - retryCountOnTaskFailure: 3 - displayName: Install .NET 3.1.x - task: UseDotNet@2 condition: and(succeeded(), eq(variables['DOWNLOAD_EXTERNALS'], '')) inputs: diff --git a/scripts/azure-templates-stages.yml b/scripts/azure-templates-stages.yml index b39f34db490..ea65da7892e 100644 --- a/scripts/azure-templates-stages.yml +++ b/scripts/azure-templates-stages.yml @@ -490,6 +490,15 @@ stages: ${{ if eq(parameters.buildPipelineType, 'both') }}: dependsOn: native jobs: + - template: /scripts/azure-templates-bootstrapper.yml@self # Validate Interop + parameters: + name: managed_interop_windows + displayName: Validate Interop + buildPipelineType: ${{ parameters.buildPipelineType }} + buildAgent: ${{ parameters.buildAgentWindows}} + target: externals-interop + additionalArgs: --skipExternals="all" --validateInterop=true + installAndroidSdk: false - template: /scripts/azure-templates-bootstrapper.yml@self # Build Managed (Windows) parameters: name: managed_windows diff --git a/scripts/cake/externals.cake b/scripts/cake/externals.cake index d5b4df53ed0..18b29313b38 100644 --- a/scripts/cake/externals.cake +++ b/scripts/cake/externals.cake @@ -40,6 +40,29 @@ Task("externals-download") await DownloadPackageAsync("_nativeassets", "./output/native"); }); +//////////////////////////////////////////////////////////////////////////////////////////////////// +// EXTERNALS INTEROP - re-generate the interop files +//////////////////////////////////////////////////////////////////////////////////////////////////// + +Task("externals-interop") + .Does(() => +{ + RunProcess("pwsh", "./utils/generate.ps1"); + + RunProcess("git", "diff --name-only binding/*/*.generated.cs", out var files); + + if (files.Any()) { + Information("Generated files have changed:"); + foreach (var file in files) { + Information($" - {file}"); + } + + if (Argument("validateInterop", false)) { + throw new Exception("Generated interop files are out of date. Please run `pwsh ./utils/generate.ps1`."); + } + } +}); + //////////////////////////////////////////////////////////////////////////////////////////////////// // CLEAN - remove all the build artefacts //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/utils/NativeLibraryMiniTest/docker/NativeLibraryMiniTest.csproj b/utils/NativeLibraryMiniTest/docker/NativeLibraryMiniTest.csproj index 21aa313d610..f40c99436d6 100644 --- a/utils/NativeLibraryMiniTest/docker/NativeLibraryMiniTest.csproj +++ b/utils/NativeLibraryMiniTest/docker/NativeLibraryMiniTest.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net7.0 True diff --git a/utils/SkiaSharpGenerator/Generate/GenerateCommand.cs b/utils/SkiaSharpGenerator/Generate/GenerateCommand.cs index 105da78e106..bc7404e7f66 100644 --- a/utils/SkiaSharpGenerator/Generate/GenerateCommand.cs +++ b/utils/SkiaSharpGenerator/Generate/GenerateCommand.cs @@ -20,7 +20,7 @@ public GenerateCommand() protected override OptionSet OnCreateOptions() => new OptionSet { - { "s|skia=", "The root of the skia source", v => SourceRoot = v }, + { "r|root=", "The root of the source", v => SourceRoot = v }, { "c|config=", "The config file path", v => ConfigPath = v }, { "o|output=", "The output path", v => OutputPath = v }, }; @@ -31,7 +31,7 @@ protected override bool OnValidateArguments(IEnumerable extras) if (string.IsNullOrEmpty(SourceRoot)) { - Program.Log.LogError($"{Program.Name}: Path to the skia source was not provided: `--skia=`."); + Program.Log.LogError($"{Program.Name}: Path to the skia source was not provided: `--root=`."); hasError = true; } else if (!Directory.Exists(SourceRoot)) diff --git a/utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj b/utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj index 7b3c5de9903..25df0ee1655 100644 --- a/utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj +++ b/utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 enable LatestMajor diff --git a/utils/generate.ps1 b/utils/generate.ps1 index f7fc7a20504..12d937313bd 100644 --- a/utils/generate.ps1 +++ b/utils/generate.ps1 @@ -1,5 +1,25 @@ -dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.json --skia externals/skia --output binding/SkiaSharp/SkiaApi.generated.cs -dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.Skottie.json --skia externals/skia --output binding/SkiaSharp.Skottie/SkottieApi.generated.cs -dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.SceneGraph.json --skia externals/skia --output binding/SkiaSharp.SceneGraph/SceneGraphApi.generated.cs -dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.Resources.json --skia externals/skia --output binding/SkiaSharp.Resources/ResourcesApi.generated.cs -dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libHarfBuzzSharp.json --skia externals/skia/third_party/externals/harfbuzz --output binding/HarfBuzzSharp/HarfBuzzApi.generated.cs +$ErrorActionPreference = "Stop" + +$projects = @( + @{ Json="libSkiaSharp.json"; Root="externals/skia"; Output="SkiaSharp/SkiaApi.generated.cs" }, + @{ Json="libSkiaSharp.Skottie.json"; Root="externals/skia"; Output="SkiaSharp.Skottie/SkottieApi.generated.cs" }, + @{ Json="libSkiaSharp.SceneGraph.json"; Root="externals/skia"; Output="SkiaSharp.SceneGraph/SceneGraphApi.generated.cs" }, + @{ Json="libSkiaSharp.Resources.json"; Root="externals/skia"; Output="SkiaSharp.Resources/ResourcesApi.generated.cs" }, + @{ Json="libHarfBuzzSharp.json"; Root="externals/skia/third_party/externals/harfbuzz"; Output="HarfBuzzSharp/HarfBuzzApi.generated.cs" } +) + +New-Item -ItemType Directory -Force -Path "output/generated/" | Out-Null + +foreach ($proj in $projects) { + $json = $proj.Json; + $output = $proj.Output; + $root = $proj.Root; + $filename = Split-Path $output -Leaf + + dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/$json --root $root --output binding/$output + if (!$?) { + exit $LASTEXITCODE + } + + Copy-Item -Path binding/$output -Destination output/generated/$filename -Force +}