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 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
|
\input texinfo @c -*-texinfo-*-
@input texiplus
@c %**start of header
@setfilename tutorial.info
@settitle GNAT Programming Studio Tutorial
@syncodeindex fn cp
@dircategory GNU Ada tools
@direntry
* GPS Tutorial: (gps_tutorial). GNAT Programming Studio Tutorial
@end direntry
@set GPSVersion 4.3.0
@copying
Copyright @copyright{} 2002-2008, 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 3 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 @url{http://www.gnu.org/licenses/}.
@end copying
@titlepage
@title GNAT Programming Studio Tutorial
@subtitle Version @value{GPSVersion}
@subtitle Document revision level $Revision: 131088 $
@subtitle Date: $Date: 2008-10-20 14:21:00 +0200 (Mon, 20 Oct 2008) $
@author AdaCore
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@ifnotinfo
@contents
@end ifnotinfo
@ifinfo
@node Top, Introduction, (dir), (dir)
@top GNAT Programming Studio Tutorial
GNAT Programming Studio Tutorial
Version @value{GPSVersion}
Date: $Date: 2008-10-20 14:21:00 +0200 (Mon, 20 Oct 2008) $
Copyright @copyright{} 2002-2007, AdaCore.
@insertcopying
@menu
* Introduction::
* Quick overview of the GPS areas::
* Editing sources::
* Building applications::
* Source Navigation::
* Search Dialog::
* Project View (entities)::
* Back to Source Navigation::
* Code Completion::
* Run::
* Debug::
* Call Graph::
* Locations Tree::
* Projects::
* Epilogue::
@end menu
@end ifinfo
@c --------------------------------------------------------------------
@node Introduction
@chapter Introduction
@c --------------------------------------------------------------------
@noindent
This document provides a guide through the major capabilities
of the GNAT Programming Studio by working on a code example: sdc, a simple
desktop calculator.
It is important to realize that the features that you are about to
experiment with are available on multiple platforms, using the same user
interface and capabilities, providing a user-friendly environment
with a tight integration between the tools.
Start GPS in the directory containing the tutorial files, or if the directory
is read-only, copy the @file{tutorial} directory and its subdirectories in a
local (writable) area, and start GPS from the @file{tutorial} directory, so
that GPS will load the right context.
By default, the tutorial sources can be found under
@code{<prefix>/share/examples/gps/tutorial}, where @code{<prefix>} is the
prefix directory of the GPS installation.
Alternatively, if you have already started GPS in another directory, you
can load the project @code{sdc.gpr} by using the menu @code{Project->Open...}
@c --------------------------------------------------------------------
@node Quick overview of the GPS areas
@chapter Quick overview of the GPS areas
@c --------------------------------------------------------------------
@noindent
Having launched GPS, you should now have access to a main window composed of
several areas:
@itemize @bullet
@item a menu bar at the top
@item a tool bar under the menu bar
@item a scenario view under the tool bar, on the left side
@item a project view under the scenario view, on the left side
@item a working area on the right of the project view
@item a messages window under the working area
@end itemize
@c --------------------------------------------------------------------
@node Editing sources
@chapter Editing sources
@c --------------------------------------------------------------------
@noindent
In the project view, open the @code{common} directory by clicking
on the @code{[+]} sign (a triangle under unix systems) on the left of
@code{common}.
This will open the directory and display a list of source files located
in this directory.
Now, double click on @file{sdc.adb}: this will open a source editor on this
file. The source code is syntax-highlighted: keywords, comments, strings and
characters have different colors.
As with many other properties, colors are configurable in GPS:
Select the menu @code{Edit->Preferences}. This will open a preferences
dialog window.
Select the @code{Editor->Fonts & Colors} page by clicking on the cross next to
the item @code{Editor} and then selecting the @code{Fonts & Colors} item.
As you go over the various lines and labels, you will notice that by
holding the mouse over a label, a tool tip pops up displaying on-line help
about the selected item.
Change the background color of the @code{Keywords} by clicking on the last
button, at the right of the @code{Keywords} line.
Choose a color, e.g a light green. When you're done with the color
selection, click on @code{OK} in the color selection dialog.
Click on the @code{Apply} button and look at the effects in the source
editor. If you like the new display, click on @code{OK} to confirm the
changes, otherwise clicking on @code{Cancel} will revert to the previous
color.
@c --------------------------------------------------------------------
@node Building applications
@chapter Building applications
@c --------------------------------------------------------------------
@noindent
Select the icon @code{Build Main: sdc.adb} on the toolbar: this will launch
a complete build of the @i{sdc} application. Note also that you can use a
key binding directly instead of this tool bar button (@key{F4}), or use the
corresponding menu item @code{Build->Project->sdc.adb}. If you use the menu
item, an extra intermediate dialog is displayed showing the actual command
line that will be used by GPS. Pressing @key{Enter} will launch also the build.
The build has generated a number of errors in a new window: the @i{Locations}
tree, displayed in the bottom area. The errors are also highlighted in the
corresponding source editor.
GPS has automatically jumped to the first error message
(@i{sdc.adb, 28:6 : (style) bad indentation}),
at the line (28) and column (6) of the error.
Fix the error by hand by inserting a space.
Now you can fix the next error by moving the cursor to the line 30 (press
the @key{down} arrow twice), and by using @key{Ctrl-Tab} (press first the
@key{Control} key, and then the @key{Tab} key on your keyboard): this key
combination asks the source editor to automatically re-indent the current
line.
Note that on some window managers or desktop environments,
@key{Ctrl-Tab} is already defined. If this is the case, you can change this
shortcut from the key shortcuts dialog (menu @code{Edit->Key shortcuts},
@code{Source editor} section, @code{Format selection} item).
You can then fix all the remaining errors by selecting the whole block
(from line 28 to line 40) and pressing @key{Ctrl-Tab}. To select a block,
you can either click on the left mouse button and select the area while
holding the button, or using the keyboard by pressing the @key{Shift} key
and moving the cursor using the @key{Up} or @key{Down} keys.
Press the @key{F4} key to build again. GPS will automatically save the
modified files, and start a build. This behavior (automatic saving of files
before building) can be configured in the preferences dialog.
If you look at the bottom right of the GPS window, you will notice that a
progress bar has appeared, displaying the current number of files compiled,
and the number of remaining files. This progress bar disappears when the
build is finished.
This should now report a successful build.
@c --------------------------------------------------------------------
@node Source Navigation
@chapter Source Navigation
@c --------------------------------------------------------------------
@noindent
Now let's try to understand a little bit about how the program is working by
looking at the @file{sdc.adb} editor: there's a loop, the main processing is
done by the functions Process and Next (at line 30).
Click around line 30, move the mouse over @code{Process} and let a tool tip
appear (@code{Tokens.Process global procedure declared at tokens.ads:19}): this
gives information about the kind of entity and the location (file and line) of
the declaration of this procedure, the profile of the parameters, and
documentation for this function, as extracted from the comments surrounding
the procedure declaration.
Do the same for @code{Next} (@code{Tokens.Next global function declared at
tokens.ads:15}).
Keeping the mouse over @code{Next}, display the contextual menu by clicking on
the right mouse button,
then click on @code{Goto declaration of Next}: we're now in the package
@code{Tokens}, in file @file{tokens.ads}; but where is this file in the project?
@c --------------------------------------------------------------------
@node Search Dialog
@chapter Search Dialog
@c --------------------------------------------------------------------
@noindent
Select the menu @code{Navigate->Find or Replace...}: this will open a search
dialog.
In the @code{Search for:} text entry type @file{tokens.ads}. Then
select @code{Project view} in the @code{Look in:} area. The search
area provides an easy way to search for text or regular expressions in
several contexts including the current file, the project view, @dots{}
Now click on @code{Find}. The file @file{tokens.ads}, in directory @code{struct}
is highlighted.
Close the search dialog by clicking on the @code{Close} button.
Note that in this specific case, a simpler way to locate a file in the
project view is to use the contextual menu from the source editor:
@code{Locate in Project View: tokens.ads}.
@c --------------------------------------------------------------------
@node Project View (entities)
@chapter Project View (entities)
@c --------------------------------------------------------------------
@noindent
Click on the @code{[+]} sign (or triangle) to open @file{tokens.ads} entities.
When you click on a file in the project view, you get
language sensitive information about the file, such as
@code{packages}, @code{subprograms}, @code{tasks}, ... for @code{Ada}.
Open the @code{subprogram} category, click on @code{Process}: this
will open @file{tokens.ads} and move the cursor on the first line
corresponding to the procedure @code{Process}.
Similarly, click on @code{Next}, and move your mouse on @code{Next}
in the source editor.
@c --------------------------------------------------------------------
@node Back to Source Navigation
@chapter Back to Source Navigation
@c --------------------------------------------------------------------
@noindent
Using the contextual menu, select @code{Goto body of Next};
scroll through the procedure @code{Next}, move the mouse on
@code{Instructions.Read} at line 46 and from the contextual menu, select
@code{Goto body of Read}.
We've now navigated quite a bit through the application source code,
which you can verify by clicking on the left arrow in the tool bar, to go
back to the previous locations visited.
Repeat the operation until you're back in @file{sdc.adb}.
As with the undo/redo capability in the source editor, the
@code{goto previous/next location} is infinite.
@c --------------------------------------------------------------------
@node Code Completion
@chapter Code Completion
@c --------------------------------------------------------------------
@noindent
Go on the line 38 of sdc.adb. You can see that there is a null instruction for
the case of Stack.Overflow. We are going to add some code here, using the
code assist capabilities.
Type @key{enter} to create a new line, and then @code{Scr}, and hit
@key{Ctrl+Space}. If you've never used
auto-completion before, GPS will pop a window asking you if you want to enable
the auto-completion engine. Answer "yes". You will see at the bottom right of
GPS a progress bar, showing the status of the completion database load. Note
that you can still work during this operation. The auto completion mechanism
can be disabled from the preferences if needed.
Wait until the progress bar disappears, and then hit @key{Ctrl+Space} again.
A completion popup will be displayed, showing all the entities of the project
begining with @code{Scr}. Select @code{Screen_Output}. The code will be
automatically completed in the editor. Then add a dot in your code. The
completion popup will be automatically triggered, and will offer you to
complete your code with the entities contained in the @code{Screen_Output}
package. Select @code{Msg}, add a space, and then an open parenthesis. Once
again, the completion windows will pop up, and show you the possible parameters
for msg. If you choose the first entry of the completion list
("params of Msg"), the call will
be automatically completed by a list of named parameters. Complete the list by
giving e.g. @code{"The stack is full."} for @code{S1}, @code{""} for @code{S2},
and @code{True} for @code{End_Line}.
Don't forget to add a semicolon at the end of the instruction. Then hit @key{F4}
in order to rebuild the application.
@c --------------------------------------------------------------------
@node Run
@chapter Run
@c --------------------------------------------------------------------
@noindent
It is now time to run the application: select the menu
@code{Build->Run->sdc}, which will open a dialog window.
Type @code{input.txt} in the text entry: this is the name of a text
file that will be passed as argument to the @i{sdc} program.
Now click on @code{OK}: a new window titled @code{Run: sdc input.txt}
is created at the bottom of the main window where the sdc application
runs and displays an unexpected internal error: this is a good opportunity
to use the integrated debugger.
Close the execution window by clicking on the x icon on the top right
corner of this window.
@c --------------------------------------------------------------------
@node Debug
@chapter Debug
@c --------------------------------------------------------------------
@noindent
Open the preferences dialog (menu @code{Edit->Preferences}) and
click on the @code{Debugger} item on the left; set the button
@code{Break on exceptions} to @i{Enabled}: this will enable by default a special
breakpoint every time an exception is raised. Click on @code{OK} to confirm your
change.
Now select the menu @code{Debug->Initialize->sdc}: a new window is
created: this is the debugger console.
You can also look at the various debug menu item and tool bar buttons which are
now activated.
Use the menu @code{Debug->Data->Call Stack}: this opens a new window on the
right of the source editors. If you select the contextual menu in the call
stack, various pieces of information can be displayed or
removed in the call stack. From this contextual menu, add the
@code{Frame Number} info by clicking on it.
Now select the menu @code{Debug->Run...}. Notice that @code{input.txt} has
been filled automatically for you since the two menus @code{Build->Run...} and
@code{Debug->Run...} are synchronized. Click on @code{OK}: the debugger should
stop on an exception (@code{Constraint_Error} in the file @file{stack.adb}, at
line 49).
Go up in the call stack by clicking on the @code{tokens.process} line
(frame number 6 or 7, depending on your GNAT version).
If you move the mouse over the parameter @code{T} at line 64, a tool tip is
displayed showing the value of @code{T}. You have probably noticed that
tool tips, like menus, are contextual: depending on the current session and
on the entity selected, different information is displayed.
Select the contextual menu @code{Debug->Display T}: this will open a new
window: the data window, with a box displaying graphically the contents
of the different fields of @code{T}, each clearly separated.
On @code{T} data display, select the contextual menu
@code{Display->Show Value + Type}: this displays for all fields both their
type and value.
Special colors are used in the data display: blue for pointers that can be
dereferenced by a double-click (double click on @code{T.val}); red for fields
that have been modified since last step.
In the contextual menu that pops up when you right-click on @code{T},
select @code{Debug->View memory at address of T}: a memory view is opened.
Use the @code{up} and @code{down} arrows on the right to visit memory.
Click in the memory dump, and modify it by typing numbers. Notice the
red color for modified values;
click on @code{Undo Changes} to cancel the modifications;
click on @code{Close} to close the memory window.
In the call stack, go back to @code{stack.push} frame (num 4 or 5).
Move the mouse over @code{Last} and let the debugger display its value: 0.
From the contextual menu, select @code{Goto declaration of Last}: this
will jump to the line 16 of @file{stack.adb}, where you can see that
@code{Last} is a @code{Natural}. Now click on the @code{Goto Previous Location}
button in the tool bar: we're now back at line 49 where we can see that for a
@code{Push} procedure, @code{Last} should be incremented, and not decremented.
Fix the line to @code{Last := Last + 1;}
Save the file (@key{Ctrl-S});
End the debug session: menu @code{Debug->Terminate};
Rebuild (press @key{F4} key);
Rerun (menu @code{Build->Run->sdc}): the program now completes as expected.
Close the execution window.
@c --------------------------------------------------------------------
@node Call Graph
@chapter Call Graph
@c --------------------------------------------------------------------
@noindent
Now go back to the file @file{sdc.adb}, move the mouse over the procedure
@i{sdc} at line 8, select the contextual menu
@code{Browsers->Sdc calls}: this will open a new window titled
@i{Call graph browser}.
Note that there is also a top level contextual menu (@code{Sdc calls})
which provides a tree view of the callers/callees.
In the call graph, click on the right arrow of @code{Process} (one of the
first items on the top). Also click on the right arrow of @code{error_msg}.
Select @code{Orthogonal links} in the contextual menu of the graph to change the
way links are displayed in the graph.
You may then play with the zoom (@key{=} and @key{-} keys).
If you select @code{Hide links} from @code{error_msg} contextual menu, this
will hide all the links that are related to this item: the link between the
callers and callees of @code{error_msg} are no longer displayed. This can
be useful when the graph becomes complex, to hide some parts. If you go back to
the contextual menu, you can now select @code{Show links} to show the links
again.
Click on right arrow of @code{process} (@code{(Decl) instructions.ads:12}).
The items can also be moved: move e.g @code{msg} item around.
You can also recompute the layout of all the current items by using
the contextual menu @code{Refresh layout}.
Click on left arrow of @code{msg}
to display who is calling @code{msg}. Notice that @code{view} calls @code{msg}.
Click on left arrow of @code{view}: the arrow disappears, and no
new items are created, which means that @code{view} isn't called by anyone,
so we're now going to remove this procedure.
@c --------------------------------------------------------------------
@node Locations Tree
@chapter Locations Tree
@c --------------------------------------------------------------------
@noindent
From @i{view}, click on the blue link: @code{stack.ads:32}, this will open
the file @file{stack.ads} at line 32.
Then from the source editor (file @file{stack.ads}), select the contextual
menu @code{References->Find all references to View}: this highlights the
@code{Locations} tree which now contains all the references for @code{view},
grouped by files (@file{stack.ads} and @file{stack.adb}).
The first location is highlighted automatically: this is the spec of the
procedure @code{View}. Now click in the tree on the @code{+} sign (or
triangle) at the left
of @file{stack.adb}: two locations are listed, at line 90 and 97.
Click on each of these locations: they correspond to the procedure body.
The @code{Find all references} capability is another way to list all the uses of
an entity, and it confirms that @code{View} isn't called in our project.
Remove @i{View} body by e.g selecting it, and pressing the @key{Delete} key,
then save the file (@key{Ctrl-S}).
Do the same for the spec, save the file.
Close the @file{stack.ads} and @file{stack.adb} files (menu File->Close,
or using the shortcut @key{Ctrl-W}), as well as the call graph window.
Rebuild by pressing the @key{F4} key.
@c "Let's now have a look at all the changes we've done so far, by looking at
@c the version control system explorer, aka VCS explorer"
@c --------------------------------------------------------------------
@c @node Version Control
@c @chapter Version Control
@c --------------------------------------------------------------------
@c @noindent
@c From the project view, contextual menu on project @i{sdc}, select
@c @code{Version Control->Query status for project}. The VCS Explorer is
@c opened, listing the files in the project.
@c => Explain the use of icons for status, log files, ...
@c => The list can be sorted by status or by file name, by clicking
@c on the @code{Status} and @code{File name} labels.
@c Move the mouse over @file{stack.ads}, select the contextual menu
@c @code{Compare against head rev.}:
@c this will open a visual comparison between the version in the repository,
@c and the local (modified) file; You can see that scrolling is synchronized
@c between the two files, and that colors are used to show lines
@c added, removed and modified.
@c Close the Visual Comparison window
@c Go back to the VCS Explorer
@c On @file{stack.ads}, contextual menu, @code{Edit changelog}
@c In the change log, type a log, e.g: @code{(View): Removed, since unused}
@c Save and close the log editor.
@c This log file will now associated with @file{stack.ads} until the
@c next check in.
@c Go back to the VCS Explorer, @file{stack.ads} has now an icon
@c showing that a log is associated with this file.
@c On @file{stack.ads}, commit the file using the contextual menu,
@c entry @code{Commit}.
Let's now see how to create a project corresponding to the @i{sdc}
project we've used in this tutorial.
@c --------------------------------------------------------------------
@node Projects
@chapter Projects
@c --------------------------------------------------------------------
@menu
* Project Wizard::
* Project properties::
* Variable editor::
* Switch editor::
* Source dependencies::
* Project dependencies::
@end menu
@node Project Wizard
@section Project Wizard
@noindent
Go to the menu @code{Project->New...}: this is a standard wizard, with various
steps listed on the left area of the window.
The first page of the wizard allows you to select what kind of project you
want to build, depending on the information you have. Select the default
choice @code{Single Project}, and press @code{Forward}.
Type @i{sdc2} in the project name field.
Click on @code{Forward}: we are now on the language selection page.
It is possible to create a multi-language project by e.g. selecting the C or C++
check box.
Click on @code{Forward}: we are now on the @code{VCS page}. @i{VCS} stands
for @i{Version Control System}.
GPS provides a generic framework for @i{VCS} which allows it to support
new systems easily. Systems supported by default are CVS, ClearCase and
Subversion. Select @code{CVS}.
Click on @code{Forward}: this is the source directories selection,
used to specify the project's sources. Click on the @code{Add} button,
and select the @code{struct} directory, then click on @code{OK} to validate.
Click on @code{Forward}: this is the @code{Build} and @code{Exec} directory
selection, used to store object, ali files, ...
Click on the first @code{Browse} button, then click on
@code{obj}, and finally click on @code{OK}.
Click on @code{Forward}: this is the main units selection, used mainly for
building executables and debugging.
Click on @code{Add}, open the @code{common} directory and select
@code{sdc.adb}.
Click on @code{Forward}: this is the naming scheme editor.
GNAT is very flexible and can use any kind of naming scheme for Ada files.
In particular, you can easily set the default file
extensions (e.g by using one of the predefined schemes) and you
can also specify exceptions that use non standard file names.
Click on @code{Forward}: we're now in the switch selector.
Select @code{Recompile if switches changed}.
Click on @code{Ada} page.
Select @code{Full errors} and @code{Overflow checking}.
The boxes and the command line (the text entry at the
bottom of the page) are fully synchronized, e.g if you click on the
command line, and change @code{-gnatf} to @code{-gnat}, the
@code{Full errors} check box is unselected; now type @code{a} to get
@code{-gnata}, and notice that @code{Enable assertions} is now selected.
We've now created a project similar to the one used in this tutorial.
Click on @code{Cancel} to close the wizard.
Clicking on @code{Apply} instead would have created the project file
and loaded it in GPS.
@node Project properties
@section Project properties
@noindent
In the project view, on the project @i{sdc}, use the contextual menu
@code{Project->Properties}.
All the properties set in the project wizard can be found here as well.
You can switch between pages by clicking on the tabs located along the
left side of the window.
Once you're done exploring the property pages, click on the @code{Cancel}
button to close the properties window.
@node Variable editor
@section Variable editor
@noindent
Select the window titled "Scenario View". If not available, you can open it
using the menu @code{Tools->Views->Scenario}.
This window contains a @code{Build} label.
This is a configuration variable. With GPS and the GNAT
project facility, you can define as many configuration variables as you want,
and modify any project settings (e.g. switches, sources, ...) based on the
values of configuration variables. These variables can also take any
number of different values.
The @code{Build} variable demonstrates a typical @code{Debug/Production}
configuration where we've set different switches for the two modes.
Click on the button at the left (@code{Edit variable properties}): this
is the variable editor, where values can be added or renamed.
Close the variable editor by clicking on the @code{Cancel} button.
Now, let's take a look at the switches set in the project.
@node Switch editor
@section Switch editor
@noindent
Select the menu item @code{Project->Edit File Switches}: a global
switch editor is displayed in the working area, showing the
switches associated with each file in the @code{sdc} project.
The editor lists the switches associated with each file in the project.
Gray entries indicate default (global) switches. Notice that
@file{screen_output.adb} has specific switches, which are highlighted
using a different font.
Switch between @code{Debug} and @code{Production} mode in the @code{Build}
combo box: the switches are updated automatically.
Back to our project, let's now examine the dependencies between sources.
@node Source dependencies
@section Source dependencies
@noindent
Select @file{sdc.adb} in the @code{Project View} and then the contextual menu
item @code{Show dependencies for sdc.adb}: this will open a new graph showing
the dependencies between sources of the project.
Click on the right arrow of @file{tokens.ads} to display the files that
@file{tokens.ads} depends on. Similarly, click on the right arrow of
@file{stack.ads}.
@node Project dependencies
@section Project dependencies
@noindent
Back in the project view, on the @i{Sdc} project, select the contextual
menu @code{Project->Dependencies}, then on the @code{Add From File},
then open the @i{tutorial}
directory and click on the @code{projects} subdirectory. Select the file
@code{prj1.gpr}. Click on @code{Apply} to validate the change.
You can see the new dependency added in the project view, as a tree of
projects. In particular, project dependencies are duplicated: if you open
the @code{prj1} icon by clicking on the @code{[+]} sign (or triangle), and then
similarly open the @code{prj2} icon, you will notice that the project
@code{prj4} is displayed twice: once as a dependency of @code{prj2}, and
once as a dependency of @code{prj1}.
GPS can also display the graph of dependencies between projects: on @i{Sdc}
project, use the contextual menu
@code{Show projects imported by Sdc}: this will open a project hierarchy
browser.
On the @code{Sdc.gpr} project, select the contextual menu
@code{Show projects imported by Sdc recursively}.
In the browser, you can move the project items, and select them to highlight
the dependencies.
Close the project browser by clicking on the @code{[x]} sign at the top right
area of the window, or by typing @key{Ctrl-W}, or by using the menu
@code{File->Close}.
@c --------------------------------------------------------------------
@node Epilogue
@chapter Epilogue
@c --------------------------------------------------------------------
@noindent
This terminates our tour of GPS, the GNAT Programming Studio.
We hope this tutorial gave you a good overview of the general capabilities
available with GPS. A non exhaustive list of the features not mentioned in
this document includes:
@itemize @bullet
@item Documentation generation
@item Automatic generation of body files
@item Pretty printing
@item Visual comparison of files
@item Version control
@item Flexible multiple document interface
@item Code coverage
@end itemize
For more information, please look at the @i{User's Guide} (@url{gps.html}),
and also look at the @code{Tools} menu which gives access to most of these
capabilities.
@c @printindex cp
@bye
|