Skip to content

Commit 019b8c0

Browse files
committed
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.
1 parent e455ee6 commit 019b8c0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/docurium/docparser.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ class DocParser
1212
def find_clang_includes
1313
@includes ||=
1414
begin
15-
bindir = `#{ENV["LLVM_CONFIG"]} --bindir`.strip
16-
clang = "#{bindir}/clang"
15+
clang = if ENV["LLVM_CONFIG"]
16+
bindir = `#{ENV["LLVM_CONFIG"]} --bindir`.strip
17+
"#{bindir}/clang"
18+
else
19+
"clang"
20+
end
21+
1722
output, _status = Open3.capture2e("#{clang} -v -x c -", :stdin_data => "")
1823
includes = []
1924
output.each_line do |line|
20-
if line =~ %r{^\s+/.*lib/clang.*/include}
25+
if line =~ %r{^\s+/(.*usr|.*lib/clang.*)/include}
2126
includes << line.strip
2227
end
2328
end

0 commit comments

Comments
 (0)