X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=doc%2Fguides%2Fcontributing%2Fcoding_style.rst;h=b27b5fcfdbe87c8bef354c83a8b8542c83909ccc;hb=34fd4373ce76efd0236e59397c495762c2ec9e64;hp=fdcd21861d0b6bd17c4defc2c6a10fe4ab5bbf2f;hpb=bc4617433845c39af339ca76afd6f00a706169c5;p=dpdk.git diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst index fdcd21861d..b27b5fcfdb 100644 --- a/doc/guides/contributing/coding_style.rst +++ b/doc/guides/contributing/coding_style.rst @@ -55,7 +55,7 @@ License Header ~~~~~~~~~~~~~~ Each file must begin with a special comment containing the -`Software Package Data Exchange (SPDX) License Identfier `_. +`Software Package Data Exchange (SPDX) License Identifier `_. Generally this is the BSD License, except for code granted special exceptions. The SPDX licences identifier is sufficient, a file should not contain @@ -759,7 +759,7 @@ Examples: * The virtio network PMD in ``drivers/net/virtio`` uses ``pmd.net.virtio`` * The eventdev software poll mode driver in ``drivers/event/sw`` uses ``pmd.event.sw`` * The octeontx mempool driver in ``drivers/mempool/octeontx`` uses ``pmd.mempool.octeontx`` - * The DPDK hash library in ``lib/librte_hash`` uses ``lib.hash`` + * The DPDK hash library in ``lib/hash`` uses ``lib.hash`` Specializations ~~~~~~~~~~~~~~~ @@ -926,7 +926,7 @@ name If a library's .so or .a file differs from that given in the directory name, the name should be specified using this variable. In practice, since the convention is that for a library called ``librte_xyz.so``, the - sources are stored in a directory ``lib/librte_xyz``, this value should + sources are stored in a directory ``lib/xyz``, this value should never be needed for new libraries. .. note:: @@ -1012,3 +1012,59 @@ 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. + +* Where a line is split in the middle of a statement, e.g. a multiline `if` statement, + brackets should be used in preference to escaping the line break. + +Example:: + + if (condition1 and condition2 # line breaks inside () need no escaping + and condition3 and condition4) + x = y + endif + +* 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', + ]