From b0f26d11ffafdbab75ae61ef56a6367f9f0a149d Mon Sep 17 00:00:00 2001 From: kycn <35106533+kycn@users.noreply.github.com> Date: Tue, 30 Apr 2024 08:17:13 +0000 Subject: [PATCH] Bug 1892641 - Add profile markers for gradle project evaluations and task executions to capture execution times in the build profiles. r=florian,glandium Differential Revision: https://phabricator.services.mozilla.com/D208094 --- build.gradle | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/build.gradle b/build.gradle index 75c6d7ba34b3..55da44edcf71 100644 --- a/build.gradle +++ b/build.gradle @@ -73,6 +73,34 @@ def getRustVersionFor(packageName) { } allprojects { + def shouldPrintBuildStatus = + System.getenv("MACH") && !System.getenv("NO_BUILDSTATUS_MESSAGES") + + if (shouldPrintBuildStatus) { + // Adding new line before each line to make sure they're dumped as a separate line. + // Add profile marker to the start of the project evaluation + project.beforeEvaluate { + println "\nBUILDSTATUS START_gradle:evaluate-project ${project.name}" + } + + // Add profile marker to the end of the project evaluation + project.afterEvaluate { + println "\nBUILDSTATUS END_gradle:evaluate-project ${project.name}" + } + + tasks.configureEach { task -> + // Add profile marker to the start of the gradle task + task.doFirst { + println "\nBUILDSTATUS START_gradle:${project.name}-tasks ${task.name}" + } + + // Add profile marker to the end of the gradle task + task.doLast { + println "\nBUILDSTATUS END_gradle:${project.name}-tasks ${task.name}" + } + } + } + // Expose the per-object-directory configuration to all projects. ext { mozconfig = gradle.mozconfig