doc: add Meson coding style to contributors guide
authorBruce Richardson <bruce.richardson@intel.com>
Tue, 20 Apr 2021 10:22:29 +0000 (11:22 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 21 Apr 2021 12:04:09 +0000 (14:04 +0200)
To help with consistency across all files, add a section to the
contributors guide on meson coding style. Although short, this covers
the basics for now, and can be extended in future as we see the need.

Meson style guide recommends four-space indents, like for python,
so add to editorconfig file.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
.editorconfig
doc/guides/contributing/coding_style.rst

index d705825..5101630 100644 (file)
@@ -17,6 +17,11 @@ max_line_length = 80
 indent_style = space
 indent_size = 4
 
+[meson.build]
+indent_style = space
+indent_size = 4
+tab_width = 4
+
 [*.rst]
 indent_style = space
 indent_size = 3
index fdcd218..dae1bd3 100644 (file)
@@ -1012,3 +1012,49 @@ headers
 
 version
        As above
+
+
+Meson Coding Style
+------------------
+
+The following guidelines apply to the build system code in meson.build files in DPDK.
+
+* Indentation should be using 4 spaces, no hard tabs.
+
+* Line continuations should be doubly-indented to ensure visible difference from normal indentation.
+  Any line continuations beyond the first may be singly indented to avoid large amounts of indentation.
+
+* Lists of files or components must be alphabetical unless doing so would cause errors.
+
+* Two formats are supported for lists of files or list of components:
+
+   * For a small number of list entries, generally 3 or fewer, all elements may be put on a single line.
+     In this case, the opening and closing braces of the list must be on the same line as the list items.
+     No trailing comma is put on the final list entry.
+   * For lists with more than 3 items,
+     it is recommended that the lists be put in the files with a *single* entry per line.
+     In this case, the opening brace, or ``files`` function call must be on a line on its own,
+     and the closing brace must similarly be on a line on its own at the end.
+     To help with readability of nested sublists, the closing brace should be dedented to appear
+     at the same level as the opening braced statement.
+     The final list entry must have a trailing comma,
+     so that adding a new entry to the list never modifies any other line in the list.
+
+Examples::
+
+    sources = files('file1.c', 'file2.c')
+
+    subdirs = ['dir1', 'dir2']
+
+    headers = files(
+            'header1.c',
+            'header2.c',
+            'header3.c',   # always include trailing comma
+    )                      # closing brace at indent level of opening brace
+
+    components = [
+            'comp1',
+            'comp2',
+            ...
+            'compN',
+    ]