scitools.com

← All und commands

und is the command-line interface to Understand — script project creation, analysis, CodeCheck, metrics, and reports, locally or in CI.

und add

adds files, directories and roots

The add command can be used to add files, directories, or visual studio files to a project. The add command can also be used to add compiler log files or CMake databases (e.g. compile_commands.json files). Additionally, add can be used to specify named roots. The type being added does not need to be specified, but the -file, -vs, and -root switches are available to force the arguments to be treated as a file, visual studio file, or named root respectively. Directory is the default when the argument's type cannot be determined.

1) Adding Directories

This is the most common use for the command. It can be run like this:

und add thisDirectory myProject.und

This adds "thisDirectory" to myProject.und. The directory can be absolute or relative to the current directory. The following switches are available for adding directories:

OptionDescription
-watchThis determines whether a directory is watched or not. By default, -watch is on. It can be given <on,off>.
-subdirThis determines whether or not to add all the subdirectories. This is on by default, and can be given <on,off> as parameters.
-excludeThis takes in a list of wildcards separated by a comma. Any files or directories that match are ignored. By default, it is .*
-noncodeTurns 'On/Off' the inclusion of noncode files found in existing code directories. By default, this is turned 'Off'.
-filterThis takes in a list of wildcards. Any files or directories that match are included. By default, there are none.
-langThis specifies specific languages to add files for. By default, all project languages are included.

The switches should appear before the arguments, so a command with switches might look like this:

und add -watch off -exclude "*.java","*.cpp" thisDirectory

2) Adding Import Files

Understand can add visual studio projects and solutions, xcode projects, and cmake compile_commands.json files to the database. It supports .csproj .dsp .dsw .vbproj .vcp .vcproj .vfproj .vcxproj .vcw .xcodeproj and compile_commands.json files. Visual studio files and xcode projects require a configuration given with the -config switch. The following switches are available:

OptionDescription
-analyzelaterSkip the automatic analysis of changed files.
-cmakeOptional, tell und the file is a cmake compile_commands.json.
-configThe configuration to use with the project.
-excludeList of wild card excludes separated by semicolon.
-noncodeTurns 'On/Off' the inclusion of noncode files found in existing code directories. By default, this is turned 'Off'.
-onetimeDisable project sync.
-vsOptional, tell und the file is a visual studios file.
-xcodeOptional, tell und the file is an xcode project.

A command might look like this:

add -config "Debug|Win32" file.vcproj  (Interactive mode)
und add -exclude "test*" -cmake compile_commands.json myProject.und

3) Adding Files

This command simply adds a file to the project. If a file is currently excluded, adding it will remove the exclude flag. It takes in a list of files, or a text file containing a single file per line with comments starting with #. If a text file is given as the parameter, it should begin with @. The only switch is:

OptionDescription
-fileOptional, force the arguments to be treated as files to add (rather than a directory, import file, or named root).
und add file1.cpp file2.cpp myProject.und
und -db myProject.und add -file file1.cpp file2.cpp
add @myFiles.txt    (Interactive Mode)

4) Adding Named Roots

For information on named roots, use (und help roots). Multiple roots can be added on a line with root=value root2=value2 and so on. The command can also take in a text file listing one root=value per line. The text file should begin with @. The command for adding named roots could look like this:

und add -root root=value root2=value2
add @myRoots.txt   (Interactive Mode)

5) Adding Log Files

A log file is recognized by the extension "log" and has two available switches.

OptionDescription
-ccSpecifies the c compiler.
-cxxSpecifies the c++ compiler.

6) Merging another database

The add command can be used to add all the files and their override settings of one database to another database. If the files are already in the "to" database, their override settings will be changed to match that of the "from" database. The command looks like this:

und add -db todb.und fromdb.und fromdb2.und
und add fromdb.und todb.und

Note that both fromdb and todb must be specified, even in interactive mode.