Skip to content

Conversation

@sairon
Copy link
Member

@sairon sairon commented Sep 10, 2025

The extra information printed when using the top-level makefile can clutter the output when it needs to be further processed, e.g. when running make show-info | jq. Make it respect the --silent flag (which also suppresses messages about changing directories which would break parsing as well).

Summary by CodeRabbit

  • New Features

    • Build now supports silent mode: invoking make with -s suppresses non-essential status messages while keeping default verbosity unchanged.
    • Status messages are now conditionally suppressed when silent mode is active.
  • Chores

    • Centralized printing of build status messages for consistent, cleaner output across targets without altering build results.

@sairon sairon requested a review from agners September 10, 2025 10:30
@sairon sairon added the build Build and CI related issues label Sep 10, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 10, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Introduces a SILENT variable and a print macro to conditionally emit messages in the Makefile; replaces direct echo/info outputs with $(call print, ...) for .DEFAULT, per-target defconfig, and build notices, suppressing these messages when make is run with -s.

Changes

Cohort / File(s) Summary
Makefile silent-print integration
Makefile
Added public variable SILENT := $(findstring s,$(word 1, $(MAKEFLAGS))); added public macro print (wraps $(info ...) and respects SILENT); replaced three direct echo/info invocations (.DEFAULT fallback, per-target defconfig notice, per-target build notice) with $(call print, ...).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant M as make
  participant F as Makefile
  participant P as print macro
  participant C as Console

  U->>M: invoke make (optionally -s)
  M->>F: parse Makefile, MAKEFLAGS
  F->>F: set SILENT := find 's' in MAKEFLAGS
  F->>P: $(call print, "message")
  alt SILENT set (silent mode)
    P--xC: (no output)
  else SILENT not set
    P->>C: info "message"
  end
  F->>M: continue target execution
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 993be97 and c719f2c.

📒 Files selected for processing (1)
  • Makefile (3 hunks)
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch makefile-support-silent

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
Makefile (1)

55-55: Propagate no-print-directory to all sub-makes

Extend the earlier change to all $(MAKE) calls so silent runs are fully clean.

-	$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL)
+	$(MAKE) $(NOPRINTDIR) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL)

Also apply to:

  • Line 42 (default target)
  • Line 52 (%-config sub-make)
  • Line 59 (buildroot-help)
  • Line 38 (.DEFAULT) — per earlier comment
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 0e3fd2c and 993be97.

📒 Files selected for processing (1)
  • Makefile (3 hunks)

Comment on lines +19 to +24
SILENT := $(findstring s,$(word 1, $(MAKEFLAGS)))

define print
$(if $(SILENT),,$(info $1))
endef

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Make silent-mode detection robust; prep a reusable flag for sub-makes

Current detection misses grouped short options and may false-positive on variable text. Filter out long options first and scan all short-option groups. Also precompute a flag to suppress directory spam in sub-makes.

-SILENT := $(findstring s,$(word 1, $(MAKEFLAGS)))
+SILENT := $(findstring s,$(filter-out --%,$(MAKEFLAGS)))
+
+# Pass to sub-makes to suppress "Entering/Leaving directory" noise when silent
+NOPRINTDIR := $(if $(SILENT),--no-print-directory,)
🤖 Prompt for AI Agents
In Makefile around lines 19-24, the current SILENT detection can be fooled by
long options and doesn't inspect grouped short options; change it to first strip
long options from MAKEFLAGS, then inspect remaining short-option groups for the
's' flag (e.g. compute a temp variable like MAKEFLAGS_SHORT := $(filter
%-%,$(MAKEFLAGS)) and then MAKEFLAGS_SHORT := $(filter-out
--%,$(MAKEFLAGS_SHORT)) and set SILENT := $(if $(findstring
s,$(MAKEFLAGS_SHORT)),1,) ), and then precompute and export a reusable flag for
sub-makes (e.g. SILENT_FLAG := $(if $(SILENT),-s,)) so sub-makes can use
$(SILENT_FLAG) to suppress directory spam.

# fallback target when target undefined here is given
.DEFAULT:
@echo "$(COLOR_STEP)=== Falling back to Buildroot target '$@' ===$(TERM_RESET)"
$(call print,$(COLOR_STEP)=== Falling back to Buildroot target '$@' ===$(TERM_RESET))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Also suppress “Entering/Leaving directory” noise from sub-makes

When piping output, those messages still appear even with -s. Pass --no-print-directory to the Buildroot sub-make (and replicate for other $(MAKE) calls below).

 .DEFAULT:
-	$(call print,$(COLOR_STEP)=== Falling back to Buildroot target '$@' ===$(TERM_RESET))
+	$(call print,$(COLOR_STEP)=== Falling back to Buildroot target '$@' ===$(TERM_RESET))
 	$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) "$@"
+	# ^ add $(NOPRINTDIR)

Apply:

-	$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) "$@"
+	$(MAKE) $(NOPRINTDIR) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) "$@"
🤖 Prompt for AI Agents
In Makefile around line 37, the Buildroot sub-make invocation prints
"Entering/Leaving directory" noise; update the $(MAKE) invocation that produces
the line "$(call print,$(COLOR_STEP)=== Falling back to Buildroot target '$@'
===$(TERM_RESET))" to pass --no-print-directory to the sub-make (i.e., add
--no-print-directory to the command that calls $(MAKE) for the Buildroot target)
and apply the same --no-print-directory flag to any other $(MAKE) calls in this
Makefile below to suppress those messages when piping output.

bash -c 'read -t 10 -p "Waiting 10s, press enter to continue or Ctrl-C to abort..."' || true; \
fi
@echo "$(COLOR_STEP)=== Using $*_defconfig ===$(TERM_RESET)"
$(call print,$(COLOR_STEP)=== Using $*_defconfig ===$(TERM_RESET))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Send warnings to stderr and skip the 10s prompt in silent/non-tty runs

To keep stdout machine-parseable and avoid blocking CI/pipes, redirect warnings to stderr and don’t wait in silent mode or when not attached to a TTY.

 $(TARGETS_CONFIG): %-config:
 	@if [ -f $(O)/.config ] && ! grep -q 'BR2_DEFCONFIG="$(DEFCONFIG_DIR)/$*_defconfig"' $(O)/.config; then \
-		echo "$(COLOR_WARN)WARNING: Output directory '$(O)' already contains files for another target!$(TERM_RESET)"; \
-		echo "         Before running build for a different target, run 'make distclean' first."; \
-		echo ""; \
-		bash -c 'read -t 10 -p "Waiting 10s, press enter to continue or Ctrl-C to abort..."' || true; \
+		echo "$(COLOR_WARN)WARNING: Output directory '$(O)' already contains files for another target!$(TERM_RESET)" 1>&2; \
+		echo "         Before running build for a different target, run 'make distclean' first." 1>&2; \
+		echo "" 1>&2; \
+		if [ -z "$(SILENT)" ] && [ -t 0 ]; then \
+			bash -c 'read -t 10 -p "Waiting 10s, press enter to continue or Ctrl-C to abort..."' || true; \
+		fi; \
 	fi
 	$(call print,$(COLOR_STEP)=== Using $*_defconfig ===$(TERM_RESET))
 	$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) "$*_defconfig"

Additionally pass $(NOPRINTDIR) to this sub-make (see next comment).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$(call print,$(COLOR_STEP)=== Using $*_defconfig ===$(TERM_RESET))
$(TARGETS_CONFIG): %-config:
@if [ -f $(O)/.config ] && ! grep -q 'BR2_DEFCONFIG="$(DEFCONFIG_DIR)/$*_defconfig"' $(O)/.config; then \
echo "$(COLOR_WARN)WARNING: Output directory '$(O)' already contains files for another target!$(TERM_RESET)" 1>&2; \
echo " Before running build for a different target, run 'make distclean' first." 1>&2; \
echo "" 1>&2; \
if [ -z "$(SILENT)" ] && [ -t 0 ]; then \
bash -c 'read -t 10 -p "Waiting 10s, press enter to continue or Ctrl-C to abort..."' || true; \
fi; \
fi
$(call print,$(COLOR_STEP)=== Using $*_defconfig ===$(TERM_RESET))
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) "$*_defconfig"
🤖 Prompt for AI Agents
In Makefile around line 51, the current rule prints a step message to stdout and
may block CI by waiting for a 10s prompt; update the invocation so warnings/step
messages go to stderr (redirect the print/echo output to >&2) and ensure the
sub-make is invoked with silent/non-tty detection so the 10s prompt is skipped
(check for .SILENT or test -t 1 and conditionally avoid the sleep/prompt), and
also add passing $(NOPRINTDIR) into the sub-make invocation so the child make
inherits the no-print-dir behavior.

Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM!

@sairon sairon force-pushed the makefile-support-silent branch from 993be97 to 2aee67d Compare September 11, 2025 12:05
The extra information printed when using the top-level makefile can clutter the
output when it needs to be further processed, e.g. when running
`make show-info | jq`. Make it respect the --silent flag (which also suppresses
messages about changing directories which would break parsing as well).
@sairon sairon force-pushed the makefile-support-silent branch from 2aee67d to c719f2c Compare September 11, 2025 12:05
@sairon sairon merged commit 0e09f22 into dev Sep 11, 2025
2 checks passed
@sairon sairon deleted the makefile-support-silent branch September 11, 2025 12:05
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

build Build and CI related issues cla-signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants