5 ms·
When writing Ruby C extensions, you almost inevitably need to learn to read the Ruby codebase (written in C). It helps if you can get your preferred IDE to buil
by jez 5y ago
When writing Ruby C extensions, you almost inevitably need to learn to read the Ruby codebase (written in C). It helps if you can get your preferred IDE to build and understand the codebase.
For people who want to use LSP + clangd to explore the Ruby codebase, I wrote up some instructions here:
https://blog.jez.io/clangd-ruby/ https://blog.jez.io/clangd-ruby/
tl;dr: Bear[1] is a tool that hijacks a process tree, looks for calls to clang, records the args it was given, and serializes those out into a compile_commands.json file that can be consumed by various clang tools, including clangd. It's really slick and in my experience Just Works (the highest praise, IMO).
You can use more or less the same trick described in that post to get the Ruby C extensions you build working with LSP + clangd (no guide for this, but it should be self-evident from reading the original guide).
[1] https://github.com/rizsotto/Bear https://github.com/rizsotto/Bear
- Lammy 5y ago> you almost inevitably need to learn to read the Ruby codebase (written in C) That's how I ran across this reference, but from the other direction — I've been reading the MRI codebase with the goal of writing faster/better Ruby :) I've been working on my own version of a file-type identification library (even before the recent `mimemagic` drama) and have found it very necessary to understand the way allocation works since the code in question sits in my app's startup path and gets referenced more frequently than anything else. This post series by Pat Shaughnessy was also very useful for me: http://patshaughnessy.net/2013/2/8/ruby-mri-source-code-idioms-3-embedded-objects http://patshaughnessy.net/2013/2/8/ruby-mri-source-code-idio...
- malkia 5y agoFor MSBuild, one can use what IDE does to get the compile targets: msbuild YourProject.sln /p:Configuration=Release /p:DesignTimeBuild=true /t:_PrintIntellisenseInfo The _PrintIntellisenseInfo target is the key, and "lying" to the rules that you are the IDE - e.g DesignTimeBuild=true. This prints almost the info you want for compilation_database.json