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

Support workflows that involve C++, such as in R packages #2718

Open
juliasilge opened this issue Apr 10, 2024 · 6 comments
Open

Support workflows that involve C++, such as in R packages #2718

juliasilge opened this issue Apr 10, 2024 · 6 comments
Labels
area: builds Issues related to Builds category. area: license Issues related to Licensing enhancement New feature or request
Milestone

Comments

@juliasilge
Copy link
Contributor

A fair amount of R packages involve C++ code, such as those using cpp11 or Rcpp. Let's consider how to support workflows where folks use C++. R package developers like to use VS Code for this, but the main extension(s) are proprietary and not on OpenVSX.

@juliasilge juliasilge added enhancement New feature or request area: license Issues related to Licensing labels Apr 10, 2024
@lionel-
Copy link
Contributor

lionel- commented Apr 10, 2024

The clangd extension (https://github.com/clangd/vscode-clangd) is open source but requires a bit more configuration: a compile_commands.json file that contains compiler flags for each file. Once set up correctly though, it's a very good analyzer.

It's been on our longer-term todo list to look into integration with pkgload / pkgbuild to construct the compilation database. I'm using https://github.com/rizsotto/Bear which works well. Windows support might be tricky: rizsotto/Bear#431

Should we aim for RC for this issue?

@juliasilge
Copy link
Contributor Author

Would you vote for RC @lionel-? I think we'll discuss in the next triage meeting as well.

@rstub
Copy link

rstub commented Apr 10, 2024

Besides R packages using C++ there are also standalone C++ files that can be sourced using Rcpp::sourceCpp or cpp11::cpp_source(). In the RStudio IDE the "source" button uses these functions directly, which allows for convenient workflows.

@lionel-
Copy link
Contributor

lionel- commented Apr 10, 2024

@juliasilge I think it's a nice-to-have for RC but not a blocker. Do we add such aspirational items to milestones and remove them later on if time is short?

@kevinushey
Copy link
Contributor

Could Positron generate compile_commands.json by hand for the user? Either by inspecting the output of R CMD SHLIB --dry-run, or something similar with running make -n?

It'd be nice if this worked at least for the most common configurations, for packages containing some C / C++ files with perhaps some minimal versions of Makevars supported.

@juliasilge juliasilge added the area: builds Issues related to Builds category. label Apr 11, 2024
@juliasilge juliasilge added this to the Future milestone Apr 16, 2024
@lionel-
Copy link
Contributor

lionel- commented Jun 28, 2024

r-lib/pkgload#285 brings us much closer by making it possible to update a compile_commands.json file on each load_all(). This makes the package compatible with the clangd LSP server.

A manual intervention is required to set it up, currently the user needs to call pkgload:::use_compilation_db() (this will be exported from usethis in the future). We'll need to think about whether and how to advertise this on the frontend side. We could detect C/C++ code and a missing Config/build/compilation-database field in DESCRIPTION and prompt the user about whether they want to maintain a compilation database with devtools? This would be annoying to users of non-devtools workflows though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: builds Issues related to Builds category. area: license Issues related to Licensing enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants