aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-09-24 11:25:44 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-09-25 14:52:07 +0200
commit3a6920ebdcae0a2f9fee6ddf980fc8c7c94cf89c (patch)
tree899e07f3997425cf2402850380301aae03ce1f30 /mesonbuild/mesonlib.py
parentc4f96e00a6a49613efd25fe75b521ea2dff72f8d (diff)
downloadmeson-3a6920ebdcae0a2f9fee6ddf980fc8c7c94cf89c.zip
meson-3a6920ebdcae0a2f9fee6ddf980fc8c7c94cf89c.tar.gz
meson-3a6920ebdcae0a2f9fee6ddf980fc8c7c94cf89c.tar.bz2
Add helper to print warnings once
The helper is general, although in this patch it is only used for warnings. No functional change intended.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 5df7311..1adc752 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -20,7 +20,7 @@ import time
import platform, subprocess, operator, os, shlex, shutil, re
import collections
from enum import Enum
-from functools import lru_cache
+from functools import lru_cache, update_wrapper
import typing
import uuid
@@ -1496,6 +1496,19 @@ def get_wine_shortpath(winecmd, wine_paths):
return wine_path.strip(';')
+def run_once(func):
+ ret = []
+
+ def wrapper(*args, **kwargs):
+ if ret:
+ return ret[0]
+
+ val = func(*args, **kwargs)
+ ret.append(val)
+ return val
+
+ return update_wrapper(wrapper, func)
+
class OptionProxy:
def __init__(self, value):