-
Notifications
You must be signed in to change notification settings - Fork 237
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
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.
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.
other/tools/run_protoc.sh
Outdated
@@ -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 |
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.
Where does $OSTYPE
come from?
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.
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.
other/tools/run_protoc.sh
Outdated
@@ -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' |
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.
Does gsed
exist on every Mac?
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.
No, it needs to be installed bye 'brew install gnu-sed'
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? |
@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. |
Great, thank you! |
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. 😄