Skip to content

Conversation

@ladislas
Copy link
Member

fixes #378

Copy link
Contributor

Copilot AI left a 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.

Comment on lines 24 to 25
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),)"
Copy link

Copilot AI Nov 28, 2025

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.

Suggested change
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),)")

Copilot uses AI. Check for mistakes.
# 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)",
Copy link

Copilot AI Nov 28, 2025

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.

Suggested change
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)",

Copilot uses AI. Check for mistakes.
@ladislas ladislas force-pushed the ladislas/bugfix/simavr-patch branch from 0b209b9 to 1774585 Compare November 28, 2025 11:43
@ladislas ladislas force-pushed the ladislas/bugfix/simavr-patch branch 2 times, most recently from 7412493 to ae96e09 Compare November 28, 2025 11:57
@ladislas ladislas force-pushed the ladislas/bugfix/simavr-patch branch from ae96e09 to 6822b33 Compare November 28, 2025 13:59
ladislas added a commit that referenced this pull request Nov 28, 2025
@ladislas ladislas closed this Nov 28, 2025
@ladislas ladislas deleted the ladislas/bugfix/simavr-patch branch November 28, 2025 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simavr 1.7 problem: Issuing a load command from GDB throws an error, building from source does not work

2 participants