Skip to content
Open
31 changes: 18 additions & 13 deletions src/codechecker_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@
CODECHECKER_ENV = "{codechecker_env}"
COMPILE_COMMANDS = "{compile_commands}"

START_PATH = r"\/(?:(?!\.\s+)\S)+"
BAZEL_PATHS = {
r"\/sandbox\/processwrapper-sandbox\/\S*\/execroot\/": "/execroot/",
START_PATH + r"\/worker\/build\/[0-9a-fA-F]{16}\/root\/": "",
START_PATH + r"\/[0-9a-fA-F]{32}\/execroot\/": "",
Comment on lines -32 to -34
Copy link
Contributor

@Szelethus Szelethus Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the new explanations, but I think I'm gonna need a bit more info as to whether we've truly reproduced these with the new regexes. In particular, by omitting START_PATH, you seem to produce absolute paths when symlinking fails, whereas the old regexes seem to produce relative paths always. Do we need to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have not reproduced what these regex did. Only the middle one is reused, just without the START_PATH; this is most likely a remote executor-specific setting, our testing solution did not produce such a START_PATH. We should inquire more about these regexes. For now, it seems like for local runs, they are unnecessary; for remote jobs, it could be setup-dependent.

# Running with Build Barn produces path output like:
# /worker/build/b301eed7f2bf2fd8/root/local_path.cc
# By removing the part until bin we have resolved the path to a local file
r"\/worker\/build\/[a-z0-9]{16}\/root\/": "",
# Sometimes the previous part is followed by this, before the local_path:
r"bazel-out\/k8-fastbuild\/bin\/": "",
# Virtual includes seems to be just a folder between the package and the
# folder containing the header files, like this:
# /path/to/package/_virtual_include/folder_with_headers/header.h
r"\/_virtual_includes\/" : "/",
}


Expand Down Expand Up @@ -280,18 +286,17 @@ def resolve_symlinks():
files_processed = 0
for root, _, files in os.walk(analyze_outdir):
for filename in files:
if re.search("clang-tidy", filename):
filepath = os.path.join(root, filename)
if os.path.splitext(filepath)[1] == ".plist":
resolve_plist_symlinks(filepath)
elif os.path.splitext(filepath)[1] == ".yaml":
resolve_yaml_symlinks(filepath)
files_processed += 1
filepath = os.path.join(root, filename)
if os.path.splitext(filepath)[1] == ".plist":
resolve_plist_symlinks(filepath)
elif os.path.splitext(filepath)[1] == ".yaml":
resolve_yaml_symlinks(filepath)
files_processed += 1
logging.info("Processed file paths in %d files", files_processed)
def update_file_paths():
""" Fix bazel sandbox paths and resolve symbolic links in generated files to real paths """
fix_bazel_paths()
""" Resolve symlinks from local jobs, then try fixing path from remote executors """
resolve_symlinks()
fix_bazel_paths()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, whats the explanation here? Why the change of order? If possible, resolve, than fall back to replacing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, we should not shoot ourselves in the foot, if we can use the syslinks



def parse():
Expand Down
4 changes: 1 addition & 3 deletions test/unit/virtual_include/test_virtual_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ def test_bazel_codechecker_plist_path_resolved(self):
self.assertTrue(
os.path.isdir(f"{self.BAZEL_BIN_DIR}/_virtual_includes")
)
# FIXME: In the postprocessed plists, all _virtual_include paths
# should've been removed. Possible fix is in the github PR #14.
self.assertNotEqual(
self.assertEqual(
self.contains_in_files(r"/_virtual_includes/", plist_files), []
)

Expand Down