Skip to content
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

fix(stm32CubeProg): fallback to BSD getopt on mac #100

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

fpistm
Copy link
Member

@fpistm fpistm commented Jul 1, 2024

By default, MacOS uses getopt from FreeBSD and not the GNU-based one.
Then "-o" and long options are not supported except if gnu-getopt is installed.

Fixes #99

Main advantage to kept GNU getopt by default is it is able to deal with space in arguments.
Install the package gnu-getopt via e.g. Homebrew:

brew install gnu-getopt

If not installed the BSD getopt is used but long option and space in arguments are not supported.

@fpistm fpistm added the enhancement New feature or request label Jul 1, 2024
@fpistm fpistm added this to the 2.2.3 milestone Jul 1, 2024
@fpistm fpistm force-pushed the getopt branch 2 times, most recently from 439a07d to 4020213 Compare July 15, 2024 13:10
@fpistm fpistm force-pushed the getopt branch 2 times, most recently from 8fee15e to 1c5f1bd Compare July 15, 2024 14:59
if ! command -v $STM32CP_CLI >/dev/null 2>&1; then
aborting
fi
if ! command -v /usr/local/opt/gnu-getopt/bin/getopt >/dev/null 2>&1; then
Copy link

Choose a reason for hiding this comment

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

By the way, for Apple Silicon devices, the path should be /opt/homebrew/opt/gnu-getopt/, maybe this needs to be checked as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @lhvy
Thanks for the feedback, I'm not familiar with mac.
So something like this:

    if ! command -v /usr/local/opt/gnu-getopt/bin/getopt >/dev/null 2>&1; then
      if ! command -v /opt/homebrew/opt/gnu-getopt/bin/getopt >/dev/null 2>&1; then
        echo "Warning: long options not supported due to getopt from FreeBSD usage."
        GNU_GETOPT=n
      else
        export PATH="/opt/homebrew/opt/gnu-getopt/bin":"$PATH"
      fi
    else
      export PATH="/usr/local/opt/gnu-getopt/bin":"$PATH"
    fi

By default, MacOS uses getopt from FreeBSD and not the GNU-based one.
Then "-o" and long options are not supported except if gnu-getopt
is installed.

Fixes stm32duino#99

Signed-off-by: Frederic Pillon <[email protected]>
@fpistm fpistm changed the title fix(stm32CubeProg): use BSD getopt fix(stm32CubeProg): fallback to BSD getopt on mac Jul 17, 2024
@fpistm fpistm merged commit 17a14b7 into stm32duino:main Jul 17, 2024
@fpistm fpistm deleted the getopt branch July 17, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

Cannot upload sketch on MacOS
2 participants