Debian Codegraph @

Docs/src/defines.but

raw
1 \S0{compdefines} Conditional Compilation
2
3 The compiler maintains a list of defined symbols, which can be defined using !define or the /D command line switch. These defined symbols can be used for conditional compilation (using !ifdef) or for symbol replacement (a simple form of macros). To replace a symbol with its value, use $\{SYMBOL\} (if SYMBOL is not defined, no translation will occur). The translation is first-come-first-served, meaning if you do:
4
5 \c !define symbol_one ${symbol_two}
6
7 If symbol_two is defined when that line occurs, it will be replaced. Otherwise, any replacing will occur when $\{symbol_one\} is referenced.
8
9 Define/conditional compilation related commands:
10
11 \S1{define} !define
12
13 \c [/ifndef | /redef] ([/date|/utcdate] gflag [value]) | (/file gflag filename.txt) | (/intfmt gflag fmtstr value) | (/math gflag val1 OP val2)
14
15 This command will add \e{gflag} to the global define list. This will have a similar effect as using the /D switch on the command line (the define only becomes effective after the !define command).
16
17 If \e{/date} or \e{/utcdate} are used, \e{value} will be passed to strftime() and the result will be used as the value of \e{gflag}. strftime converts special symbols into certain parts of the current time or date. For example, %H will be converted into the current hour in 24-hour format. For a complete list of available symbols, search for strftime on \W{http://msdn.microsoft.com/}{MSDN}. On POSIX, you can get the list by using \c{man strftime}.
18
19 If \e{/file} is used, the entire text file specified (including whitespace and newlines) will be read and placed into \e{gflag}.
20
21 If \e{/intfmt} is used, \e{value} is interpreted as a integer and formatted using the same syntax as \R{intfmt}{IntFmt}.
22
23 If \e{/math} is used, the result of 'val1 OP val2', where OP may be +,-,*,/,%,<<,>>,>>>,&,|,^,~,!,&& or ||, will be used as the value of \e{gflag}. Note that val1 AND val2 MUST be integer values!
24
25 \c !define USE_SOMETHING
26 \c !define VERSION 1.2
27 \c !define /date NOW "%H:%M:%S %d %b, %Y"
28 \c !define /math RESULT 3 + 10
29 \c !define /math REST 15 % ${RESULT}
30 \c !define /file BunchaStuff somesourcefile.cpp
31 \c !define /redef USE_SOMETHING ${RESULT} ;redefine USE_SOMETHING
32 \c !define /intfmt HEX "0x%X" 3133078222
33
34 \S1{undef} !undef
35
36 \c [/noerrors] gflag [...]
37
38 Removes an item from the global define list. Note that $\{SYMBOL\} where SYMBOL is undefined will be translated to "$\{SYMBOL\}".
39
40 \c !define SOMETHING
41 \c !undef SOMETHING
42
43 \S1{ifdef} !ifdef
44
45 \c gflag [bcheck gflag [...]]
46
47 This command, when paired with an !endif command, will tell the compiler whether or not to compile the lines in between the two lines. If gflag is globally defined (using !define or the /D switch), then the contained lines will be compiled. Otherwise, they will be skipped. 'bcheck' can be specified as & (boolean and) or | (boolean or) along with more gflags -- precedence is simple, left to right.
48
49 \c !define SOMETHING
50 \c !ifdef SOMETHING
51 \c !echo "SOMETHING is defined"
52 \c !endif
53 \c !undef SOMETHING
54 \c !ifdef SOMETHING
55 \c !echo "SOMETHING is defined" # will never be printed
56 \c !endif
57
58 \S1{ifndef} !ifndef
59
60 \c gflag [bcheck gflag [...]]]
61
62 The opposite of !ifdef. The lines will be compiled when the gflag has not been defined.
63
64 \S1{if} !if
65
66 \c [!] value [op value2]
67 \c [!] /FileExists "c:\path\file.exe"
68
69 This command, when paired with an !endif command, will tell the compiler whether or not to compile the lines in between the two lines. If value is non-zero, or the comparison of value and value2 depending on the operator results in true, the contained lines will be compiled. Otherwise, they will be skipped.
70 op can be either == or != (case-insensitive string comparison), S== or S!= (case-sensitive string comparison), =, <>, <=, <, > or >= (int/hex/float comparison), & (bitwise AND comparison), && or || (boolean comparison).
71 If [!] is set, the result will be flipped from true to false and vice versa.
72
73 \c !if 1 < 0x2
74 \c !echo "1 is smaller than 2!!"
75 \c !else if ! 3.1 > 1.99
76 \c !error "this line should never appear"
77 \c !else
78 \c !error "neither should this"
79 \c !endif
80
81 \c !if /FileExists ".\cert.pfx"
82 \c !finalize '".\sign.bat" "%1"'
83 \c !endif
84
85 \S1{ifmacrodef} !ifmacrodef
86
87 \c gflag [bcheck gflag [...]]]
88
89 This command, when paired with an !endif command, will tell the compiler whether or not to compile the lines in between the two lines. If the macro gflag exists, then the contained lines will be compiled. Otherwise, they will be skipped. 'bcheck' can be specified as & (boolean and) or | (boolean or) along with more gflags -- precedence is simple, left to right.
90
91 \c !macro SomeMacro
92 \c !macroend
93 \c !ifmacrodef SomeMacro
94 \c !echo "SomeMacro is defined"
95 \c !endif
96
97 \S1{ifmacrondef} !ifmacrondef
98
99 \c gflag [bcheck gflag [...]]]
100
101 The opposite of !ifmacrodef. The lines will be compiled when the macro gflag does not exist.
102
103 \S1{else} !else
104
105 \c [if|ifdef|ifndef|ifmacrodef|ifmacrondef [...]]
106
107 This command allows to easily insert different code when different defines or macros are set. You can create blocks like !ifdef/!else/!endif, !ifdef/!else ifdef/!else/!endif etc.
108
109 \c !ifdef VERSION
110 \c OutFile installer-${VERSION}.exe
111 \c !else
112 \c OutFile installer.exe
113 \c !endif
114
115 \S1{endif} !endif
116
117 This command closes a block started with !if, !ifdef, !ifndef, !ifmacrodef or !ifmacrondef.
118
119 \S1{insertmacro} !insertmacro
120
121 \c macro_name [parameter] [...]
122
123 Inserts the contents of a macro that was created with !macro. If the macro was created with parameters, then you must pass as many parameters to the macro as it requires.
124
125 \c !macro Print text
126 \c DetailPrint "${text}"
127 \c !macroend
128 \c !insertmacro Print "some text"
129 \c !insertmacro Print "some more text"
130
131 \S1{macro} !macro
132
133 \c macro_name [parameter][...]
134
135 Creates a macro named 'macro_name'. All lines between the !macro and the !macroend will be saved. To insert the macro later on, use !insertmacro. !macro definitions can have one or more parameters defined. The parameters may be accessed the same way a !define would (e.g. $\{PARMNAME\}) from inside the macro.
136
137 \c !macro SomeMacro parm1 parm2 parm3
138 \c DetailPrint "${parm1}"
139 \c MessageBox MB_OK "${parm2}"
140 \c File "${parm3}"
141 \c !macroend
142
143 \S1{macroend} !macroend
144
145 Ends a macro that was started with !macro.
146
147 \S1{macroundef} !macroundef
148
149 \c macro_name
150
151 Deletes a macro.
152
153 \S1{searchparse} !searchparse
154
155 \c [/ignorecase] [/noerrors] [/file] source_string_or_file substring_start OUTPUTSYMBOL1 [substring [OUTPUTSYMBOL2 [substring ...]]]
156
157 Parses \e{source_string_or_file} (which is treated as a string, or as a filename if \e{/file} is set), looking for \e{substring_start}. If \e{substring_start} is found, then \e{OUTPUTSYMBOL1} is defined to the rest of the string (minus any other \e{substring} that may be found). Any number of \e{OUTPUTSYMBOLx} may be specified, and the final \e{substring} is optional.
158
159 If \e{/noerrors} is specified, matching less than the full number of strings is allowed (all \e{OUTPUTSYMBOLx} after the not-found substring will be ignored).
160
161 If \e{/file} is specified, the file is treated as a series of lines. The file is searched until all substrings are matched. If \e{/noerrors} is specified and not all strings are matched, the first line with the most symbols matched is used.
162
163 \c # search filename.cpp for a line '#define APP_VERSION "2.5"' and set ${VER_MAJOR} to 2, ${VER_MINOR} to 5.
164 \c !searchparse /file filename.cpp `#define APP_VERSION "` VER_MAJOR `.` VER_MINOR `"`
165
166 \S1{searchreplace} !searchreplace
167
168 \c [/ignorecase] symbol_out source_string searchfor replacewith
169
170 Searches \e{source_string}, looking for \e{searchfor} and replacing all instances of it with \e{replacewith}. Unlike !define, !searchreplace allows you to redefine \e{symbol_out} without warning or error.
171
172 \c # defines ${blah} to "i like ponies"
173 \c !searchreplace blah "i love ponies" "love" "like"
174
175