7 The build system contains a text preprocessor similar to the C preprocessor,
8 meant for processing files which have no built-in preprocessor such as XUL
9 and JavaScript documents. It is implemented at ``python/mozbuild/mozbuild/preprocessor.py`` and
10 is typically invoked via :ref:`jar_manifests`.
12 While used to preprocess CSS files, the directives are changed to begin with
13 ``%`` instead of ``#`` to avoid conflict of the id selectors.
27 #define variable value
29 Defines a preprocessor variable.
31 Note that, unlike the C preprocessor, instances of this variable later in the
32 source are not automatically replaced (see #filter). If value is not supplied,
35 Note that whitespace is significant, so ``"#define foo one"`` and
36 ``"#define foo one "`` is different (in the second case, ``foo`` is defined to
37 be a four-character string).
46 Undefines a preprocessor variable.
58 #if variable == string
59 #if variable != string
61 Disables output if the conditional is false. This can be nested to arbitrary
62 depths. Note that in the equality checks, the variable must come first.
71 Reverses the state of the previous conditional block; for example, if the
72 last ``#if`` was true (output was enabled), an ``#else`` makes it off
73 (output gets disabled).
82 Ends the conditional block.
92 An ``#if`` conditional that is true only if the preprocessor variable
93 variable is defined (in the case of ``ifdef``) or not defined (``ifndef``).
95 elif / elifdef / elifndef
96 ^^^^^^^^^^^^^^^^^^^^^^^^^
102 #elif variable == string
103 #elif variable != string
107 A shorthand to mean an ``#else`` combined with the relevant conditional.
108 The following two blocks are equivalent::
136 The file specified by filename is processed as if the contents was placed
137 at this position. This also means that preprocessor conditionals can even
138 be started in one file and ended in another (but is highly discouraged).
139 There is no limit on depth of inclusion, or repeated inclusion of the same
140 file, or self inclusion; thus, care should be taken to avoid infinite loops.
147 #includesubst @variable@filename
149 Same as a ``#include`` except that all instances of variable in the included
150 file is also expanded as in ``#filter`` substitution
159 All variables wrapped in ``__`` are replaced with their value, for this line
160 only. If the variable is not defined, it expands to an empty string. For
161 example, if ``foo`` has the value ``bar``, and ``baz`` is not defined, then::
163 #expand This <__foo__> <__baz__> gets expanded
167 This <bar> <> gets expanded
174 #filter filter1 filter2 ... filterN
175 #unfilter filter1 filter2 ... filterN
177 ``#filter`` turns on the given filter.
179 Filters are run in alphabetical order on a per-line basis.
181 ``#unfilter`` turns off the given filter. Available filters are:
184 strips blank lines from the output
186 dumbComments: empties out any line that consists of optional whitespace
187 followed by a ``//``. Good for getting rid of comments that are on their
188 own lines, and being smarter with a simple regexp filter is impossible
190 all variables wrapped in @ are replaced with their value. If the
191 variable is not defined, it is a fatal error. Similar to ``#expand``
194 all variables wrapped in ``@`` are replaced with their value, or an
195 empty string if the variable is not defined. Similar to ``#expand``.
204 Output the string (i.e. the rest of the line) literally, with no other fixups.
205 This is useful to output lines starting with ``#``, or to temporarily
218 Cause a fatal error at this point, with the error message being the