Skip to content

macOS support for run_protoc.sh #391

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

Merged
merged 2 commits into from
Sep 20, 2021

Conversation

mattes-bru
Copy link
Contributor

I stumbled over an incompatibility with the macOS version of sed. I got this solved by doing this little hack using the homebrew gnu-sed package. There might be better solutions but I am neither a bash nor an regex expert but I think I'd better come with a solution than a problem. 😄

Copy link
Collaborator

@julianoes julianoes left a comment

Choose a reason for hiding this comment

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

Sorry, I was meaning to cherry-pick my fix that I did here:
mavlink/MAVSDK@f158136

Now we just need to decide which one we prefer.

@@ -24,7 +24,11 @@ command -v protoc-gen-mavsdk > /dev/null || {
}

function snake_case_to_camel_case {
echo $1 | sed -r 's/(^|_)([a-z])/\U\2/g'
if [[ "$OSTYPE" == "darwin"* ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does $OSTYPE come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is from one of the first search hits on "how to determine the os type in bash scripts" 😀

It seems to be defined by default.

@@ -24,7 +24,11 @@ command -v protoc-gen-mavsdk > /dev/null || {
}

function snake_case_to_camel_case {
echo $1 | sed -r 's/(^|_)([a-z])/\U\2/g'
if [[ "$OSTYPE" == "darwin"* ]]; then
echo $1 | gsed -r 's/(^|_)([a-z])/\U\2/g'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does gsed exist on every Mac?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it needs to be installed bye 'brew install gnu-sed'

@mattes-bru
Copy link
Contributor Author

Based on your comments and my responses, I would prefer yours, because it seems to be OS independent without any additional packages.

@julianoes
Copy link
Collaborator

Based on your comments and my responses, I would prefer yours, because it seems to be OS independent without any additional packages.

Me too. I was just trying to cherry-pick it but now realized it is already applied, however, that's in the C++ repo, not the Python one! Would you mind making a PR and using the awk magic?

@mattes-bru
Copy link
Contributor Author

@julianoes I pushed your suggestion to my branch. This should be enough to update this PR, otherwise let me know. I also tested it on my machine and it worked as expected.

@julianoes
Copy link
Collaborator

Great, thank you!

@JonasVautherin JonasVautherin merged commit ab4b774 into mavlink:main Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants