qacli project files

Add or remove source files from the Helix QAC project. Manipulate file/folder specific components options.

Usage

project files {-A <filelist>|-R <filelist>|-a|-r|-s|-e|-u|-x|-l} -P <directory> [-z <command>] [-p <priority>] [-C <cct-name>] [-Z] [-f] [-o <option-name>] [-v <option-value>] [-O <options-file>] [-F <filelist>] [-c <component key>] [--] [-h]

Extended Description

Add a source file from a user’s project into a Helix QAC project. This can then be subsequently analyzed and reported on. Specific analysis options can be specified on a per file or per folder basis, which will override any options on a component wide basis. Allow the user to specify an analysis priority to determine which files get analyzed before others.

Options

Name, shorthand Default Description
‑‑add, ‑a   Explicitly add a file (and optionally) any includes and defines to the Helix QAC project.
‑‑add-list, ‑A   Explicitly add a list of files (and optionally) any includes and defines to the Helix QAC project.
‑‑analysis‑priority, ‑p 0 Specify an analysis priority (32-bit integer) when adding files to a project. Can only be used with ‑‑add or ‑‑add-list.
‑‑cct, ‑C   For projects with multiple CCTs configured this option allows you to explicitly specify a CCT to use for those file(s). If not specified or it is blank then the default CCT for the project will be used.
‑‑clear, ‑x   Removes all file/folder level options for the specified files/folders.
‑‑compile‑command, ‑z   Specify a command to be used when running qacli in compiler wrapping mode. This command will be used to compile your files after qacli has extracted data and added it to a Helix QAC project.
‑‑component, ‑c   Key of component to operate on, in a <name>-<version> format. If the version is omitted, the latest version of the component will be used.
‑‑files, ‑F   Specify a path to a file containing a list of files/folders to be used for this command. Applies to ‑‑set, ‑‑unset, ‑‑clear, ‑‑set-once, ‑‑list.
‑‑folder, ‑f   Add a folder to the Helix QAC project with optional folder specific compile dependencies. Folder details must be placed after the '‑‑' option.
‑‑help, ‑h   Displays usage information and exits.
‑‑ignore‑rest, ‑‑   Ignores the rest of the labeled arguments following this flag.
‑‑list, ‑l   Lists option values that have been explicitly set for the specified files/folders.
‑‑optimize, ‑Z   Optimize the project's folder and file dependencies before the project configuration is saved.
‑‑option, ‑o   Name of option on which to operate. Supported operations: ‑‑set, ‑‑set-once and ‑‑unset.
‑‑options‑file, ‑O   Specify a path to a valid file containing component options, one per line. Lines beginning with '*' are ignored.
‑‑qaf‑project, ‑P . Specify a path to a valid Helix QAC project.
‑‑remove‑list, ‑R   Explicitly remove a list of files and any associated includes and defines from the Helix QAC project.
‑‑remove, ‑r   Explicitly remove a file and any associated includes and defines from the Helix QAC project.
‑‑set, ‑s   Sets the component option (‑‑option) with a given value (‑‑value).
‑‑set‑once, ‑e   Sets the option (‑‑option) with a given value (‑‑value) if the option has not already been set. This should be used with cumulative options. If used with non-cumulative options it will behave exactly like ‑‑set.
‑‑unset, ‑u   Removes the value (‑‑value) from a given option.
‑‑value, ‑v   Value of the option.

Examples

Adding a File Explicitly

qacli project files -P . --add --analysis-priority 100 -- -Isrc/ -Ithird/party/lib/include -DMACRO=1 src/file.c

For the case when a file already exists in the project, the file will be updated with the new argument data.

Adding a File with Specific Priority and CCT

This will add the file foo.c, with the stated Includes and Defines:

qacli project files -P . --add --analysis-priority 100 --cct gcc-13 -- -Isrc/ -Ithird/party/lib/include -DMACRO=1 src/foo.c

It will have the optional fields, analysis priority (= 100) and CCT gcc-13 - which must already be in the project.

Adding Multiple Files Explicitly

Multiple files can be added by placing the files into a filelist, together with associated Includes and Defines.

qacli project files -P . --add-list my-filelist

Updating Folders

Following a synchronization or project optimization, dependency data (Include Paths and Definitions) may become associated with folders in the project. Files downstream from folders with dependency data will inherit these dependencies, and so it’s useful to have a mechanism for modifying the folders directly. It is possible to update folders like in this example:

qacli project files -P . --add --folder -- -Ithird/party/lib -DMACRO=1 src/

It cannot be used in combination with the compile-command switch, see Compiler Wrapping. Multiple folders can be specified in the argument list.

Removing a File Explicitly

The simplest method of ensuring that files are consistent in a project is to use the qacli sync command described in qacli sync, which will add and remove files as needed. However, you can also remove specific files as needed, for example:

qacli project files -P . --remove -- src/file.c

Using a Different CCT for a Folder

Usually, a project will use a single CCT for each language but you can also use multiple CCTs, as explained in Projects with Multiple CCTs. If you have chosen the Auto CCT route, then the correct CCT will be automatically allocated to the correct file, but you can also explicitly specify which CCT to use for each file or directory.

Whilst you can specify it on a file basis, this may be tedious and impractical for larger projects. Instead, you can specify the default CCT on a per folder basis, using a command such as:

qacli project files -P . --add --folder --cct basic_c_cct -- -Ithird/party/lib

All files (of the same language as the CCT) in this directory and below will use this CCT.

Removing Multiple Files Explicitly

Multiple files can be removed by placing the files into a filelist, optionally with associated Includes and Defines.

qacli project files -P . --remove-list my-filelist

Removing Folders

Individual folders can also be removed, similarly to files:

qacli project files -P . --remove --folder -- src/

Removing a folder using this method will also remove any immediate files that directly rely upon it, but any child/sub folders will not be affected.

Optimization

When files are added or removed from a project in bulk, it may be useful to optimize the project. For more information about project optimization, refer to Optimizing a Project.

qacli project files -P . --optimize --add-list my-filelist

Modifying Options

Options are usually set at the component level, but these can be overridden for a file or a folder (and subsequent files) by specifying the option with a different value. It is possible to modify the option directly on the CLI or specify a list of options and values you want altering. Individual files/folders can be altered, or a list of files can be specified in a filelist.

Where possible, options should be set at the component level, then directory level, then finally on a file-by-file basis. Setting many options for several files will cause the main configuration file to grow excessively and will impact the performance of the project.
Most of the following examples mention altering the options for a file but this can also be applied to a folder (and all files below that in the filesystem hierarchy).
Many of the following examples are for ‑‑set, but they equally apply to ‑‑unset and ‑‑set-once.
Modifying and Viewing a Single Option for a Single File

To add a single define for the file src/test_1.c and then view all options for that file:

qacli project files -P . --set --option d --value NAME=Baldrick --component qac -- src/test_1.c
qacli project files -P . --list --component qac -- src/test_1.c
Modifying and Viewing Multiple Options for Multiple Files

To modify several options, create an options list (options.lst) and then apply it the files:

options.lst:
-d NAME=Baldrick
-d IQ=10
qacli project files -P . --set --options-file options.lst --component qac -- src/test_1.c src/test_2.c
Attempted to modify 2 options for 2 files.
qacli project files -P . --list --component qac -- src/test_1.c
-d NAME=Baldrick
-d IQ=10
Modifying Options for Multiple Files

To modify an option for many files, put the list of files into a filelist (files.lst):

files.lst:
src/test_1.c
src/test_2.c
qacli project files -P . --set --option d --value NAME=Baldrick --component qac --files files.lst
qacli project files -P . --list --component qac --files files.lst
* /home/steve/.config/Perforce/Helix-QAC-2022.1/samples/sample_mixsource-2022.1/src/test_1.c
-d NAME=Baldrick
* /home/steve/.config/Perforce/Helix-QAC-2022.1/samples/sample_mixsource-2022.1/src/test_2.c
-d NAME=Baldrick
Modifying Multiple Options for Multiple Files

You can combine an options list with a filelist to modify multiple options in multiple files:

qacli project files -P . --set --options-file options.lst --component qac --files files.lst
Attempted to modify 2 options for 2 files.
qacli project files -P . --list --component qac --files files.lst
* /home/steve/.config/Perforce/Helix-QAC-2022.1/samples/sample_mixsource-2022.1/src/test_1.c
-d NAME=Baldrick
-d IQ=10
* /home/steve/.config/Perforce/Helix-QAC-2022.1/samples/sample_mixsource-2022.1/src/test_2.c
-d NAME=Baldrick
-d IQ=10
Removing Individual Options

Individual options and values can be removed using the ‑‑unset option, which follows the same format as ‑‑set. For example:

qacli project files -P . --set --option d --value NAME=Baldrick --component qac -- src/test_1.c
qacli project files -P . --unset --option d --value NAME=Baldrick --component qac -- src/test_1.c
qacli project files -P . --list --component qac -- src/test_1.c
Removing All Options

To remove all options, you can use the ‑‑clear option:

qacli project files -P . --set --option d --value NAME=Baldrick --component qac -- src/test_1.c
qacli project files -P . --clear --component qac -- src/test_1.c
qacli project files -P . --list --component qac -- src/test_1.c
A filelist can also be used.
Modifying Options in Multiple Components

The examples listed above all explicitly specify which component the option applies to. When using an options list (or the ‑‑list option) you can omit the component from the command line. For options lists the first column in the file is then the component, for example:

component_options.lst:
qac -d NAME=Baldrick
qac -d IQ=10
namecheck -echo Namecheck
qacli project files -P . --options-file component_options.lst --set -- src/test_1.c
Attempted to modify 3 options for 1 files.
qacli project files -P .  --list -- src/test_1.c
qac -d NAME=Baldrick
qac -d IQ=10
namecheck -echo Namecheck