Skip to content

Commit

Permalink
Build ANGLE separately (#2950)
Browse files Browse the repository at this point in the history
* Build ANGLE separately

The public CI agents are now running out of space.

* Update build.cake
  • Loading branch information
mattleibow authored Jul 19, 2024
1 parent 215abb5 commit e3ab2e4
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 56 deletions.
75 changes: 72 additions & 3 deletions native/winui/ANGLE.cake → native/winui-angle/build.cake
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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);
Expand All @@ -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",
Expand All @@ -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)) {
Expand All @@ -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);
53 changes: 0 additions & 53 deletions native/winui/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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(() =>
Expand Down Expand Up @@ -92,7 +40,6 @@ Task("SkiaSharp.Views.WinUI.Native")
});

Task("Default")
.IsDependentOn("ANGLE")
.IsDependentOn("SkiaSharp.Views.WinUI.Native");

RunTarget(TARGET);
30 changes: 30 additions & 0 deletions scripts/azure-templates-stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e3ab2e4

Please sign in to comment.