4.2. Setup the Software System - Makefile Capturing

This section describes how to create a new C++ system using command capturing files. Select "New""System based on C/C++ Make command capturing files" . Specify the name of the directory of the Sonargraph software system and where its files will be stored. It is a best practice to store the software system close to the actual source code and place it under version control. Using a Quality Model is explained in Section 2.6, “Share Results” ; you can leave this option unchecked for now.

You will have to do a complete rebuild of your system while passing a special shell to the 'make' command. The special shell will create raw files named 'h2m-capture.txt' for each 'Makefile' that executes compile commands during the make process. These files contain a complete list of the compile commands and are used to extract the right options for the C/C++ parser. Sonargraph will then translate these files into files named 'h2m-capture-rel.txt' Do not delete the translated capturing files, instead add them to your version control system. They are used each time Sonargraph opens your system. If you change options or add or remove files from your build you have to repeat the capturing process. Please note, that your top level 'Makefile' must be either in the same directory as the software system or in a sub-directory of that directory. Here are the commands you need to execute on the level of your top-level 'Makefile':

Example 4.1. Command Capturing Process
                        
        SG_DIR=<replace with Sonargraph installation directory>
        $SG_DIR/bin/h2mcs clean
        make clean
        make <optional-targets> SHELL=$SG_DIR/bin/h2mcs
                        
            


After executing those commands you should find 'h2m-capture.txt' files in the relevant project directories; 'make clean' can be replaced with another command you use to force a complete rebuild of your system. On Windows platforms the capturing process currently only works in combination with Cygwin.

Once the 'h2m-capture.txt' files have been generated you can choose which of them you want to use to create the modules.

Select C++ modules to import from capturing files
Figure 4.1. Select C++ Modules to Import from Capturing Files


If you want, you can change the name and configuration for each of the modules by editing the corresponding fields.

Renaming and configuring C++ modules to import from capturing files
Figure 4.2. Renaming and Configuring C++ Modules to Import from Capturing Files


Each generated 'h2m-capture.txt' results in the creation of one module in the Sonargraph workspace. You can see the created modules in the Navigation view.

The next step to get started with your analysis is perform a refresh so the required information is picked up from the set-up modules.