[GRASS-dev] Replace GNU Indent with ClangFormat?
Markus Neteler
neteler at osgeo.org
Tue Mar 22 02:23:48 PDT 2022
+1
FYI - on Fedora:
clang-format --version
clang-format version 13.0.0 (Fedora 13.0.0-3.fc35)
Markus
On Mon, Mar 21, 2022 at 6:43 PM Anna Petrášová <kratochanna at gmail.com> wrote:
>
> +1
>
> On Ubuntu 20.04 LTS, there is ClangFormat 12, I suppose there will be 13 in the upcoming 22.04 release.
>
> Anna
>
> On Mon, Mar 21, 2022 at 10:01 AM Nicklas Larsson via grass-dev <grass-dev at lists.osgeo.org> wrote:
>>
>> Formatting the C and C++ code, making a consistent coding style was proposed for G8 [1]. Unfortunately, it didn't make it. There were attempts to do this [2, 3], but numerous problem arose using `util/grass_indent.sh` and its batch script `util/grass_indent_ALL.sh`, which are based on GNU Indent [4]. These problem are probably originate in the comparatively limited functionality and lack of active development on GNU Indent.
>>
>> I just filed a PR [5] with the aim to replace GNU Indent with ClangFormat [6] and later (separately!) make a bulk formatting of all the code. Running clang-format on all *.h|*.c|*.cpp (some 3000+) files goes fine without any issues. I have created a `.clang-format` file with the settings as close as possible to the ones in `grass_indent.sh` (somewhat outdated described in [7]).
>>
>> ClangFormat is a working program in active development, therefore its performance is version dependent (similar to what we have had with Black for Python). On the other hand, its adaptation is increasing, now used in several big and small projects.
>>
>>
>> Now the question is first of all: is using ClangFormat something the GRASS dev community (you) would want or could live with for this project?
>> And if so, what version of ClangFormat should then be the starting point (what do you have reasonably easy available for your dev platform)? The present settings in the PR are derived from ClangFormat 13, but could possibly be back ported if really needed.
>>
>> Please check out the settings, as well as some code files formatted for illustrational purposes only, at the PR [5].
>>
>>
>> Best,
>> Nicklas
>>
>>
>>
>> [1] https://trac.osgeo.org/grass/wiki/Grass8Planning#Codeorganisationcodingstyles
>> [2] https://github.com/OSGeo/grass/issues/1630
>> [3] https://github.com/OSGeo/grass/pull/2270
>> [4] https://www.gnu.org/software/indent/
>> [5] https://github.com/OSGeo/grass/pull/2272
>> [6] https://clang.llvm.org/docs/ClangFormat.html
>> [7] https://trac.osgeo.org/grass/wiki/Submitting/C#Indentation
>>
>> _______________________________________________
>> grass-dev mailing list
>> grass-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/grass-dev
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-dev
--
Markus Neteler, PhD
https://www.mundialis.de - free data with free software
https://grass.osgeo.org
https://courses.neteler.org/blog
More information about the grass-dev
mailing list