Skip to content

Conversation

dpfrey
Copy link
Contributor

@dpfrey dpfrey commented May 13, 2021

No description provided.

@MichalPrincNXP
Copy link
Member

Hello @dpfrey , thank you for this PR. I have two comments/questions:

  • What is the first command about (Make run_clang_format.py executable)? I do not see any difference.
  • I would stay with "subprocess.call(["clang-format-10.0", "-i", file])" - thus users are informed again that the v10.0 needs to be used, maybe the description in https://github.com/EmbeddedRPC/erpc/wiki/Contributing could be updated to be more accurate about install folder naming / script content renaming

@dpfrey
Copy link
Contributor Author

dpfrey commented Jun 29, 2021

Thanks for taking a look at this @MichalPrincNXP.

git tracks file permissions. So prior to this PR, if someone clones eRPC, the run_clang_format.py will not have the executable permission and therefore it will not be possible to do:

$ ./run_clang_format.py

The user must either run:

$ python run_clang_format.py

or:

$ chmod a+x run_clang_format.py
$ ./run_clang_format.py

So it's basically just a minor ease of use change and it also helps to signal to the user that this python file is meant to be executed as a script rather than imported as a library.

I was previously building eRPC on arch linux and there was no clang-format-10 binary, only clang-format. My Arch Linux install imploded and I have installed Ubuntu and it has clang-format-10. I guess clang-format might be better for compatibility than clang-format-10, but I guess that makes it less clear that version 10 is required.

@MichalPrincNXP
Copy link
Member

Thank you, @dpfrey . Re. the way Clang version is checking, better approach would be runtime check, I think. I have updated the script by this runtime version checking ... may I ask you to try on your side, please? Thank you.
M.
run_clang_format.zip

Run "clang-format --version" and parse the results to check that
clang-format is at least as new as a minimum required version. Thanks to
Michal Princ <michal.princ@nxp.com> for the idea and initial
implementation.
@dpfrey
Copy link
Contributor Author

dpfrey commented Jul 7, 2021

Hi @MichalPrincNXP, I took the code from your zip file and modified it to allow any clang-format newer than 10.0.0. I pushed a new commit on top of this PR that adds the version checking.

@MichalPrincNXP
Copy link
Member

David, I would rather stick with 10.0.0 version. I have read that each version produces a littler different output and that is why one specified version would be preferred.

@Hadatko
Copy link
Member

Hadatko commented Jul 8, 2021

Hi @dpfrey it is really important to stick with one concrete version of clang-format application. Even minor version may provide different output. If users will change code with different clang-format application, they may change formatted code back and forth. This may result in redundant code format changes pushed to the repository.

@Hadatko
Copy link
Member

Hadatko commented Jul 8, 2021

Other changes looks great. Btw i would like to add this link to several places to let user know where to download binary https://releases.llvm.org/download.html (like documentation, formatting script,...).
Currently i think we are using clang-format from path environment. Maybe we should first check if exist variable CLANG_FORMAT_PATH. Users may use it to set path to downloaded clang-format.

What do you think @dpfrey, @MichalPrincNXP ?
@dpfrey do you think it can be part of this PR?

The previous version required clang-format >= 10.0.0, but this could
cause problems if a version > 10.0.0 formatted differently.
@dpfrey
Copy link
Contributor Author

dpfrey commented Jul 9, 2021

Thanks for the feedback @Hadatko And @MichalPrincNXP. I agree that it would be a problem if a clang-format newer than 10.0 produced output different from 10.0.0. In the latest commit, I require clang-format == 10.0.0 and I also made $CLANG_FORMAT_PATH the first choice and "clang-format" the backup.

@MichalPrincNXP MichalPrincNXP merged commit f419037 into EmbeddedRPC:develop Jul 19, 2021
@MichalPrincNXP
Copy link
Member

Great, thank you @dpfrey !

@dpfrey dpfrey deleted the pr_run_clang_format_cleanup branch July 19, 2021 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants