chetant / LibClang

Haskell FFI to libclang
Other
58 stars 10 forks source link

Provide access to libclang headers needed for accurate parsing #38

Closed sethfowler closed 10 years ago

sethfowler commented 11 years ago

To produce good results libclang relies on the presence of a set of header files that are normally distributed with it. We need to also distribute those header files in LibClang and provide the programmer with access to their location.

chetant commented 11 years ago

How are these include files used? I see that we export a function that provides the path, do you add that path in withParse?

sethfowler commented 11 years ago

Nah, I didn't want to force users to always include them. It would be a good idea to provide a higher level function with some nice defaults and some clarification on how to use the path, though. (Essentially you just want to add to the command line arguments a "-I" argument which uses that path.)

sethfowler commented 10 years ago

So it turns out that in the release version of LLVM 3.4, they've fixed this problem. libclang now automatically looks for its headers in the directory containing the library. Once the next GHC is out and we can use dynamic linking, this will be perfect.

For now, I've patched libclang to add clang_setClangResourcesPath which allows us to specify the location of the headers. The nice thing is that because this is a special call instead of being part of the command line arguments passed to clang_parseTranslationUnit and the like, we can totally hide this from the user. I no longer export libclangIncludePath in the updated version of the code.