-
Notifications
You must be signed in to change notification settings - Fork 375
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
Setup clangd-based native dev env via rake native_dev:setup #3245
Conversation
e0bc04f
to
e1802a9
Compare
e1802a9
to
b18d2f8
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3245 +/- ##
=======================================
Coverage 98.22% 98.22%
=======================================
Files 1253 1253
Lines 72198 72198
Branches 3350 3350
=======================================
Hits 70917 70917
Misses 1281 1281 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few notes! I'm curious about the choice to develop in ext/
instead of in tmp/
🤔
Rakefile
Outdated
Rake::ExtensionTask.new("ddtrace_profiling_native_extension.#{RUBY_VERSION}_#{RUBY_PLATFORM}") do |ext| | ||
native_exts = [] | ||
|
||
native_exts << Rake::ExtensionTask.new("ddtrace_profiling_native_extension.#{RUBY_VERSION}_#{RUBY_PLATFORM}") do |ext| | ||
ext.ext_dir = 'ext/ddtrace_profiling_native_extension' | ||
end | ||
|
||
Rake::ExtensionTask.new("ddtrace_profiling_loader.#{RUBY_VERSION}_#{RUBY_PLATFORM}") do |ext| | ||
native_exts << Rake::ExtensionTask.new("ddtrace_profiling_loader.#{RUBY_VERSION}_#{RUBY_PLATFORM}") do |ext| | ||
ext.ext_dir = 'ext/ddtrace_profiling_loader' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I'm not sure the extra complexity to support the ddtrace_profiling_loader
here and below is entirely worth it; after all, it's self-contained and received all of 5 commits since its creation.
Up to you ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd personally prefer to keep it. It looks less complex with the latest version and makes for full coverage and easy change if any other native extension appears in the future. But not a strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a strong opinion either, so let's keep it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great contribution, LGTM 👍
directory tmp_dir_dd_native_dev | ||
NATIVE_CLEAN << tmp_dir_dd_native_dev | ||
|
||
compile_commands_task = file "#{ext.ext_dir}/compile_commands.json" => [tmp_dir_dd_native_dev] do |t| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess one downside of this approach is that it works only for a specific Ruby version, so if we need to switch around, we'll need to re-run the rake task every time (and remember to do so).
On the other hand, I think that's fine ATM -- I'm guessing it may be non-trivial to make this per-ruby-version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think doing some automation here may require either encoding the switch operation as a rake task or formally aligning on an official way to handle different Ruby versions (e.g. asdf) so we could use some kind of hook system.
Both options sound way too complicated for the benefit atm 😅
What does this PR do?
Add some helpers to facilitate development on the native extensions of
dd-trace-rb
using the clangd language server.rake native_dev:setup
task to generate the requiredcompile_commands.json
files through bear (following the clangd getting started guide).rake native_dev:clean
task to cleanup the files generated by the previous task (and integration into globalrake clean
).ext/*
directories since the current source code format does not align with clang and it'll try to reformat whole files on every save..gitignore
specific to native extensions to ignore thecompilation-flags.json
files created from this setup and keep them out of source control.Motivation:
Auto complete, navigation and diagnostic support during native extension development:
Additional Notes:
How to test the change?
rake native_dev:setup
.ext/
.I tested it with
neovim
on my local setup.For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance
.Unsure? Have a question? Request a review!