Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Support for relative paths in CodeChecker #4181

Open
vodorok opened this issue Mar 4, 2024 · 1 comment
Open

[DRAFT] Support for relative paths in CodeChecker #4181

vodorok opened this issue Mar 4, 2024 · 1 comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands new feature 👍 New feature request RFC ✒️ Request For Comments server 🖥️

Comments

@vodorok
Copy link
Collaborator

vodorok commented Mar 4, 2024

Certain tools (bazel) produce such an output, where absolute paths cannot be used in a cross-environment way. Absolute paths in the .plist output make the CodeChecker store and diff commands unusable as (for example the Bazel) cache folder prefixes would not allow the proper identification of the source files.

A dedicated flag should be added to the CodeChecker analyze command, which would enable the option of the use of relative paths during the whole CodeChecker workflow.

I propose the --use-relative-paths flag for the function mentioned above.

analyze:

When using the analyze command with a compilation command, that contains "."

The current implementation defines the meaning of the relative directory in the compilation database in the following way:
If the "directory" is a "." CodeChecker will pass the current working directory to the exec() function call in the cwd parameter. Eg. the actual analysis command will be executed from the CodeChecker analysis invocation location.

We had an issue with the passing of a filename with leading path elements in the –file option.
#4180 Should fix the problem with the --file option.

When the --use-relative-paths flag is active, all of the paths should be considered, and resolvable from the original CodeChecker analyze invocation, in every output format.

Considering the following directory layout:

/home/proj/src/source.c
/home/proj/src/include/header.h
/home/proj/reports/
/home/proj/reports/proj.plist

Example .plist

…
  <key>files</key>
        <array>
                <string>./src/source.c</string>
                <string>./src/include/header.h</string>
        </array>
…

The paths in the .plist file should be relative to the CodeChecker invocation location.

parse, store, cmd, and server:

The support for relative paths should also be added to the report management command line (parse/store/cmd) utilities, and possibly to the server too.

Because the .plist contains paths to the source files relative to the CodeChecker analyze invocation location, the user must invoke the CodeChecker store|parse|cmd from the original invocation location of CodeChecker analyze

/ The command only works if/$CWD=/home/proj/
CodeChecker store home/proj/reports
@vodorok vodorok added RFC ✒️ Request For Comments new feature 👍 New feature request CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands server 🖥️ analyzer 📈 Related to the analyze commands (analysis driver) labels Mar 4, 2024
@dkrupp
Copy link
Member

dkrupp commented Mar 7, 2024

Wouldn't it be better to resolve the relative paths to the location of the compile_commands.json (instead of the CodeChecker invocation dir) and the plist files?

The advantage would be that you could run the CodeChecker (analyze/parse) from any directory because the location of real files could be calculated from the location of the compile_commands.json and the plist files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands new feature 👍 New feature request RFC ✒️ Request For Comments server 🖥️
Projects
None yet
Development

No branches or pull requests

2 participants