GSoC 2021 Improvements to Haiku-format Final update

Blog post by saloni on Wed, 2021-08-18 12:07

GSoC 2021 Improvements to Haiku-format Final update

It has rightly been said - “All good things come to an end”. Google Summer of Code too was one of the good experiences I’ve had, in the sense that I didn’t know anything about the Open Source world. It provided the exact platform that I needed to kickstart my open source contributions.

About my project:

Haiku has its own coding standards which describe how the code should be formatted. Haiku-format is a tool that reformats code according to Haiku coding style but it is not giving desired results. So, we need to format the code such that when this code is run on Haiku the coding style of code gets updated according to haiku guidelines, but it has to be compiled on the developer machine and then run manually.

The tool ' haiku-format ' can be used to check the format according to guidelines which will be integrated with concourse to automate the process of checking coding style.

What we achieved?

I started with the input preferences directory and started solving the issues according to haiku guidelines. Following erros were solved:

  • Preserve the indentation of comments
  • Removal of braces for multiline control statements
  • Line break after return type in function definitions
  • Unusual indentation of BLayoutBuilder block
  • Extra space before ++ operator in for loop
  • Tabs are converted into spaces
  • Remove extra spacing for std::nothrow.
  • ' : ' should come on its own line and initializers in following lines
  • Empty functions to inline

Along with the errors in input directory, same errors persist in other directories too. So they also got solved. With these major bugs got solved and the clang-format further doesn’t lead to break the code or build anymore.

But where’s the code?

S/NWhat I did?Merge Request or Code Link
1.Removes extra space between new and (std::nothrow)
2.' : ' should come on its own line and initializers in following lines
3.Empty functions to inline
4.Preserve indentation of comments
5.Removal of braces for multiline control statements
6.Line break after return type in function definitions
7.Unusual whitespace for multiline for loop
8.Unusual indentation of BLayoutBuilder block
9.Tabs are converted into spaces
10.Input preferences: test reformatting with haiku-format
11.Updates code according to haiku guidelines with clang-format
12.Updates code according to haiku guidelines with haiku-format-10.x

What’s next?

Time and again, I’ve written about my love for open source software and the freedom it brings. I’ve decided that I’ll continue contributing to open source in my spare time. I’ll keep contributing to these projects because the codebase is really interesting and that they’ve provided me the stepping stones into the open source world.

What we under-estimated?

I wrote in my proposal that to solve input directory errors which was supposed to be done before the first evaluation but I did the mistake of under-estimating how much time it takes to produce efficient result. This work takes a lot of time because it needs a complete understanding of how the llvm code works. But Pulkomandy and Preetpal explained me how the code works. As there was number of files, it was difficult to figure out which file should contain the solution of the problem

Next problem which I face was solving the unusual indentation of BLayoutBuilder block. As it was almost impossible for the clang-format to do this. Another one was tabs were converted into spaces.

The basic idea was :

indented 1 tab: qualifiers (volatile, virtual, static)
indented 3 tabs: type of fields and return type of functions
indented 2 tabs: function or field name

These take alot of time and patience. Even sometimes I messed up with github branches but Pulkomandy always patiently explained me and corrected my mistakes.

I have learnt so many new things in these months about haiku and git.

Work to do:

I have setup a base for us to work upon this but this needs testing on other directories that are pending. As much I have tested the major errors have been solved and there might be some minor errors which will not break code.

Final Note

All in all, this journey of GSoC has been one of the most beautiful ones when it comes to my career. It was a really wholesome experience with the whole community. I’d like to extend my gratitude to each and every person involved with me over this journey.

A special thanks to my mentors Preetpal Kaur and Adrien Destugues. They mentored me really well and was always ready to help. Thank you for being patient with me and clarifying my doubts.

Also, a big thanks to owenca and Suhel for helping and clarifying my doubts. Thank you Haiku members and Google supporting open source software for providing students like me with this opportunity.

Weekly Blogs: