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