-
Notifications
You must be signed in to change notification settings - Fork 456
Closed
Labels
proposalRFC's that are awaiting discussion to be accepted or rejectedRFC's that are awaiting discussion to be accepted or rejected
Description
@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:
- The C/C++ library's name, i.e. the name of the resulting
.afile. This name can be used as a reference in theself_build_stubs_archivefield which could probably be aliased asc_archivefor simplicity. A possible further extension is to also supportpublic_nameas in OCaml libraries. - The set of all C/C++ files.
- The list of command-line flags: both common, as well as C and C++ specific ones.
- The set of include directories: again both common, as well as C and C++ specific ones.
We can describe the above using the following top-level c_library stanza:
(c_library
(archive_name my_lib)
(c_names file1 file2 ...)
(cxx_names file1 file2 ...)
(flags common_flag1 common_flag2 ...)
(c_flags c_flag1 c_flag2 ...)
(cxx_flags cxx_flag1 cxx_flag2 ...)
(include_dirs common_dir1 %{lib:another_lib} ...)
(c_include_dirs c_dir1 c_dir2 ...)
(cxx_include_dirs cxx_dir1 cxx_dir2 ...)
(extra_deps extra_file1 extra_file2 ...)
)
Here is the semantics:
- The C/C++ compiler is called on each file matching
*_namesin a sandbox (duplicate name matches are disallowed as in the current implementation). Allflagswill be passed to every invocation of the compiler;c_flagswill be passed when compiling C files andcxx_flagswill be passed when compiling C++ files. All the resulting objects are placed intoarchive_name.afile. - The header directories from
*include_dirswill be available and tracked as dependencies. They will also appear in the command line in-Iflags. Note that you can refer to public headers of other (OCaml) libraries using the%{lib:another_lib}syntax. - Additionally,
extra_depswill 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:
(library
...
(c_stubs (c_names ... ) ...)
...
)
Any comments/suggestions are welcome!
See a generalisation of this proposal in #2650.
Metadata
Metadata
Assignees
Labels
proposalRFC's that are awaiting discussion to be accepted or rejectedRFC's that are awaiting discussion to be accepted or rejected