diff mbox series

[1/4] bitbake-setup: define a global for the color choice

Message ID 20260213-improve-bbsetup-readability-v1-1-41cec3b06992@bootlin.com
State New
Headers show
Series bitbake-setup: Improve readability | expand

Commit Message

Antonin Godard Feb. 13, 2026, 1:50 p.m. UTC
Define a BBSETUP_COLOR global variable that holds the color choice
optionally passed from the command-line. This will be re-used in the
next commits to force subprocess commands to color their outputs, as
passing --color=auto in them always render without coloring.

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 bin/bitbake-setup | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 927c03a1033..547d3f36bff 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -29,6 +29,8 @@  import bb.process
 
 logger = bb.msg.logger_create('bitbake-setup', sys.stdout)
 
+BBSETUP_COLOR = False
+
 # These settings can only be set in the global context
 GLOBAL_ONLY_SETTINGS = (
     "top-dir-prefix",
@@ -1095,6 +1097,10 @@  def main():
     elif args.quiet:
         logger.setLevel(logging.ERROR)
 
+    global BBSETUP_COLOR
+    if args.color == 'always' or (args.color == 'auto' and sys.stdout.isatty() and os.environ.get('NO_COLOR', '') == ''):
+        BBSETUP_COLOR = True
+
     # Need to re-run logger_create with color argument
     # (will be the same logger since it has the same name)
     bb.msg.logger_create('bitbake-setup', output=sys.stdout,