/usr/share/doc/gnat-gps/html/Defining-tool-switches.html is in gnat-gps-doc 5.0-16.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 2002-2010 AdaCore.
This document is free; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This document is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see http://www.gnu.org/licenses/.
A copy of the license is included in the section entitled
"GNU General Public License". -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Using the GNAT Programming Studio: Defining tool switches</title>
<meta name="description" content="Using the GNAT Programming Studio: Defining tool switches">
<meta name="keywords" content="Using the GNAT Programming Studio: Defining tool switches">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index-table.html#Index-table" rel="index" title="Index table">
<link href="Adding-support-for-new-tools.html#Adding-support-for-new-tools" rel="up" title="Adding support for new tools">
<link href="Executing-external-tools.html#Executing-external-tools" rel="next" title="Executing external tools">
<link href="Defining-default-command-line.html#Defining-default-command-line" rel="previous" title="Defining default command line">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
pre.smallexample {background-color:rgb(240,240,240);
font-family: courier new,courier,fixed;
font-size: 14px;
margin: 0px 40px 0px 40px;
border-width: 1px 2px 2px 1px;
border-top-style: dotted;
border-left-style: dotted;
border-right-style: solid;
border-bottom-style: solid;
border-color: black;}
code {color:black;
font-family: courier new,courier,fixed;
font-size: 14px;}
body {font-family: arial,helvetica,sans-serif;
font-size: 16px;
max-width: 800px;
text-align: justify}
samp {font-family: courier new,courier,fixed;
font-size: 14px}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Defining-tool-switches"></a>
<div class="header">
<p>
Next: <a href="Executing-external-tools.html#Executing-external-tools" accesskey="n" rel="next">Executing external tools</a>, Previous: <a href="Defining-default-command-line.html#Defining-default-command-line" accesskey="p" rel="previous">Defining default command line</a>, Up: <a href="Adding-support-for-new-tools.html#Adding-support-for-new-tools" accesskey="u" rel="up">Adding support for new tools</a> [<a href="Index-table.html#Index-table" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Defining-tool-switches-1"></a>
<h4 class="subsection">16.6.3 Defining tool switches</h4>
<a name="index-_003cswitches_003e"></a>
<p>The user has to be able to specify which switches to use with the tool.
If the tool is simply called through custom menus, you might
want to hard code some or all of the switches. However, in the general case
it is better to use the project properties editor, so that project-specific
switches can be specified.
</p>
<p>This is what GPS does by default for Ada, C and C++. You can find in the GPS
installation directory how the switches for these languages are defined in an
XML file. These provide extended examples of the use of customization files.
</p>
<p>The switches editor in the project properties editor provides a powerful
interface to the command line, where the user can edit the command line both as
text and through GUI widgets.
</p>
<p>The switches are declared through the <code><switches></code> tag in the
customization file, which must be a child of a <code><tool></code> tag as described
above.
</p>
<p>This <code><switches></code> tag accepts the following attributes:
</p>
<dl compact="compact">
<dt><code>lines (default value is 1)</code></dt>
<dd><p>The switches in the project properties editor are organized into boxes,
each surrounded by a frame, optionally with a title. This attribute specifies
the number of rows of such frames.
</p>
</dd>
<dt><code>columns (default value is 1)</code></dt>
<dd><p>This attribute specifies the number of columns of frames in the project
properties page.
</p>
</dd>
<dt><code>separator (default value is "")</code></dt>
<dd><p>This attribute specifies the default character that should go between a switch
and its value, to distinguishes cases like "-a 1", "-a1" and "-a=1". This can
be overridden separately for each switch. Note that if you want the separator
to be a space, you must use the value <code>"&#32;"</code> rather than <code>" "</code>,
since XML parser must normalize the latter to the empty string when reading
the XML file.
</p>
</dd>
<dt><code>use_scrolled_window (Default value is false)</code></dt>
<dd><p>This optional attribute specifies if the boxes of the project editor are placed
into scrolled window. This is particularily useful if the number of displayed
switches if important.
</p>
</dd>
<dt><code>show_command_line (Default value is true)</code></dt>
<dd><p>If this attribute is set to "false", the command line will not be displayed
in the project properties editor. This can be used for instance if you only
want users to edit it through the buttons and other widgets, and not directly.
</p>
</dd>
<dt><code>switch_char (Default value is "-")</code></dt>
<dd><p>This is the leading character of command line arguments that indicate they
are considered as switches. Arguments not starting with this character will
be kept as is, and cannot have graphical widgets associated with them
</p>
</dd>
<dt><code>sections (Default value is empty)</code></dt>
<dd><p>This is a space separated list of switches delimiting a section (such as
"-bargs -cargs -largs"). A section of switches is a set of switches that
need to be grouped together and preceded by a specific switch. Sections are
always placed at the end of the command line, after regular switches.
</p>
</dd>
</dl>
<p>This <code><switches></code> tag can have any number of child tag, among the
following. They can be repeated multiple times if you need several check boxes.
For consistency, most of these child tags accept attributes among the
following:
</p>
<dl compact="compact">
<dt><code>line (default value is 1)</code></dt>
<dd><p>This indicates the row of the frame that should contain the switch. See the
description of <code>lines</code> above.
</p>
</dd>
<dt><code>column (default value is 1)</code></dt>
<dd><p>This indicates the column of the frame that should contain the switch. See the
description of <code>columns</code> above.
</p>
</dd>
<dt><code>label (mandatory)</code></dt>
<dd><p>This is the label which is displayed in the graphical interface
</p>
</dd>
<dt><code>switch (mandatory)</code></dt>
<dd><p>This is the text that should be put on the command line if that switch is
selected. Depending on its type, a variant of the text might be put instead,
see the description of <code>combo</code> and <code>spin</code> below.
This switch shouldn’t contain any space.
</p>
</dd>
<dt><code>switch-off (default value is empty)</code></dt>
<dd><p>This attribute is used for <code><check></code> tags, and indicates the switch
used for deactivating the concerned feature. This is useful for features that
are on by default on certain occasions, but can be individually deactivated.
</p>
</dd>
<dt><code>section (default value is empty)</code></dt>
<dd><p>This is the switch section delimiter (such as "-cargs"). See the ’sections’
attribute of the tag ’switches’ for more information.
</p>
</dd>
<dt><code>tip (default value is empty)</code></dt>
<dd><p>This is the tooltip which describes that switch more extensively. It is
displayed in a small popup window if the user leaves the mouse on top of
the widget. Note that tags accepting the tip attribute also accept a single
child <code><tip></code> whose value will contain the text to be displayed. The
advantage of the latter is that the text formatting is then kept.
</p>
</dd>
<dt><code>before (default value is "false")</code></dt>
<dd><p>This attribute is used to indicate that a switch needs to be always inserted
at the begining of the command line.
</p>
</dd>
<dt><code>min (default value is 1)</code></dt>
<dd><p>This attribute is used for <code><spin></code> tags, and indicates the minimum
value authorized for that switch.
</p>
</dd>
<dt><code>max (default value is 1)</code></dt>
<dd><p>This attribute is used for <code><spin></code> tags, and indicates the maximum
value authorized for that switch.
</p>
</dd>
<dt><code>default (default value is 1)</code></dt>
<dd><p>This attribute is used for <code><check></code> and <code><spin></code> tags. See the
description below.
</p>
</dd>
<dt><code>noswitch (default is empty)</code></dt>
<dd><p>This attribute is only valid for <code><combo></code> tags, and described below.
</p>
</dd>
<dt><code>nodigit (default is empty)</code></dt>
<dd><p>This attribute is only valid for <code><combo></code> tags, and described below.
</p>
</dd>
<dt><code>value (mandatory)</code></dt>
<dd><p>This attribute is only valid for <code><combo-entry></code> tags.
</p>
</dd>
<dt><code>separator (default is the value given to <code><switches></code></code></dt>
<dd><p>This attribute specifies the separator to use between the switch and its value.
See the description of this attribute for <code><switches></code>.
</p>
</dd>
</dl>
<p>Here are the valid children for <code><switches></code>:
</p>
<dl compact="compact">
<dt><code><title></code></dt>
<dd><a name="index-_003ctitle_003e-1"></a>
<p>This tag, which accepts the <code>line</code> and <code>column</code> attributes, is used
to give a name to a specific frame.
The value of the tag is the title itself. You do not have to specify
a name, and this can be left to an empty value.
</p>
<p>Extra attributes for <code><title></code> are:
</p>
<dl compact="compact">
<dt><code>line-span (default value is 1)</code></dt>
<dd><p>This indicates how many rows the frame should span. If this is set to 0, then
the frame is hidden from the user. See for instance the Ada or C switches
editor.
</p>
</dd>
<dt><code>column-span (default value is 1)</code></dt>
<dd><p>This indicates how many columns the frame should span. If this is set to 0,
then the frame is hidden from the user. See for instance the Ada or C
switches editor.
</p></dd>
</dl>
</dd>
<dt><code><check></code></dt>
<dd><a name="index-_003ccheck_003e"></a>
<p>This tag accepts the <code>line</code>, <code>column</code>, <code>label</code>, <code>switch</code>,
<code>switch-off</code>, <code>section</code>, <code>default</code>, <code>before</code> and <code>tip</code>
attributes.
</p>
<p>This tag doesn’t have any value. An optional <code><tip></code> child can be present.
</p>
<p>It creates a toggle button. When the latter is active, the text defined in the
switch attribute is added as is to the command line. The switch can be also
activated by default (<code>default</code> attribute is "on" or "true"). In this
case, deactivating the switch will add <code>switch-off</code> to the command line.
</p>
</dd>
<dt><code><spin></code></dt>
<dd><a name="index-_003cspin_003e"></a>
<p>This tag accepts the <code>line</code>, <code>column</code>, <code>label</code>, <code>switch</code>,
<code>section</code>, <code>tip</code>, <code>min</code>, <code>max</code>, <code>separator</code> and
<code>default</code> attributes.
</p>
<p>This tag doesn’t have any value. An optional <code><tip></code> child can be present.
</p>
<p>This switch will add the contents of the <code>switch</code> attribute followed by
the current numeric value of the widget to the command line. This is typically
used to indicate indentation length for instance.
If the current value of the widget is equal to the <code>default</code> attribute,
then nothing is added to the command line.
</p>
</dd>
<dt><code><radio></code></dt>
<dd><a name="index-_003cradio_003e"></a>
<a name="index-_003cradio_002dentry_003e"></a>
<p>This tag accepts the <code>line</code> and <code>column</code> attributes. It groups any
number of children, each of which is associated with its own switch. However,
only one of the children can be selected at any given time.
</p>
<p>The children must have the tag <code>radio-entry</code>. This tag accepts the
attributes <code>label</code>, <code>switch</code>, <code>section</code>, <code>before</code> and
<code>tip</code>. As a special case, the switch attribute can have an empty value
("") to indicate this is the default switch to use in this group of radio
buttons.
</p>
<p>This tag doesn’t have any value. An optional <code><tip></code> child can also be
present.
</p>
</dd>
<dt><code><field></code></dt>
<dd><a name="index-_003cfield_003e"></a>
<p>This tag accepts the <code>line</code>, <code>column</code>, <code>label</code>, <code>switch</code>,
<code>section</code>, <code>separator</code>, <code>before</code> and <code>tip</code> attributes.
</p>
<p>This tag doesn’t have any value. An optional <code><tip></code> child can be present.
</p>
<p>This tag describes a text edition field, which can
contain any text the user types. This text will be prefixed by the value of
the <code>switch</code> attribute, and the separator (by default nothing). If no text
is entered in the field
by the user, nothing is put on the command line.
</p>
<p>This tag accepts two extra attributes:
</p>
<dl compact="compact">
<dt><code>as-directory (optional)</code></dt>
<dd><a name="index-as_002ddirectory"></a>
<p>If this attribute is specified and set to "true", then an extra "Browse"
button is displayed, so that the user can easily select a directory.
</p>
</dd>
<dt><code>as-file (optional)</code></dt>
<dd><a name="index-as_002dfile"></a>
<p>This attribute is similar to <code>as-directory</code>, but opens a dialog to
select a file instead of a directory. If both attributes are set to "true",
the user will select a file.
</p></dd>
</dl>
</dd>
<dt><code><combo></code></dt>
<dd><a name="index-_003ccombo_003e"></a>
<a name="index-_003ccombo_002dentry_003e"></a>
<p>This tag accepts the <code>line</code>, <code>column</code>, <code>label</code>, <code>switch</code>,
<code>section</code>, <code>before</code>, <code>tip</code>, <code>noswitch</code>, <code>separator</code>
and <code>nodigit</code> attributes.
</p>
<p>The tag <code><combo></code> accepts any number of <code>combo-entry</code> children tags,
each of which accepts the <code>label</code> and <code>value</code> attribute. An optional
<code><tip></code> child can also be present.
</p>
<p>The text inserted in the command line is the text from the <code>switch</code>
attribute, concatenated with the text of the <code>value</code> attribute for the
currently selected entry. If the value of the current entry is the same
as that of the <code>nodigit</code> attribute, then only the text of the
<code>switch</code> attribute is put on the command line. This is in fact necessary
to interpret the gcc switch "-O" as "-O1".
</p>
<p>If the value of the current entry is that of the <code>noswitch</code> attribute,
then nothing is put in the command line.
</p>
</dd>
<dt><code><popup></code></dt>
<dd><a name="index-_003cpopup_003e"></a>
<p>This tag accepts the <code>line</code>, <code>column</code>, <code>label</code>, <code>lines</code>
and <code>columns</code> attributes. This displays a simply button that, when
clicked, displays a dialog with some extra switches. This dialog, just as the
switches editor itself, is organizes into lines and columns of frames, the
number of which is provided by the <code>lines</code> and <code>columns</code> attributes.
</p>
<p>This tag accepts any number of children, which are the same as the
<code><switches></code> attribute itself.
</p>
</dd>
<dt><code><dependency></code></dt>
<dd><a name="index-_003cdependency_003e"></a>
<p>This tag is used to describe a relationship between two switches. It is used
for instance when the "Debug Information" switch is selected for "Make", which
forces it for the Ada compiler as well.
</p>
<p>It has its own set of attributes:
</p>
<dl compact="compact">
<dt><code>master-page master-switch master-section</code></dt>
<dd><p>These two attributes define the switch that possibly forces a specific
setting on the slave switch. In our example, they would have the values
"Make" and "-g".
The switch referenced by these attributes must be of type <code><check></code>
or <code><field></code>. If it is part of a section, then ’master-section’ needs
to be defined. If the check button is selected, it forces the
selection of the slave check button. Likewise, if the field is set to
any value, it forces the selection of the slave.
</p>
</dd>
<dt><code>slave-page slave-switch slave-section</code></dt>
<dd><p>These two attributes define the switch which is acted upon by the master
switch. In our example, they would have the values "Ada" and "-g".
The switch referenced by these attributes must be of type <code><check></code>.
</p>
</dd>
<dt><code>master-status slave-status</code></dt>
<dd><p>These two switches indicate which state of the master switch forces which
state of the slave-status. In our example, they would have the values
"on" and "on", so that when the make debug information is activated, the
compiler debug information is also activated. However, if the make debug
information is not activated, no specific setup is forced for the compiler
debug information.
if master-status is "off" and the master switch is a field, then the
status of the slave will be changed when no value is set in the field.
</p></dd>
</dl>
</dd>
<dt><code><default-value-dependency></code></dt>
<dd><a name="index-_003cdefault_002dvalue_002ddependency_003e"></a>
<p>This tag is used to describe a relationship between two switches. It is
slightly different from the <dependency> tag in that the relationship concerns
only the default activation states. It is used for instance when the "-gnatwa"
switch is selected for the "Ada" Compiler, which imply that the default values
for "-gnatwc", "-gnatwd", etc. become activated by default. They can however
still be deactivated with respectively "-gnatwC" and "-gnatwD".
</p>
<p>It has its own set of attributes:
</p><dl compact="compact">
<dt><code>master-switch</code></dt>
<dd><p>This is the switch that triggers the dependency. If <code>master-switch</code> is
present in the command line, then the switch’s default status of
<code>slave-switch</code> is modified accordingly.
</p>
</dd>
<dt><code>slave-switch</code></dt>
<dd><p>This is the switch whose default value depends on <code>master-switch</code>. This
needs to be a switch already defined in a <code><switch></code> tag. It can match
its ’switch’ or ’switch-off’ attributes. In the latter case, the
slave-switch default value is deactivated if master-switch is present.
</p></dd>
</dl>
</dd>
<dt><code><expansion></code></dt>
<dd><a name="index-_003cexpansion_003e"></a>
<a name="index-_003centry_003e-1"></a>
<p>This tag is used to describe how switches can be grouped together on the
command line to keep it shorter. It is also used to define aliases between
switches.
</p>
<p>It is easier to explain it through an example. Specifying the GNAT switch
"-gnatyy" is equivalent to specifying "-gnaty3abcefhiklmnprst". This is in
fact a style check switch, with a number of default values. But it is also
equivalent to decomposing it into several switches, as in "-gnatya",
"-gnatyb", …; With this information, GPS will try to keep the
command line length as short as possible, to keep it readable.
</p>
<p>Both these aspects are defined in a unique <code><expansion></code> tag, which
accepts two attributes: <code>switch</code> is mandatory, and <code>alias</code> is
optional. Alias contains the text "-gnatyabcefhiklmnprst" in our example.
</p>
<p>There are two possible uses for this tag:
</p><ul class="no-bullet">
<li>- If the "alias" attribute is not specified, then the "switch" attribute
indicates that all switches starting with that prefix should be grouped.
For instance, if you pass "-gnatw" as the value for the "switch" attribute,
then a command line with "-gnatwa -gnatw.b" will in fact result in "-gnatwa.b".
</li><li>- If the "alias" attribute is specified, then the "switch" attribute is
considered as a shorter way of writting "alias". For instance, if "switch"
is "-gnatyy" and "alias" is "-gnaty3abcefhiklmnprst", then the user can simply
type "-gnatyy" to mean the whole set of options.
</li></ul>
<p>The same "switch" attribute can be used in two expansion nodes if you want
to combine the behavior.
</p>
<p>For historical reasons, this tag accepts <code><entry></code> children, but these
are no longer used.
</p>
</dd>
</dl>
<hr>
<div class="header">
<p>
Next: <a href="Executing-external-tools.html#Executing-external-tools" accesskey="n" rel="next">Executing external tools</a>, Previous: <a href="Defining-default-command-line.html#Defining-default-command-line" accesskey="p" rel="previous">Defining default command line</a>, Up: <a href="Adding-support-for-new-tools.html#Adding-support-for-new-tools" accesskey="u" rel="up">Adding support for new tools</a> [<a href="Index-table.html#Index-table" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|