diff --git a/native/winui/ANGLE.cake b/native/winui-angle/build.cake similarity index 54% rename from native/winui/ANGLE.cake rename to native/winui-angle/build.cake index 966902a6b3..2b8340aa93 100644 --- a/native/winui/ANGLE.cake +++ b/native/winui-angle/build.cake @@ -1,9 +1,22 @@ -void InitializeAngle(string branch, DirectoryPath ANGLE_PATH, DirectoryPath WINAPPSDK_PATH) +DirectoryPath ROOT_PATH = MakeAbsolute(Directory("../..")); +DirectoryPath ANGLE_PATH = ROOT_PATH.Combine("externals/angle"); +DirectoryPath WINAPPSDK_PATH = ROOT_PATH.Combine("externals/winappsdk"); +DirectoryPath OUTPUT_PATH = MakeAbsolute(ROOT_PATH.Combine("output/native/winui")); +string ANGLE_VERSION = GetVersion("ANGLE", "release"); + +#load "../../scripts/cake/native-shared.cake" +#load "../../scripts/cake/msbuild.cake" + +Task("sync-ANGLE") + .WithCriteria(IsRunningOnWindows()) + .Does(() => { + // sync ANGLE if (!DirectoryExists(ANGLE_PATH)) { - RunProcess("git", $"clone https://github.com/google/angle.git --branch {branch} --depth 1 --single-branch --shallow-submodules {ANGLE_PATH}"); + RunProcess("git", $"clone https://github.com/google/angle.git --branch {ANGLE_VERSION} --depth 1 --single-branch --shallow-submodules {ANGLE_PATH}"); } + // sync submodules var submodules = new[] { "build", "testing", @@ -24,6 +37,7 @@ void InitializeAngle(string branch, DirectoryPath ANGLE_PATH, DirectoryPath WINA }); } + // patch the output filenames { var toolchain = ANGLE_PATH.CombineWithFilePath("build/toolchain/win/toolchain.gni"); var contents = System.IO.File.ReadAllText(toolchain.FullPath); @@ -34,6 +48,7 @@ void InitializeAngle(string branch, DirectoryPath ANGLE_PATH, DirectoryPath WINA System.IO.File.WriteAllText(toolchain.FullPath, newContents); } + // set build args if (!FileExists(ANGLE_PATH.CombineWithFilePath("build/config/gclient_args.gni"))) { var lines = new[] { "checkout_angle_internal = false", @@ -44,11 +59,13 @@ void InitializeAngle(string branch, DirectoryPath ANGLE_PATH, DirectoryPath WINA System.IO.File.WriteAllLines(ANGLE_PATH.CombineWithFilePath("build/config/gclient_args.gni").FullPath, lines); } + // set version numbers if (!FileExists(ANGLE_PATH.CombineWithFilePath("build/util/LASTCHANGE"))) { var lastchange = ANGLE_PATH.CombineWithFilePath("build/util/LASTCHANGE"); RunPython(ANGLE_PATH, ANGLE_PATH.CombineWithFilePath("build/util/lastchange.py"), $"-o {lastchange}"); } + // download rc.exe var rc_exe = "build/toolchain/win/rc/win/rc.exe"; var rcPath = ANGLE_PATH.CombineWithFilePath(rc_exe); if (!FileExists(rcPath)) { @@ -58,14 +75,66 @@ void InitializeAngle(string branch, DirectoryPath ANGLE_PATH, DirectoryPath WINA DownloadFile(url, rcPath); } + // download llvm if (!FileExists(ANGLE_PATH.CombineWithFilePath("third_party/llvm-build/Release+Asserts/cr_build_revision"))) { RunPython(ANGLE_PATH, ANGLE_PATH.CombineWithFilePath("tools/clang/scripts/update.py")); } + // generate Windows App SDK files if (!FileExists(WINAPPSDK_PATH.CombineWithFilePath("Microsoft.WindowsAppSDK.nuspec"))) { var setup = ANGLE_PATH.CombineWithFilePath("scripts/winappsdk_setup.py"); RunProcess( ROOT_PATH.CombineWithFilePath("scripts/vcvarsall.bat"), $"\"{VS_INSTALL}\" \"x64\" \"{PYTHON_EXE}\" \"{setup}\" --output \"{WINAPPSDK_PATH}\""); } -} +}); + +Task("ANGLE") + .IsDependentOn("sync-ANGLE") + .IsDependentOn("git-sync-deps") + .WithCriteria(IsRunningOnWindows()) + .Does(() => +{ + Build("x86"); + Build("x64"); + Build("arm64"); + + void Build(string arch) + { + if (Skip(arch)) return; + + try { + System.Environment.SetEnvironmentVariable("DEPOT_TOOLS_WIN_TOOLCHAIN", "0"); + + RunGn(ANGLE_PATH, $"out/winui/{arch}", + $"target_cpu='{arch}' " + + $"is_component_build=false " + + $"is_debug=false " + + $"is_clang=false " + + $"angle_is_winappsdk=true " + + $"winappsdk_dir='{WINAPPSDK_PATH}' " + + $"enable_precompiled_headers=false " + + $"angle_enable_null=false " + + $"angle_enable_wgpu=false " + + $"angle_enable_gl_desktop_backend=false " + + $"angle_enable_vulkan=false"); + + RunNinja(ANGLE_PATH, $"out/winui/{arch}", "libEGL libGLESv2"); + } finally { + System.Environment.SetEnvironmentVariable("DEPOT_TOOLS_WIN_TOOLCHAIN", ""); + } + + var outDir = OUTPUT_PATH.Combine(arch); + EnsureDirectoryExists(outDir); + CopyFileToDirectory(ANGLE_PATH.CombineWithFilePath($"out/winui/{arch}/libEGL.dll"), outDir); + CopyFileToDirectory(ANGLE_PATH.CombineWithFilePath($"out/winui/{arch}/libEGL.pdb"), outDir); + CopyFileToDirectory(ANGLE_PATH.CombineWithFilePath($"out/winui/{arch}/libGLESv2.dll"), outDir); + CopyFileToDirectory(ANGLE_PATH.CombineWithFilePath($"out/winui/{arch}/libGLESv2.pdb"), outDir); + } +}); + +Task("Default") + .IsDependentOn("sync-ANGLE") + .IsDependentOn("ANGLE"); + +RunTarget(TARGET); diff --git a/native/winui/build.cake b/native/winui/build.cake index 9533fd98fa..20030f410c 100644 --- a/native/winui/build.cake +++ b/native/winui/build.cake @@ -4,58 +4,6 @@ DirectoryPath OUTPUT_PATH = MakeAbsolute(ROOT_PATH.Combine("output/native/winui" #load "../../scripts/cake/native-shared.cake" #load "../../scripts/cake/msbuild.cake" -#load "ANGLE.cake" - -Task("ANGLE") - .IsDependentOn("git-sync-deps") - .WithCriteria(IsRunningOnWindows()) - .Does(() => -{ - var ANGLE_PATH = ROOT_PATH.Combine("externals/angle"); - var WINAPPSDK_PATH = ROOT_PATH.Combine("externals/winappsdk"); - - var branch = GetVersion("ANGLE", "release"); - - InitializeAngle(branch, ANGLE_PATH, WINAPPSDK_PATH); - - Build("x86"); - Build("x64"); - Build("arm64"); - - void Build(string arch) - { - if (Skip(arch)) return; - - try { - System.Environment.SetEnvironmentVariable("DEPOT_TOOLS_WIN_TOOLCHAIN", "0"); - - RunGn(ANGLE_PATH, $"out/winui/{arch}", - $"target_cpu='{arch}' " + - $"is_component_build=false " + - $"is_debug=false " + - $"is_clang=false " + - $"angle_is_winappsdk=true " + - $"winappsdk_dir='{WINAPPSDK_PATH}' " + - $"enable_precompiled_headers=false " + - $"angle_enable_null=false " + - $"angle_enable_wgpu=false " + - $"angle_enable_gl_desktop_backend=false " + - $"angle_enable_vulkan=false"); - - RunNinja(ANGLE_PATH, $"out/winui/{arch}", "libEGL libGLESv2"); - } finally { - System.Environment.SetEnvironmentVariable("DEPOT_TOOLS_WIN_TOOLCHAIN", ""); - } - - var outDir = OUTPUT_PATH.Combine(arch); - EnsureDirectoryExists(outDir); - CopyFileToDirectory(ANGLE_PATH.CombineWithFilePath($"out/winui/{arch}/libEGL.dll"), outDir); - CopyFileToDirectory(ANGLE_PATH.CombineWithFilePath($"out/winui/{arch}/libEGL.pdb"), outDir); - CopyFileToDirectory(ANGLE_PATH.CombineWithFilePath($"out/winui/{arch}/libGLESv2.dll"), outDir); - CopyFileToDirectory(ANGLE_PATH.CombineWithFilePath($"out/winui/{arch}/libGLESv2.pdb"), outDir); - } -}); - Task("SkiaSharp.Views.WinUI.Native") .WithCriteria(IsRunningOnWindows()) .Does(() => @@ -92,7 +40,6 @@ Task("SkiaSharp.Views.WinUI.Native") }); Task("Default") - .IsDependentOn("ANGLE") .IsDependentOn("SkiaSharp.Views.WinUI.Native"); RunTarget(TARGET); diff --git a/scripts/azure-templates-stages.yml b/scripts/azure-templates-stages.yml index bd003e725f..f7e605d924 100644 --- a/scripts/azure-templates-stages.yml +++ b/scripts/azure-templates-stages.yml @@ -206,6 +206,36 @@ stages: buildAgent: ${{ parameters.buildAgentWindowsNative }} target: externals-winui additionalArgs: --buildarch=arm64 + - template: /scripts/azure-templates-bootstrapper.yml@self # Build Native ANGLE WinUI|x86 (Win) + parameters: + name: native_winui_angle_x86_windows + displayName: ANGLE WinUI x86 + sdl: ${{ parameters.sdl }} + buildExternals: ${{ parameters.buildExternals }} + buildPipelineType: ${{ parameters.buildPipelineType }} + buildAgent: ${{ parameters.buildAgentWindowsNative }} + target: externals-winui-angle + additionalArgs: --buildarch=x86 + - template: /scripts/azure-templates-bootstrapper.yml@self # Build Native ANGLE WinUI|x64 (Win) + parameters: + name: native_winui_angle_x64_windows + displayName: ANGLE WinUI x64 + sdl: ${{ parameters.sdl }} + buildExternals: ${{ parameters.buildExternals }} + buildPipelineType: ${{ parameters.buildPipelineType }} + buildAgent: ${{ parameters.buildAgentWindowsNative }} + target: externals-winui-angle + additionalArgs: --buildarch=x64 + - template: /scripts/azure-templates-bootstrapper.yml@self # Build Native ANGLE WinUI|arm64 (Win) + parameters: + name: native_winui_angle_arm64_windows + displayName: ANGLE WinUI arm64 + sdl: ${{ parameters.sdl }} + buildExternals: ${{ parameters.buildExternals }} + buildPipelineType: ${{ parameters.buildPipelineType }} + buildAgent: ${{ parameters.buildAgentWindowsNative }} + target: externals-winui-angle + additionalArgs: --buildarch=arm64 - template: /scripts/azure-templates-bootstrapper.yml@self # Build Native NanoServer|x64 (Win) parameters: name: native_win32_x64_nanoserver_windows