Skip to content

refactor: Fix new and old codechecker script issues - #322

Open
nettle wants to merge 1 commit into
Ericsson:mainfrom
nettle:pybinary-fix
Open

refactor: Fix new and old codechecker script issues#322
nettle wants to merge 1 commit into
Ericsson:mainfrom
nettle:pybinary-fix

Conversation

@nettle

@nettle nettle commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Why:
Change #199 caused a few bugs in downstream projects.
Migration to py_binary should be fixed and refactored.
Besides codechecker.bzl and codechecker_script.py also
contained old bugs.

What:

  • Execute the script py_binary in the test rule, drop the symlink
  • Declare the script tools in the exec configuration
  • Pass one --env= per entry
  • Build the environment explicitly, pass it to every command
  • Simplify the script, name the arguments after the flags
  • Add tests for the analyzer paths, parse exports and config env

@nettle
nettle marked this pull request as draft August 27, 2026 22:30
@nettle
nettle force-pushed the pybinary-fix branch 2 times, most recently from ac6599e to da767c5 Compare August 28, 2026 22:07
@nettle nettle self-assigned this Aug 31, 2026
@nettle nettle added bug Something isn't working enhancement New feature or request labels Aug 31, 2026

@nettle nettle left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hi @furtib, @Szelethus,
I have added a few comments to highlight the most important bugfixes

Comment thread src/codechecker.bzl
allow_files = True,
executable = True,
cfg = "target",
cfg = "exec",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: this is important - should be double-checked

Comment thread src/codechecker.bzl
Comment on lines -240 to -246
# Create test script
codechecker_test_script = ctx.actions.declare_file(ctx.label.name + "/codechecker_test_script")
ctx.actions.symlink(
output = codechecker_test_script,
target_file = ctx.executable._codechecker_script,
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: this is mostly refactoring but potentially a bugfix

Comment thread src/codechecker_script.py
os.makedirs(path)
def build_env(config):
"""Return environment"""
env = os.environ.copy()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: this is a bugfix

Comment thread src/codechecker_script.py Outdated
# Note: This is a workaround, CodeChecker requires the PATH to be set
if "PATH" not in env:
env["PATH"] = "/bin"
if "CC_ANALYZERS_FROM_PATH" not in env:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: this is a bugfix

Comment thread src/codechecker.bzl
arguments.add("--config=" + config_file.path)
arguments.add("--output=" + codechecker_files.path)
arguments.add("--log=" + ctx.outputs.codechecker_log.path)
arguments.add_all(codechecker_env, format_each = "--env=%s")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: this is a bugfix (minor)

@nettle
nettle marked this pull request as ready for review September 1, 2026 20:36
@nettle nettle changed the title Fix py_binary issues refactor: Fix new and old codechecker script issues Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant