clangsa-sast: add include-directory rebasing to cdb-rebase
Problem to solve
When a CDB is generated in one place for use in another, it is often more than the directory entry of each command that needs changing. E.g. -I /usr/local/include/some_lib might become -I system_includes/some_lib.
Proposal
Add the ability to detect included directories outside of the source project, copy to the destination project, and update commands.
The command invocation in a compilation database can be represented as a list of arguments or as a string command. Both should be handled
-
update the CLI -
add an include-cache,-c, flag with a default value ofinclude-cachethat must be relative -
add an include,-Ioption for include paths that are not automatically detected, but must be copied into theinclude-cache -
add an extra-argument,-Xthat appends the argument to the end of every build command -
add an exclude,-eflag that takes a glob pattern for paths that should be skipped during the copy into the include cache.
-
-
parse the commandform of arguments into a[]string, e.g. usingshellparse -
for each argument -Ifollowed by an include path or-I<include-path>(or variations like-isystem)-
detect if an include path needs rewriting, i.e. because it is absolute or outside of the project directory -
apply the rewrites and update the CDB object
-
-
test -
add unit tests of CDBs with both absolute and relative includes outside the source directory. The absolute paths can be dynamically created in the test. -
add a fixture that uses an include directory outside its project directoryintegration-test is meant for use with a before_script operation likecdb-rebase.
-
Edited by Jason Leasure