From fa64dcaf056ea16b2d7aadc0449a57589a0a5453 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Fri, 10 Aug 2018 15:30:25 -0500 Subject: [PATCH] [pybind] Revive compiler diagnostics support --- pyopencl/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 46e5266e..15ec5b1b 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -221,9 +221,27 @@ if _cl.have_gl(): pass +# {{{ diagnostics + class _ErrorRecord(Record): pass +class CompilerWarning(UserWarning): + pass + + +def compiler_output(text): + import os + from warnings import warn + if int(os.environ.get("PYOPENCL_COMPILER_OUTPUT", "0")): + warn(text, CompilerWarning) + else: + warn("Non-empty compiler output encountered. Set the " + "environment variable PYOPENCL_COMPILER_OUTPUT=1 " + "to see more.", CompilerWarning) + +# }}} + # {{{ find pyopencl shipped source code -- GitLab