-
Notifications
You must be signed in to change notification settings - Fork 10
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
Format generated code only when clang-format is available #101
Conversation
ae4a31b
to
672d424
Compare
672d424
to
4ac5d78
Compare
lib/unifex/interface_IO.ex
Outdated
"#{out_base_path}.h #{out_base_path}.c #{out_base_path}.cpp" | ||
) | ||
# Format generated code only when clang-format is available | ||
if Mix.shell().cmd("whereis clang-format") == 0 do |
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 seems whereis
always returns 0 on Mac
iex(1)> System.cmd("whereis", ~w(dupa))
{"dupa:\n", 0}
test/test_helper.exs
Outdated
ExUnit.start() | ||
# clang-format is required to format the generated code | ||
# it won't match the reference files otherwise | ||
case System.cmd("clang-format", ~w(--version)) do |
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.
System.cmd/2
raises%ErlangError{orginal: :enoent}
, when it can't find a command- Why do you use one time
$ whereis clang-format
and second time$ clang-format
to check, ifclang-format
is available? - Analogically, why do you use
System.cmd/2
in one place, to execute command, butMix.shell().cmd/1
in the another place?
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.
Honestly speaking I don't know what is the difference between System.cmd
and Mix.shell().cmd()
except that Mix
might not be available in the runtime. I moved everything to System
9bd4b94
to
ca51652
Compare
lib/unifex/utils.ex
Outdated
|
||
@spec clang_format_installed?() :: boolean() | ||
def clang_format_installed?() do | ||
if System.find_executable("clang-format"), do: true, else: false |
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.
if System.find_executable("clang-format"), do: true, else: false | |
System.find_executable("clang-format") != nil |
We shouldn't require clang-format to be available on the system. Otherwise, everyone who compiles membrane package and doesn't have clang-format, will get a warning
/usr/bin/sh: 1: clang-format: not found
.clang-format
is required in tests so they should remain deterministic.