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

Create Compilation Database on every build #4711

Closed
1 task done
dzid26 opened this issue Aug 10, 2023 · 4 comments
Closed
1 task done

Create Compilation Database on every build #4711

dzid26 opened this issue Aug 10, 2023 · 4 comments

Comments

@dzid26
Copy link

dzid26 commented Aug 10, 2023

  • Feature Request.
    Start by telling us what problem you’re trying to solve. Often a solution
    already exists! Don’t send pull requests to implement new features without first getting our
    support. Sometimes we leave features out on purpose to keep the project small.

I would like compile_commands.json generation to be triggered by adding a deliberate flag in platformio.ini.

if "compiledb" in COMMAND_LINE_TARGETS:

Existing solution (below) is not great because it changes the VSCode GUI icons' action.

[env]
targets = upload, compiled
@dzid26
Copy link
Author

dzid26 commented Jan 26, 2024

I tried to do this using extra_scripts (post):

import subprocess
projectTag = (
    subprocess.run(['pio', 'run','-t','compiledb'])
)

but the build went into infinite loop and started eating up RAM.

@ivankravets
Copy link
Member

Do you run that part of the code under the guard?

if "compiledb" not in COMMAND_LINE_TARGETS: 
    subprocess.run(['pio', 'run','-t','compiledb'])

@dzid26
Copy link
Author

dzid26 commented Jan 26, 2024

Ah, that works great.

[env]
extra_scripts = post:generate_compilation_database.py #for the sonarlint
import subprocess
if "compiledb" not in COMMAND_LINE_TARGETS: #avoids infinite recursion
    subprocess.run(['pio', 'run','-t','compiledb'])

@ivankravets
Copy link
Member

I think this is a great solution. I'm going to close this issue.

Happy coding with PlatformIO! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants