Skip to content

Commit 0263033

Browse files
committed
Only load extconf_compile_commands_json when compiling through Rake tasks
Otherwise, it'd cause LoadError in official release because extconf_compile_commands_json is not a runtime dependency.
1 parent af273d8 commit 0263033

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Rakefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ bin = File.join(__dir__, "bin")
1111

1212
Rake::ExtensionTask.new("rbs_extension")
1313

14+
compile_task = Rake::Task[:compile]
15+
16+
task :setup_extconf_compile_commands_json do
17+
ENV["COMPILE_COMMANDS_JSON"] = "1"
18+
end
19+
20+
compile_task.prerequisites.unshift(:setup_extconf_compile_commands_json)
21+
1422
test_config = lambda do |t|
1523
t.libs << "test"
1624
t.libs << "lib"

ext/rbs_extension/extconf.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
create_makefile 'rbs_extension'
2828

29-
require 'extconf_compile_commands_json'
30-
ExtconfCompileCommandsJson.generate!
31-
ExtconfCompileCommandsJson.symlink!
29+
# Only generate compile_commands.json when compiling through Rake tasks
30+
# This is to avoid adding extconf_compile_commands_json as a runtime dependency
31+
if ENV["COMPILE_COMMANDS_JSON"]
32+
require 'extconf_compile_commands_json'
33+
ExtconfCompileCommandsJson.generate!
34+
ExtconfCompileCommandsJson.symlink!
35+
end

0 commit comments

Comments
 (0)