jank-lang / jank

The native Clojure dialect hosted on LLVM
https://jank-lang.org
Mozilla Public License 2.0
1.7k stars 50 forks source link

Add support for include paths, library paths, and linked libs #127

Open jeaye opened 2 weeks ago

jeaye commented 2 weeks ago

In order to support native code which wraps other native deps, we need to be able to resolve the headers and find the libs. This will be done using CLI flags to jank, which can then be declaratively set in lein-jank projects. We need to support three things:

Include paths

This is a vector of either relative or absolute paths to directories. We will need to pass these to the clang interpreter, each with an -I in front of it.

Library paths

This is a vector of either relative or absolute paths to directories. We will need to search these ourselves, for the various linked libraries, to find the shared objects to bring in.

Linked libraries

This is just the name of the library. For example, libfoo.so will be referred to as just foo. This is how things are done in the native world and we'd generally use -lfoo to link it. So we need to take in a vector of library names and then we need to find them in the library directories.

To complicate matters further, we should also support relative and absolute path names to libraries themselves (i.e. /usr/lib/libfoo.so). In that case, we don't need to do any directory searching.

Note that we need to look for .so on Linux and .dylib on macOS. We're not going to focus on static libraries at this point.

Once a library is found, we can give it to clang's interpreter to load.

Preprocessor defines

When including headers, we may need to have certain defines set. Users will need to specify these and they will turn into -DFOO=bar args to Clang.

Samy-33 commented 2 weeks ago

@jeaye, working on this