[haiku-development] Re: haiku-format for C++ developers

  • From: Owen Pan <owenpiano@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 7 Aug 2018 02:25:56 -0700

Hi Adrien,

On Tue, Aug 7, 2018 at 1:10 AM Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
wrote:

5 août 2018 18:18 "Owen Pan" <owenpiano@xxxxxxxxx> a écrit:

Inspired by this year's GSoC ideas (
https://www.haiku-os.org/community/gsoc/2018/ideas#other) and
clang-format, I have developed a C++ code formatter for Haiku's coding
guidelines. Here is the
link: https://github.com/owenca/haiku-format

It can be built on both x86 and x86_64. Just run build.sh from the top
folder, and haiku-format
will be created in the same folder. Please try it out and let me know
what you think.

Hi Owen,

Thanks, it looks like a nice tool to have!

I have several questions:
- Why can't we use the standard clang-format? What are the differences?

Although clang-format can be configured to handle most of Haiku's coding
guidelines, it doesn't support the following Haiku rules (among others):
- constructor initializer list
- all the enhancement requests found at
https://github.com/owenca/haiku-format/issues

- Why does this need to download llvm sources during build? Can't we use a
packaged llvm?

The lastest LLVM release is 6.0.1, but Haiku is still on 5.0.0. Although it
doesn't seem that LLVM has an official way to build clang from prebuit LLVM
binaries, I think we can make it work after LLVM 6.0.1 is ported on Haiku.

- Can this be integrated into Gerrit? It would be great to have a bot there
giving Code-Change: +1 or -1 on submitted patches automatically. It would
save a lot of time for those of us reviewing the changes.

I think it's possible if Gerrit has API's that can be integrated with
clang-format API's. However, I would think that any code submitted to
Gerrit should have already reformatted by clang-format or haiku-format so
that this would be unnecessary. :)

Thanks,
Owen

Other related posts: