The following documentation discusses the Source-Navigator
source code comprehension tool, using a tutorial to demonstrate the usage
of debugging the sources for a project, editing the source files and building
the project, the monopgame. In this
tutorial, you will create two targets, monop and initdeck,
and, with them, use many compiling, editing and debugging features of GNUPro
Toolkit. The result is making and running the monopproject’s
game.
Invoke Source-Navigator with the following input, using a
shell window’s commandline interface from the /usr/cygnus/gnupro/sn99r1/directory.
snavigator
For more information about using Source-Navigator, see its
online documentation from its Help
menu.
Creating the Source-Navigator
demonstration project
With Source-Navigator
active, create a new project.
1. Choose
File
-> New Project...
from the Symbol Browser
and define a new project, calling it monop.proj.
2.
Under Add Directory,
click the “...” button to select
the demos\monop directory. See Figure
4 for the result of defining the new project’s name in the Auto-Create
Project window. Click OK
to build the project.
Figure
4: Creating a new project, monop.proj, from the
demos\monop
directory
Building
the monoptarget
Having created
a project, you must then build its target components.
1. Choose
Tools
-> Build Settings...
to start the Build Settings
window.
2.
Enter monop as the name of the target. See Figure
5 for the result.
Figure
5: Creating a monop target
3.
Click Create.
The Edit Target
window appears.
4.
In the Build Directory
field, click the “...” button
and select the build directory for the monop project (see Figure
6).
Figure
6: Defining the project for building
5.
From Project Files
in the Edit Target
window for the monop project, select cards.c , execute.c
, getinp.c , houses.c , jail.c , misc.c
, monop.c , morg.c , print.c , prop.c
, rent.c , roll.c , spec.c , and trade.c
files.
6.
Click the Add Files
button to copy the files to the Target
Files list. In Figure
7, see the result of moving the files from the Target
Files pane to the Project
Files pane.
Figure
7: Adding the project’s files to the target
NOTE:
To execute
the program correctly in UNIX, click the Link
Rules tab. Enter xterm -e bmonop in the Command
to launch Application field and click OK
to close the Link Rules
window.
7.
Click OK to close
the Edit Targetwindow.
Click Done to
close the Settings window. The target is created. Now
you need to debug and compile the program. See Debugging
and compiling the monop target.
Debugging
and compiling the monop target
To ensure that
a project can compile (or build),
you must first run through a debugging process before using the maketool
to create the project.
1. Select
Tools
-> Build from
the menu bar. The Buildwindow
opens.
2.
In Build Targets,
select monop from the target list. See Figure
8. Click Start.
Figure
8: Running a debugging process for the project before compiling
3.
In this tutorial, Source-Navigator generates some errors from the build.
For instance, lint needed to have a definition in the source code.
See Figure 9.
Figure
9: Errors in the project
Creating the
lint
macro
To ensure that
a project can build, edit the macro errors that the debugger finds.
1. Choose
Tools
-> Build Settings...
to start the Edit Target
window. See Figure 10.
2.
Double-click
monop to edit it.
3.
Click the Build Rules
tab to modify the rules for the build.
Figure
10:
Modifying how the project builds
4.
Because monop is written in C, double-click the C
rule in the File Type
column. The Build Rules Settings
window appears.
5.
Click the Defines
tab. Enter lint in the text entry box. See Figure
11.
Figure
11: Defining the lintmacro
6.
Click New to create
the macro.
7.
Click OK to close
the Build Rules Settings
window. Click OK
to close the Edit Target
window. Click Done
to close the Build Settings
window.
8.
Select Tools
-> Build from
the menu bar and select monop from the target list.
9.
monop
generates without errors. However, at runtime the program does not run
because we still need to define the path to the cards pack.
Creating the
_PATH_CARDS macro
Now, define
the other macro, _PATH_CARDS, to continue making the project work.
1. Choose
Tools
-> Build Settings...
to start the Edit Target
window.
2.
Double-click monop to edit it.
3.
Click the Build Rules
tab to modify the rules for the build. See Figure
12.
Figure
12: Modifying the project’s macros
4.
Because monop is written in C, double-click the C
rule. The Build Rules Settingswindow
appears, as in Figure 13.
5.
Click the Defines
tab.
6.
Enter the following input in the dialog below the Macro
defines pane, replacing <project directory>
with your path to the demos\monop directory:
Now,
GNUPro Toolkit uses an appropriate definition for the card pack macro,
_PATH_CARDS,
when running the monop program.
7.
Click OK to close
the Build Rules Settings
window. Click OK
to close the Edit Target
window. Click Done
to close the Build Settings window.
8.
Select Tools
-> Build from
the menu bar and select monop from the target list. Click Start
to perform the build.
9.
_PATH_CARDS="\"<build
directory>/cards.pack\" " is a macro. To ensure that
this change is picked up at compile time, perform a clean build of the
monop target project by selecting Tools->Clean
Build in the Build
window (see Figure 14).
A clean build is equivalent to
the make clean command.
Figure
14: Performing a clean build for a project
10.
Click the Start
button to perform the build.
11.
Now, the monop project compiles without errors (see Figure
15).
Figure
15: A clean build of a project
Building
the initdeck target
Next, you need
to create another target to initialize the cards in the monop game.
1. Choose
Tools
-> Build Settings...
to invoke the Build Target
window.
2.
Enter initdeck as the name of the target (see Figure
16).
Figure
16: Defining another target for a project
Click
Create.
The Edit Target
window appears (see Figure 17).
In
the Build Directory
field, click the “...” button and select the monop directory.
From
Source
Files, select the initdeck.c file and click
the Add Filesbutton
to copy the file to the Target Files
list.
Figure
17: Creating a new target for a project
Click
OK
to close the
Edit Target
window. Click Done
to close the Build Settingswindow,
having defined and created the new target.
Debugging
the initdeck target
To ensure that
a project can build with the new target, edit the macro errors that the
debugger finds.
1. Build
the target by selecting Tools
-> Build from
the menu bar of the Build
window. Select initdeck from the target list, and click Start.
2.
initdeck
generates with errors. Again, we need to define the lint macro
and the path to the cards.
3.
Choose Tools
-> Build Settings...
to start the Build Settingswindow.
4.
Double-click initdeck to edit it.
5.
Click the Build Rules
tab. Double-click the C
rule. The Build Rules Settingswindow
appears (see Figure 19). Click the Defines
tab. Enter lint in the text entry box.
Figure
18: Defining the lint macro for the new target
6.
Click New to create
the macro. Enter the following input in the dialog below the Macro
defines pane, replacing <project directory>
with
your path to the demos\monop directory:
Now,
GNUPro Toolkit uses an appropriate definition for the card pack when running
the monop program.
Click
OK to close the Build Rules Settings
window. Click OK
to close the Edit Target
window. Click Done
to close the Build Settings
window, having modified the target for the project.
Open
a shell window and copy the cards.inp file in the demos\monopdirectory
into the build directory (see Figure 20
for an example of the copy command in a Command.com
shell window that a Windows NT developer could use; UNIX users would use
the cp command in a shell window).
Figure
20: Copying files for the project in a shell window
Select
Tools->
Build
from the menu bar and select initdeck from the target list.
To
ensure that the macro changes are picked up at compile time, perform a
clean build of the initdeck target by selecting Tools
-> Clean Build
(see Figure 21).
Figure
21: Performing a clean build for the new target for the project
Click
the Start button
to perform the build.
Now,
initdeck
compiles and links without errors. binitdeck is the name of the
working executable.
Click
the Run button
to run binitdeck which creates the cards used in the game.
A
shell window opens to build the cards (see Figure
22) and closes after the build is complete.
Figure
22: Rebuilding the new target for the project
From
the Build Targets
field of the Build
window, select monop and click Run.
A
shell window opens and monop runs automatically. Enter the number
of players and their names. See Figure 23 for an example
in a shell window of a project that builds and is ready to run.
Use
the ?key
to get playing options for monop. Oh, have fun.