-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Clean up and extend existing support for C/C++ libraries #2644
Comments
A trivial remark is that if we are to be compatible with existing convention, then the names in |
Suppose that you have a C file containing |
@nojb Thanks for the comments!
Yes, we should definitely list this as a possible alternative. I've added this to the top post to keep all suggestions in one place. Personally, I'm more inclined to go with a more explicit and flexible approach where the user is required to provide complete file paths but let's see what others think. Regarding your
to the |
I don't think it should be an alternative, but rather it should be the way to specify sources. This is the convention we follow when specifying C/C++ sources for C stubs in OCaml libraries already. See #1788 for some background on this issue.
It doesn't seem right to have to specify dependencies manually in such a common situation. By the way, you may want to check the behaviour of |
Looks like right now dune automatically makes C compilation depend on *.h in the current directory (but not descendants). (by code inspection, I think |
I was wrong, it seems that the dependency on all .h files in subdirs is tracked with |
I've just made some edits to the proposal:
@nojb Yes, you can use |
It's also for special cases where header files are accessed relative to the source file directory, for instance via |
I'm tempted to abandon this proposal in favour of #2650. |
@diml, @aalekseyev and I would like to clean up and extend existing support for C/C++ libraries in Dune, which requires a way to describe the following information:
.a
file. This name can be used as a reference in theself_build_stubs_archive
field which could probably be aliased asc_archive
for simplicity. A possible further extension is to also supportpublic_name
as in OCaml libraries.We can describe the above using the following top-level
c_library
stanza:Here is the semantics:
*_names
in a sandbox (duplicate name matches are disallowed as in the current implementation). Allflags
will be passed to every invocation of the compiler;c_flags
will be passed when compiling C files andcxx_flags
will be passed when compiling C++ files. All the resulting objects are placed intoarchive_name.a
file.*include_dirs
will be available and tracked as dependencies. They will also appear in the command line in-I
flags. Note that you can refer to public headers of other (OCaml) libraries using the%{lib:another_lib}
syntax.extra_deps
will be available and tracked to support ad hoc include dependencies.One can also use the same stanza as a part of an OCaml library definition via
c_stubs
:Any comments/suggestions are welcome!
See a generalisation of this proposal in #2650.
The text was updated successfully, but these errors were encountered: