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
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.
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:
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:
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:
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.
Removing Folders
Individual folders can also be removed, similarly to files:
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.
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
.
‑‑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:
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
):
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
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:
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