cmake-format.py 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. # ----------------------------------
  2. # Options affecting listfile parsing
  3. # ----------------------------------
  4. with section("parse"): # type: ignore
  5. # Specify structure for custom cmake functions
  6. additional_commands = { 'foo': { 'flags': ['BAR', 'BAZ'],
  7. 'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}}}
  8. # Override configurations per-command where available
  9. override_spec = {}
  10. # Specify variable tags.
  11. vartags = []
  12. # Specify property tags.
  13. proptags = []
  14. # -----------------------------
  15. # Options affecting formatting.
  16. # -----------------------------
  17. with section("format"): # type: ignore
  18. # Disable formatting entirely, making cmake-format a no-op
  19. disable = False
  20. # How wide to allow formatted cmake files
  21. line_width = 100
  22. # How many spaces to tab for indent
  23. tab_size = 2
  24. # If true, lines are indented using tab characters (utf-8 0x09) instead of
  25. # <tab_size> space characters (utf-8 0x20). In cases where the layout would
  26. # require a fractional tab character, the behavior of the fractional
  27. # indentation is governed by <fractional_tab_policy>
  28. use_tabchars = False
  29. # If <use_tabchars> is True, then the value of this variable indicates how
  30. # fractional indentions are handled during whitespace replacement. If set to
  31. # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
  32. # to `round-up` fractional indentation is replaced with a single tab character
  33. # (utf-8 0x09) effectively shifting the column to the next tabstop
  34. fractional_tab_policy = 'use-space'
  35. # If an argument group contains more than this many sub-groups (parg or kwarg
  36. # groups) then force it to a vertical layout.
  37. max_subgroups_hwrap = 2
  38. # If a positional argument group contains more than this many arguments, then
  39. # force it to a vertical layout.
  40. max_pargs_hwrap = 6
  41. # If a cmdline positional group consumes more than this many lines without
  42. # nesting, then invalidate the layout (and nest)
  43. max_rows_cmdline = 2
  44. # If true, separate flow control names from their parentheses with a space
  45. separate_ctrl_name_with_space = False
  46. # If true, separate function names from parentheses with a space
  47. separate_fn_name_with_space = False
  48. # If a statement is wrapped to more than one line, than dangle the closing
  49. # parenthesis on its own line.
  50. dangle_parens = True
  51. # If the trailing parenthesis must be 'dangled' on its on line, then align it
  52. # to this reference: `prefix`: the start of the statement, `prefix-indent`:
  53. # the start of the statement, plus one indentation level, `child`: align to
  54. # the column of the arguments
  55. dangle_align = 'prefix'
  56. # If the statement spelling length (including space and parenthesis) is
  57. # smaller than this amount, then force reject nested layouts.
  58. min_prefix_chars = 4
  59. # If the statement spelling length (including space and parenthesis) is larger
  60. # than the tab width by more than this amount, then force reject un-nested
  61. # layouts.
  62. max_prefix_chars = 10
  63. # If a candidate layout is wrapped horizontally but it exceeds this many
  64. # lines, then reject the layout.
  65. max_lines_hwrap = 2
  66. # What style line endings to use in the output.
  67. line_ending = 'unix'
  68. # Format command names consistently as 'lower' or 'upper' case
  69. command_case = 'canonical'
  70. # Format keywords consistently as 'lower' or 'upper' case
  71. keyword_case = 'upper'
  72. # A list of command names which should always be wrapped
  73. always_wrap = []
  74. # If true, the argument lists which are known to be sortable will be sorted
  75. # lexicographicall
  76. enable_sort = True
  77. # If true, the parsers may infer whether or not an argument list is sortable
  78. # (without annotation).
  79. autosort = False
  80. # By default, if cmake-format cannot successfully fit everything into the
  81. # desired linewidth it will apply the last, most agressive attempt that it
  82. # made. If this flag is True, however, cmake-format will print error, exit
  83. # with non-zero status code, and write-out nothing
  84. require_valid_layout = False
  85. # A dictionary mapping layout nodes to a list of wrap decisions. See the
  86. # documentation for more information.
  87. layout_passes = {}
  88. # ------------------------------------------------
  89. # Options affecting comment reflow and formatting.
  90. # ------------------------------------------------
  91. with section("markup"): # type: ignore
  92. # What character to use for bulleted lists
  93. bullet_char = '*'
  94. # What character to use as punctuation after numerals in an enumerated list
  95. enum_char = '.'
  96. # If comment markup is enabled, don't reflow the first comment block in each
  97. # listfile. Use this to preserve formatting of your copyright/license
  98. # statements.
  99. first_comment_is_literal = False
  100. # If comment markup is enabled, don't reflow any comment block which matches
  101. # this (regex) pattern. Default is `None` (disabled).
  102. literal_comment_pattern = None
  103. # Regular expression to match preformat fences in comments default=
  104. # ``r'^\s*([`~]{3}[`~]*)(.*)$'``
  105. fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
  106. # Regular expression to match rulers in comments default=
  107. # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
  108. ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
  109. # If a comment line matches starts with this pattern then it is explicitly a
  110. # trailing comment for the preceeding argument. Default is '#<'
  111. explicit_trailing_pattern = '#<'
  112. # If a comment line starts with at least this many consecutive hash
  113. # characters, then don't lstrip() them off. This allows for lazy hash rulers
  114. # where the first hash char is not separated by space
  115. hashruler_min_length = 10
  116. # If true, then insert a space between the first hash char and remaining hash
  117. # chars in a hash ruler, and normalize its length to fill the column
  118. canonicalize_hashrulers = True
  119. # enable comment markup parsing and reflow
  120. enable_markup = False
  121. # ----------------------------
  122. # Options affecting the linter
  123. # ----------------------------
  124. with section("lint"): # type: ignore
  125. # a list of lint codes to disable
  126. disabled_codes = []
  127. # regular expression pattern describing valid function names
  128. function_pattern = '[0-9a-z_]+'
  129. # regular expression pattern describing valid macro names
  130. macro_pattern = '[0-9A-Z_]+'
  131. # regular expression pattern describing valid names for variables with global
  132. # (cache) scope
  133. global_var_pattern = '[A-Z][0-9A-Z_]+'
  134. # regular expression pattern describing valid names for variables with global
  135. # scope (but internal semantic)
  136. internal_var_pattern = '_[A-Z][0-9A-Z_]+'
  137. # regular expression pattern describing valid names for variables with local
  138. # scope
  139. local_var_pattern = '[a-z][a-z0-9_]+'
  140. # regular expression pattern describing valid names for privatedirectory
  141. # variables
  142. private_var_pattern = '_[0-9a-z_]+'
  143. # regular expression pattern describing valid names for public directory
  144. # variables
  145. public_var_pattern = '[A-Z][0-9A-Z_]+'
  146. # regular expression pattern describing valid names for function/macro
  147. # arguments and loop variables.
  148. argument_var_pattern = '[a-z][a-z0-9_]+'
  149. # regular expression pattern describing valid names for keywords used in
  150. # functions or macros
  151. keyword_pattern = '[A-Z][0-9A-Z_]+'
  152. # In the heuristic for C0201, how many conditionals to match within a loop in
  153. # before considering the loop a parser.
  154. max_conditionals_custom_parser = 2
  155. # Require at least this many newlines between statements
  156. min_statement_spacing = 1
  157. # Require no more than this many newlines between statements
  158. max_statement_spacing = 2
  159. max_returns = 6
  160. max_branches = 12
  161. max_arguments = 5
  162. max_localvars = 15
  163. max_statements = 50
  164. # -------------------------------
  165. # Options affecting file encoding
  166. # -------------------------------
  167. with section("encode"): # type: ignore
  168. # If true, emit the unicode byte-order mark (BOM) at the start of the file
  169. emit_byteorder_mark = False
  170. # Specify the encoding of the input file. Defaults to utf-8
  171. input_encoding = 'utf-8'
  172. # Specify the encoding of the output file. Defaults to utf-8. Note that cmake
  173. # only claims to support utf-8 so be careful when using anything else
  174. output_encoding = 'utf-8'
  175. # -------------------------------------
  176. # Miscellaneous configurations options.
  177. # -------------------------------------
  178. with section("misc"): # type: ignore
  179. # A dictionary containing any per-command configuration overrides. Currently
  180. # only `command_case` is supported.
  181. per_command = {}