Skip to content

Commit

Permalink
Generate compile_flags.txt for clangd for development
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Mar 8, 2024
1 parent 543b1ff commit f1d84ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/ext/ilios/*.o
/ext/ilios/mkmf.log
/ext/ilios/Makefile
/ext/ilios/compile_flags.txt
/ext/ilios/cpp-driver
/ext/ilios/libuv
/ext/ilios/ports
Expand Down
16 changes: 16 additions & 0 deletions ext/ilios/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ def num_cpu_cores
cores >= 7 ? MAX_CORES : cores
end

def create_compile_flags_txt
cppflags = $CPPFLAGS.split
include_flags = cppflags.select { |flag| flag.start_with?('-I') }
define_flags = cppflags.select { |flag| flag.start_with?('-D') } + $defs

File.open('compile_flags.txt', 'w') do |f|
include_flags.each { |flag| f.puts(flag) }
f.puts("-I#{Dir.pwd}")
f.puts("-I#{RbConfig::CONFIG['rubyhdrdir']}")
f.puts("-I#{RbConfig::CONFIG['rubyhdrdir']}/ruby/backward")
f.puts("-I#{RbConfig::CONFIG['rubyarchhdrdir']}")
define_flags.each { |flag| f.puts(flag) }
end
end

module LibuvInstaller
LIBUV_INSTALL_PATH = File.expand_path('libuv')
private_constant :LIBUV_INSTALL_PATH
Expand Down Expand Up @@ -146,3 +161,4 @@ def self.install_from_source
$LDFLAGS += " #{ENV['LDFLAGS']}"

create_makefile('ilios')
create_compile_flags_txt

0 comments on commit f1d84ae

Please sign in to comment.