Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/22885 )

Change subject: scons: Add "warning" and "error" methods.
......................................................................

scons: Add "warning" and "error" methods.

These methods will make reporting errors less verbose and more
consistent, since they'll handle some formating, setting colors,
prefixing with an appropriate "Warning:" or "Error:" tag, and exiting
in the case of an error.

Change-Id: Iddea5bf342a4fc4b26002d8e98292f9dc57fa8cc
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22885
Reviewed-by: Jason Lowe-Power <ja...@lowepower.com>
Maintainer: Jason Lowe-Power <ja...@lowepower.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M site_scons/gem5_scons/__init__.py
1 file changed, 18 insertions(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/site_scons/gem5_scons/__init__.py b/site_scons/gem5_scons/__init__.py
index 0521862..86494cf 100644
--- a/site_scons/gem5_scons/__init__.py
+++ b/site_scons/gem5_scons/__init__.py
@@ -38,9 +38,12 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+from __future__ import print_function
+
 import os

 from gem5_scons.util import get_termcap
+import SCons.Script

 termcap = get_termcap()

@@ -124,4 +127,18 @@
             return ', '.join(f)
         return self.format % (com_pfx, fmt(srcs), fmt(tgts))

-__all__ = ['Transform']
+def print_message(prefix, color, message, **kwargs):
+    lines = message.split('\n')
+    message = prefix + ('\n' + ' ' * len(prefix)).join(lines)
+    print(color + termcap.Bold + message + termcap.Normal, **kwargs)
+
+def warning(*args, **kwargs):
+    message = ' '.join(args)
+    print_message('Warning: ', termcap.Yellow, message, **kwargs)
+
+def error(*args, **kwargs):
+    message = ' '.join(args)
+    print_message('Error: ', termcap.Red, message, **kwargs)
+    SCons.Script.Exit(1)
+
+__all__ = ['Transform', 'warning', 'error']

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/22885
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Iddea5bf342a4fc4b26002d8e98292f9dc57fa8cc
Gerrit-Change-Number: 22885
Gerrit-PatchSet: 2
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to