From 019b8c0c4b76870b441ac1e0a7012e699ac02b8e Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Thu, 8 Aug 2019 13:51:47 +0200 Subject: [PATCH] Use the locally installed clang, and make it work on macOS This adds a fallback for the `$PATH`-installed `clang` executable, which sidesteps `llvm-config` not being provided on macOS. This also relaxes the regex filter, as the required SDK headers on macOS have strange paths. --- lib/docurium/docparser.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/docurium/docparser.rb b/lib/docurium/docparser.rb index 385961716..4d04df134 100644 --- a/lib/docurium/docparser.rb +++ b/lib/docurium/docparser.rb @@ -12,12 +12,17 @@ class DocParser def find_clang_includes @includes ||= begin - bindir = `#{ENV["LLVM_CONFIG"]} --bindir`.strip - clang = "#{bindir}/clang" + clang = if ENV["LLVM_CONFIG"] + bindir = `#{ENV["LLVM_CONFIG"]} --bindir`.strip + "#{bindir}/clang" + else + "clang" + end + output, _status = Open3.capture2e("#{clang} -v -x c -", :stdin_data => "") includes = [] output.each_line do |line| - if line =~ %r{^\s+/.*lib/clang.*/include} + if line =~ %r{^\s+/(.*usr|.*lib/clang.*)/include} includes << line.strip end end