summaryrefslogtreecommitdiffstats
path: root/python/mozbuild/mozbuild/action/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/mozbuild/mozbuild/action/util.py')
-rw-r--r--python/mozbuild/mozbuild/action/util.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/python/mozbuild/mozbuild/action/util.py b/python/mozbuild/mozbuild/action/util.py
new file mode 100644
index 0000000000..d4102629ff
--- /dev/null
+++ b/python/mozbuild/mozbuild/action/util.py
@@ -0,0 +1,24 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import json
+import sys
+import time
+
+
+def log_build_task(f, *args, **kwargs):
+ """Run the given function, representing an entire build task, and log the
+ BUILDTASK metadata row to stdout.
+ """
+ start = time.monotonic()
+ try:
+ return f(*args, **kwargs)
+ finally:
+ end = time.monotonic()
+ print(
+ "BUILDTASK %s"
+ % json.dumps(
+ {"argv": sys.argv, "start": start, "end": end, "context": None}
+ )
+ )