Earl Ou has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/35596 )

Change subject: scons: only wrap message with positive value
......................................................................

scons: only wrap message with positive value

In case we have small TTY, scons failed with wrong testwrap value. Fix
the issue.

Change-Id: I8ec1d55c6856c1e592a57a68067091b796ac84ae
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35596
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
M site_scons/gem5_scons/__init__.py
1 file changed, 15 insertions(+), 12 deletions(-)

Approvals:
  Gabe Black: 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 3323112..4208cf1 100644
--- a/site_scons/gem5_scons/__init__.py
+++ b/site_scons/gem5_scons/__init__.py
@@ -160,20 +160,23 @@
     text_width = 80

 def print_message(prefix, color, message, **kwargs):
-    # Precompute some useful values.
     prefix_len = len(prefix)
-    wrap_width = text_width - prefix_len
-    padding = ' ' * prefix_len
+    if text_width > prefix_len:
+        wrap_width = text_width - prefix_len
+        padding = ' ' * prefix_len

-    # First split on newlines.
-    lines = message.split('\n')
-    # Then wrap each line to the required width.
-    wrapped_lines = []
-    for line in lines:
-        wrapped_lines.extend(textwrap.wrap(line, wrap_width))
- # Finally add the prefix and padding on extra lines, and glue it all back
-    # together.
-    message = prefix + ('\n' + padding).join(wrapped_lines)
+        # First split on newlines.
+        lines = message.split('\n')
+        # Then wrap each line to the required width.
+        wrapped_lines = []
+        for line in lines:
+            wrapped_lines.extend(textwrap.wrap(line, wrap_width))
+ # Finally add the prefix and padding on extra lines, and glue it all
+        # back together.
+        message = prefix + ('\n' + padding).join(wrapped_lines)
+    else:
+        # We have very small terminal, indent formatting doesn't help.
+        message = prefix + message
     # Add in terminal escape sequences.
     message = color + termcap.Bold + message + termcap.Normal
     # Actually print the message.

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

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I8ec1d55c6856c1e592a57a68067091b796ac84ae
Gerrit-Change-Number: 35596
Gerrit-PatchSet: 4
Gerrit-Owner: Earl Ou <[email protected]>
Gerrit-Reviewer: Earl Ou <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jui-min Lee <[email protected]>
Gerrit-Reviewer: Yu-hsin Wang <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to