This file is indexed.

/usr/share/doc/gnat-gps/html/Defining-project-attributes.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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
<!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 project attributes</title>

<meta name="description" content="Using the GNAT Programming Studio: Defining project attributes">
<meta name="keywords" content="Using the GNAT Programming Studio: Defining project attributes">
<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="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files" rel="up" title="Customizing through XML and Python files">
<link href="Adding-casing-exceptions.html#Adding-casing-exceptions" rel="next" title="Adding casing exceptions">
<link href="Defining-text-aliases.html#Defining-text-aliases" rel="previous" title="Defining text aliases">
<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-project-attributes"></a>
<div class="header">
<p>
Next: <a href="Adding-casing-exceptions.html#Adding-casing-exceptions" accesskey="n" rel="next">Adding casing exceptions</a>, Previous: <a href="Defining-text-aliases.html#Defining-text-aliases" accesskey="p" rel="previous">Defining text aliases</a>, Up: <a href="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files" accesskey="u" rel="up">Customizing through XML and Python files</a> &nbsp; [<a href="Index-table.html#Index-table" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Defining-project-attributes-1"></a>
<h4 class="subsection">16.5.15 Defining project attributes</h4>
<a name="index-project-attributes"></a>
<a name="index-_003cproject_005fattribute_003e"></a>

<p>The project files are required by GPS, and are used to store various
pieces of information related to the current set of source files. This
includes how to find the source files, how the files should be compiled,
or manipulated through various tools, &hellip;.
</p>
<p>However, the default set of attributes that are usable in a project file
is limited to the attributes needed by the tool packaged with GPS or GNAT.
</p>
<p>If you are delivering your own tools, you might want to store similar
information in the project files themselves, since these are a very
convenient place to associate some specific settings with a given set of
source files.
</p>
<p>GPS lets manipulate the contents of projects through XML customization
files and script commands. You can therefore add you own typed attributes
into the projects, so that they are saved automatically when the user
saves the project, and reloaded automatically the next time GPS is started.
</p>
<a name="Declaring-the-new-attributes"></a>
<h4 class="subsubsection">16.5.15.1 Declaring the new attributes</h4>

<p>New project attributes can be declared in two ways: either using the advanced
XML tags below, or using the <code>&lt;tool&gt;</code> tag (see <a href="Defining-tool-switches.html#Defining-tool-switches">Defining tool switches</a>).
</p>
<p>The customization files support the <code>&lt;project_attribute&gt;</code> tag,
which is used to declare all the new attributes that GPS should expect
in a project.  Attributes that have not been declared explictly will
not be accessible through the GPS scripting languagues, and will
generate warnings in the Messages window.
</p>
<p>Project attributes are typed: they can either have a single value, or
have a set of such values (a list). The values can in turn be a
free-form string, a file name, a directory name, or a value extracted
from a list of preset values.
</p>
<p>Attributes that have been declared in these customization files will
also be graphically editable through the project properties dialog, or
the project wizard. Therefore, you should specify when an attribute is
defined how it should be presented to the GPS user.
</p>
<p>The <code>&lt;project_attribute&gt;</code> tag accepts the following attributes:
</p>
<ul>
<li> <code>package</code> (a string, default value: &quot;&quot;)

<p>This is the package in the project file in which the attribute is
stored. Common practice suggests that one such package should be used
for each tool. These packages provide namespaces, so that attributes
with the same name, but for different tools, do not conflict with each
other.
</p>
</li><li> <code>name</code> (a string, mandatory)

<p>This is the name of the attribute. This should be a string with no
space, and that represents a valid Ada identifier (typically, it
should start with a letter and be followed by a set of letters, digits
or underscore characters). This is an internal name that is used when
saving the attribute in a project file.
</p>
</li><li> <code>editor_page</code> (a string, default value: &quot;General&quot;)

<p>This is the name of the page in the Project Properties editor dialog
in which the attribute is presented. If no such page already exists, a
new one will be created as needed. If the page already exists, the
attribute will be appended at its bottom.
</p>
</li><li> <code>editor_section</code> (a string, default value: &quot;&quot;)

<p>This is the name of the section, inside editor page, in which the
attribute is displayed. These sections are surrounded by frames, the
title of which is given by the <code>editor_section</code> attribute.
If this attribute is not specified, the attribute is put in an
untitled section.
</p>
</li><li> <code>label</code> (a string, default value: the name of the attribute)

<p>If this attribute is set to a value other than the empty string
<code>&quot;&quot;</code>, a textual label is displayed to the left of the attribute
in the graphical editor. This should be used to identify the
attribute. However, it can be left to the empty string if the
attribute is in a named section of its own, since the title of the
section might be a good enough indication.
</p>
</li><li> <code>description</code> (a string, default value: &quot;&quot;)

<p>This is the help message that describes the role of the attribute. It
is displayed in a tooltip if the user leaves the mouse on top of the
attribute for a while.
</p>
</li><li> <code>list</code> (a boolean, default value: &quot;false&quot;)

<p>If this is set to <code>&quot;true&quot;</code>, the project attribute will in fact
contains a list of values, as opposed to a single value. This is used
for instance for the list of source directories in standard projects.
</p>
</li><li> <code>ordered</code> (a boolean, default value: &quot;false&quot;)

<p>This is only relevant if the project attribute contains a list of
values. This indicates whether the order of the values is relevant.
In most cases, it will not matter. However, for instance, the order of
source directories matters, since this also indicates where the source
files will be searched, stopping at the first match.
</p>
</li><li> <code>omit_if_default</code> (a boolean, default value: &quot;true&quot;)

<p>This indicates whether the project attribute should be set explicitly
in the project if the user has left it to its default value. This can
be used to keep the project files a simple as possible, if all the
tools that will use this project attribute know about the default
value. If this isn&rsquo;t the case, set <code>omit_if_default</code> to &quot;false&quot;
to force the generation of the project attribute.
</p>
</li><li> <code>base_name_only</code> (a boolean, default value: &quot;false&quot;)

<p>If the attribute contains a file name or a directory name, this
indicates whether the full path should be stored, or only the base
name. In most cases, the full path should be used. However, since GPS
automatically looks for source files in the list of directories, for
instance, the list of source files should only contain base
names. This also increases the portability of project files.
</p>
</li><li> <code>case_sensitive_index</code> (a boolean, default value: &quot;false&quot;)

<p>This XML attribute is only relevant for project attributes that are
indexed on another one (see below for more information on indexed
attributes). It indicates whether two indexes that differ only by
their casing should be considered the same. For instance, if the index
is the name of one of the languages supported by GPS, the index is
case insensitive since &quot;Ada&quot; is the same as &quot;C&quot;. However, if the index
is the name of a file on Windows, the index is case-insensitive.
</p>
</li><li> <code>hide_in</code> (a string, default value: &quot;&quot;)

<p>This XML attribute defines the various context in which this attribute
should not be editable graphically. Currently, GPS provides three such
contexts (&quot;wizard&quot;, &quot;library_wizard&quot; and &quot;properties&quot;, corresponding to the
project creation wizards and the project properties editor). If any of those
context is specified in hide_in, then the widget to edit this
attribute will not be shown. The goal is to keep the graphical
interface simple.
</p>
</li><li> <code>disable_if_not_set</code> (a boolean, default value: &quot;false&quot;)

<p>If this attribute is set to &quot;true&quot;, the editor for this attribute will be
greyed out if the attribute is not explicitly set in the project. In most cases,
this is not needed, since the default value of the attribute can be used to leave
the editor active at all time. However, when the value of the attribute is
automatically computed depending on other attributes, the default value cannot be
easily specified in the XML file, and in this case it might be easier to grey out
the editor. An extra check box is displayed next to the attribute so that the user
can choose to activate the editor and add the attribute to the project.
</p>
</li><li> <code>disable</code> (a space-separated list of attribute names, default: &quot;&quot;)

<p>This is a list of attribute whose editor should be greyed out if the current
attribute is specified. This only works if both the current attribute and the
referenced attributes have their <code>disable_if_not_set</code> attribute set to &quot;true&quot;.
This can be used to have mutually exclusive attributes present in the editor
</p>
</li></ul>

<a name="Declaring-the-type-of-the-new-attributes"></a>
<h4 class="subsubsection">16.5.15.2 Declaring the type of the new attributes</h4>

<p>The type of the project attribute is specified through one or several
child tags of <code>&lt;project_attribute&gt;</code>. The following tags are
recognized.
</p>
<ul>
<li> <a name="index-_003cstring_003e"></a>
<code>&lt;string&gt;</code>

<p>This tag indicates that the attribute is made of one (or more if it is
a list) strings. This
tag accepts the following XML attributes:
</p>
<ul class="no-bullet">
<li>- <code>default</code> (a string, default value: &quot;&quot;)

<p>This gives the default value to be used for the string (and therefore
the project attribute), in case the user hasn&rsquo;t overridden it.
</p>
<p>If the attribute&rsquo;s type is a file or a directory, the default value will be
normalized (ie an absolute path will be generated from it, based on the
project&rsquo;s location, where <code>&quot;.&quot;</code> will represent the project&rsquo;s directory).
As a special case, if default is surrounded by parenthesis, no normalization
takes place, so that you can later on test whether the user is still using
the default value or not).
</p>
<p>A special case if when <code>default</code> is set to &quot;project source files&quot;. In this
case, this is automatically replaced by the known list of source files for the
project. This doesn&rsquo;t work from the project wizard, since the list of source files
hasn&rsquo;t been computed at that stage.
</p>
</li><li>- <code>type</code> (one of &quot;&quot;, &quot;file&quot;, &quot;directory&quot;, default &quot;&quot;)

<p>This indicates what the string represents. In the first case, any
value can be used. In the second case, it should represent a file
name, although no check is done to make sure the file actually exists
on the disk. But GPS will be able to do some special marshalling with
the file name. The third case indicates that GPS should expect a
directory.
</p>
</li><li>- <code>filter</code> (one of &quot;none&quot;, &quot;project&quot;, &quot;extending_project&quot;)

<p>This attribute is ignored for all types except <code>&quot;file&quot;</code>. In this case,
it further specifies what kind of files can be used in this attribute. If
the filter is <code>&quot;none&quot;</code>, then any file anywhere on the system is valid.
If the filter is <code>&quot;project&quot;</code>, then only files from the selected project
can be specified. If the filter is <code>&quot;extended_project&quot;</code>, then only the
files from the project extended by the current project can be specified. The
attribute will not be shown if the current project is not an extending project.
</p>
</li><li>- <code>allow_empty</code> (one of &quot;True&quot; or &quot;False, default &quot;True&quot;)

<p>This attribute indicates whether the value for this attribute can be an
empty string. If not, the user must specify a value or an error message will
be displayed in the project properties editor and project wizard.
</p>
</li></ul>

</li><li> <a name="index-_003cchoice_003e"></a>
<code>&lt;choice&gt;</code>

<p>This tag can be repeated several times. It indicates one of the valid
values for the attribute, and can be used to provide a static list of
such values. If it is combined with a <code>&lt;string&gt;</code> tag, this
indicates that the attribute can be any string, although a set of
possible values is provided to the user for ease of use.
This tag accepts one optional attribute, <code>&quot;default&quot;</code>, which is a
boolean. It indicates whether this value is the default to use for the
project attribute.
</p>
<p>If several <code>&lt;choice&gt;</code> tags are used, it is possible that several
of them are part of the default value if the project attribute is a
list, as opposed to a single value.
</p>
</li><li> <a name="index-_003cshell_003e-1"></a>
<code>&lt;shell&gt;</code>

<p>This tag is a GPS scripting command to execute to get a list of valid
values for the attribute. The command should return a list. As for the
<code>&lt;choice&gt;</code> tag, the <code>&lt;shell&gt;</code> tag can be combined with a
<code>&lt;string&gt;</code> tag to indicate that the list of values returned by
the scripting command is only a set of possible values, but that the
project attribute can in fact take any value.
</p>
<p>The <code>&lt;shell&gt;</code> tag accepts two attributes:
</p>
<ul class="no-bullet">
<li>- <code>lang</code> (a string, default value: &quot;shell&quot;)

<p>The scripting language in which the command is written. Currently, the
only other possible value is &quot;python&quot;.
</p>
</li><li>- <code>default</code> (a string, default value: &quot;&quot;)

<p>The default value that the project attribute takes if the user hasn&rsquo;t
overridden it.
</p></li></ul>

</li></ul>

<a name="index-indexed-project-attributes"></a>
<a name="index-project-attributes_002c-indexed"></a>
<a name="index-_003cindex_003e"></a>
<a name="index-_003cspecialized_005findex_003e"></a>

<p>In some cases, the type of the project attribute, or at least its
default value, depends on what the attribute applies to. The project
file support this in the form of indexed project attribute. This is
for instance used to specify what should be the name of the executable
generated when compiling each of the main files in the project (ie the
executable name for <code>gps.adb</code> should be <code>gps.exe</code>, the one
for <code>main.c</code> should be <code>myapp.exe</code>, and so on).
</p>
<p>Such attributes can also be declared through XML files. In such cases,
the <code>&lt;project_attribute&gt;</code> tag should have one <code>&lt;index&gt;</code>
child, and zero or more <code>&lt;specialized_index&gt;</code> children.
Each of these two tags in turn take one of the already mentioned
<code>&lt;string&gt;</code>, <code>&lt;choice&gt;</code> or <code>&lt;shell&gt;</code> tag.
</p>
<p>The <code>&lt;index&gt;</code> tag indicates what other project attribute is used
to index the current one. In the example given above for the
executable names, the index is the attribute that contains the list of
main files for the project.
</p>
<p>It accepts the following XML attributes:
</p>
<ul>
<li> <code>attribute</code> (a string, mandatory)

<p>The name of the other attribute. This other attribute must be declared
elsewhere in the customization files, and must be a list of values,
not a single value.
</p>
</li><li> <code>package</code> (a string, default value: &quot;&quot;)

<p>The package in which the index project attribute is defined. This is
used to uniquely identify homonym attributes.
</p></li></ul>

<p>The <code>&lt;specialized_index&gt;</code> is used to override the default type of
the attribute for specific values of the index. For instance, the
project files contains an attribute that specify what the name of the
compiler is for each language. It is indexed on the project attribute
that list the languages used for the source files of the project. Its
default value depends on the language (&quot;gnatmake&quot; for Ada, &quot;gcc&quot; for
C, and so on). This attribute accepts requires one XML attribute:
</p>
<ul>
<li> <code>value</code> (a string, mandatory)

<p>This is the value of the attribute for which the type is overriden.
</p></li></ul>

<p>Note that almost all the standard project attributes are defined
through an XML file, <samp>projects.xml</samp>, which is part of the GPS
installation. Check this file to get advanced examples on how to
declare project attributes.
</p>
<a name="Examples"></a>
<h4 class="subsubsection">16.5.15.3 Examples</h4>

<p>The following example declares three attributes, with a single string
as their value. This string represents a file or a directory in the
last two cases. You can simply copy this into a <samp>.xml</samp> file in
your <samp>$HOME/.gps/plug-ins</samp> directory, as usual.
</p>
<div class="smallexample">
<pre class="smallexample">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;custom&gt;
  &lt;project_attribute
      name=&quot;Single1&quot;
      package=&quot;Test&quot;
      editor_page=&quot;Tests single&quot;
      editor_section=&quot;Single&quot;
      description=&quot;Any string&quot;&gt;

     &lt;string default=&quot;Default value&quot; /&gt;
  &lt;/project_attribute&gt;

  &lt;project_attribute
      name=&quot;File1&quot;
      package=&quot;Test&quot;
      editor_page=&quot;Tests single&quot;
      editor_section=&quot;Single&quot;
      description=&quot;Any file&quot; &gt;

      &lt;string type=&quot;file&quot; default=&quot;/my/file&quot; /&gt;
  &lt;/project_attribute&gt;

  &lt;project_attribute
      name=&quot;Directory1&quot;
      package=&quot;Test&quot;
      editor_page=&quot;Tests single&quot;
      editor_section=&quot;Single&quot;
      description=&quot;Any directory&quot; &gt;

      &lt;string type=&quot;directory&quot; default=&quot;/my/directory/&quot; /&gt;
  &lt;/project_attribute&gt;
&lt;/custom&gt;
</pre></div>

<p>The following example declares an attribute whose value is a
string. However, a list of predefined possible values is also
provided, as an help for interactive edition for the user. If the
<code>&lt;string&gt;</code> tag wasn&rsquo;t given, the attribute&rsquo;s value would have two
be one of the three possible choices.
</p>
<div class="smallexample">
<pre class="smallexample">&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;custom&gt;
  &lt;project_attribute
      name=&quot;Static2&quot;
      package=&quot;Test&quot;
      editor_page=&quot;Tests single&quot;
      editor_section=&quot;Single&quot;
      description=&quot;Choice from static list (or any string)&quot; &gt;

      &lt;choice&gt;Choice1&lt;/choice&gt;
      &lt;choice default=&quot;true&quot; &gt;Choice2&lt;/choice&gt;
      &lt;choice&gt;Choice3&lt;/choice&gt;
      &lt;string /&gt;
  &lt;/project_attribute&gt;
&lt;/custom&gt;
</pre></div>

<p>The following example declares an attribute whose value is one of the
languages currently supported by GPS. Since this list of languages is
only know when GPS is executed, a script command is used to query this
list.
</p>
<div class="smallexample">
<pre class="smallexample">&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;custom&gt;
 &lt;project_attribute
      name=&quot;Dynamic1&quot;
      package=&quot;Test&quot;
      editor_page=&quot;Tests single&quot;
      editor_section=&quot;Single&quot;
      description=&quot;Choice from dynamic list&quot; &gt;

      &lt;shell default=&quot;C&quot; &gt;supported_languages&lt;/shell&gt;
  &lt;/project_attribute&gt;
&lt;/custom&gt;
</pre></div>

<p>The following example declares an attribute whose value is a set of
file names. The order of files in this list matters to the tools that
are using this project attribute.
</p>
<div class="smallexample">
<pre class="smallexample">&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;custom&gt;
 &lt;project_attribute
      name=&quot;File_List1&quot;
      package=&quot;Test&quot;
      editor_page=&quot;Tests list&quot;
      editor_section=&quot;Lists&quot;
      list=&quot;true&quot;
      ordered=&quot;true&quot;
      description=&quot;List of any file&quot; &gt;

      &lt;string type=&quot;file&quot; default=&quot;Default file&quot; /&gt;
  &lt;/project_attribute&gt;
&lt;/custom&gt;
</pre></div>

<p>The following example declares an attribute whose value is a set of
predefined possible values. By default, two such values are selected,
unless the user overrides this default setting.
</p>
<div class="smallexample">
<pre class="smallexample">&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;custom&gt;
  &lt;project_attribute
      name=&quot;Static_List1&quot;
      package=&quot;Test&quot;
      editor_page=&quot;Tests list&quot;
      editor_section=&quot;Lists&quot;
      list=&quot;true&quot;
      description=&quot;Any set of values from a static list&quot; &gt;

      &lt;choice&gt;Choice1&lt;/choice&gt;
      &lt;choice default=&quot;true&quot;&gt;Choice2&lt;/choice&gt;
      &lt;choice default=&quot;true&quot;&gt;Choice3&lt;/choice&gt;
  &lt;/project_attribute&gt;
&lt;/custom&gt;
</pre></div>

<p>The following example declares an attribute whose value is a
string. However, the value is specific to each language (this could
for instance be used for the name of the compiler to use for a given
language). This is an indexed project attribute. It has two default
values, one for Ada, one for C. All other languages have no default
value.
</p>
<div class="smallexample">
<pre class="smallexample">&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;custom&gt;
  &lt;project_attribute
      name=&quot;Compiler_Name&quot;
      package=&quot;Test&quot;
      editor_page=&quot;Tests indexed&quot;
      editor_section=&quot;Single&quot;
      &lt;index attribute=&quot;languages&quot; package=&quot;&quot;&gt;
         &lt;string default=&quot;&quot; /&gt;
      &lt;/index&gt;
      &lt;specialized_index value=&quot;Ada&quot; &gt;
         &lt;string default=&quot;gnatmake&quot; /&gt;
      &lt;/specialized_index&gt;
      &lt;specialized_index value=&quot;C&quot; &gt;
         &lt;string default=&quot;gcc&quot; /&gt;
      &lt;/specialized_index&gt;
  &lt;/project_attribute&gt;
&lt;/custom&gt;
</pre></div>

<a name="Accessing-the-project-attributes"></a>
<h4 class="subsubsection">16.5.15.4 Accessing the project attributes</h4>

<p>The new attributes that were defined are accessible from the GPS
scripting languages, like all the standard attributes, see <a href="Querying-project-switches.html#Querying-project-switches">Querying project switches</a>.
</p>
<p>You can for instance access the Compiler_Name attribute we created
above with a python command similar to:
</p>
<div class="smallexample">
<pre class="smallexample">GPS.Project.root().get_attribute_as_string (&quot;Compiler_Name&quot;, &quot;Test&quot;, &quot;Ada&quot;)
</pre></div>

<p>You can also access the list of main files for the project, for
instance, by calling
</p>
<div class="smallexample">
<pre class="smallexample">GPS.Project.root().get_attribute_as_list (&quot;main&quot;)
</pre></div>

<hr>
<div class="header">
<p>
Next: <a href="Adding-casing-exceptions.html#Adding-casing-exceptions" accesskey="n" rel="next">Adding casing exceptions</a>, Previous: <a href="Defining-text-aliases.html#Defining-text-aliases" accesskey="p" rel="previous">Defining text aliases</a>, Up: <a href="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files" accesskey="u" rel="up">Customizing through XML and Python files</a> &nbsp; [<a href="Index-table.html#Index-table" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>