-
Notifications
You must be signed in to change notification settings - Fork 80
Fix Makefile.common patch/gsub #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the Makefile.common patching logic to work correctly with versioned avr-gcc installations. The change replaces a simple path substitution with a more robust approach that dynamically finds and uses the first matching avr-gcc installation directory.
- Replaces the gsub pattern to search for any avr-gcc* directory in Homebrew's Cellar
- Uses Makefile variables and wildcard expansion instead of shell test commands
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Formula/simavr.rb
Outdated
| s.gsub! "ifneq (${shell test -d $(HOMEBREW_PREFIX)/Cellar/avr-gcc* && echo Exists}, Exists)", | ||
| "AVR_GCC_DIR := $(firstword $(wildcard $(HOMEBREW_PREFIX)/Cellar/avr-gcc*/))\n ifeq ($(AVR_GCC_DIR),)" |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gsub! call has inconsistent indentation in the replacement text. The newline character is followed by 3 spaces, but this may not match the indentation in the original Makefile.common file. Incorrect indentation in Makefiles can cause syntax errors or unexpected behavior. Verify the correct indentation level needed in the target file and adjust accordingly.
| s.gsub! "ifneq (${shell test -d $(HOMEBREW_PREFIX)/Cellar/avr-gcc* && echo Exists}, Exists)", | |
| "AVR_GCC_DIR := $(firstword $(wildcard $(HOMEBREW_PREFIX)/Cellar/avr-gcc*/))\n ifeq ($(AVR_GCC_DIR),)" | |
| s.gsub!(/^(\s*)ifneq \(\$\{shell test -d \$(HOMEBREW_PREFIX)\/Cellar\/avr-gcc\* && echo Exists\}, Exists\)/, | |
| "\\1AVR_GCC_DIR := $(firstword $(wildcard $(HOMEBREW_PREFIX)/Cellar/avr-gcc*/))\n\\1ifeq ($(AVR_GCC_DIR),)") |
Formula/simavr.rb
Outdated
| # Patch Makefile.common to work with versioned avr-gcc | ||
| inreplace "Makefile.common" do |s| | ||
| s.gsub! "$(HOMEBREW_PREFIX)/Cellar/avr-gcc/", "$(HOMEBREW_PREFIX)/Cellar/avr-gcc@*/" | ||
| s.gsub! "ifneq (${shell test -d $(HOMEBREW_PREFIX)/Cellar/avr-gcc* && echo Exists}, Exists)", |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The search pattern uses ${shell ...} but standard Makefile syntax uses $(shell ...) for command substitution. If the actual Makefile.common file uses $(shell ...) instead of ${shell ...}, this gsub! will not find a match and silently fail to apply the patch. Consider verifying the exact syntax in the source file.
| s.gsub! "ifneq (${shell test -d $(HOMEBREW_PREFIX)/Cellar/avr-gcc* && echo Exists}, Exists)", | |
| s.gsub! "ifneq ($(shell test -d $(HOMEBREW_PREFIX)/Cellar/avr-gcc* && echo Exists), Exists)", |
0b209b9 to
1774585
Compare
7412493 to
ae96e09
Compare
ae96e09 to
6822b33
Compare
Closes #379. Signed-off-by: osxCrossTestBot <[email protected]>
fixes #378