Skip to content
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

Have a variable to point to installed library paths #3379

Open
samoht opened this issue Apr 16, 2020 · 5 comments
Open

Have a variable to point to installed library paths #3379

samoht opened this issue Apr 16, 2020 · 5 comments
Assignees

Comments

@samoht
Copy link
Member

samoht commented Apr 16, 2020

Related to #1185 but a bit simpler.

In a few places I would like to get the place of where the current library (or one of the already present libraries) is installed. To do this I have come up with this very inelegant solution, which seems to work fine:

(rule
  (target install-dir)
  (action (with-stdout-to install-dir
    (bash "echo $(dirname %{lib:<lib>:META})"))))

And now other rules could just (:include install-dir) when they want to refer to the path where <lib> is installed.

Is there any way to make it simpler? E.g. by expanding %{lib:<lib>} to the parent directory of %{lib:<lib>:META} or %{lib:<lib>:dune-package} ?

@ghost
Copy link

ghost commented Apr 20, 2020

There is no way at the moment. We considered it in the past, however it is a bit dodgy as it provides an easy way for users to mess up their build. What is your use case?

@samoht
Copy link
Member Author

samoht commented Apr 20, 2020

I want my project to install the C flags that users should use when compiling C objects using that library.

For instance, I want <my-lib> to install a file named cflags that can be included easily:

(-isystem %{lib:<my-lib>} -L%{lib:<my-lib>})

And users will just have to write:

(foreign_library ... (flags (:include %{lib:<my-lib>:cflags}))

Note that %{lib:<my-lib>} coud either be part of cflags and be expended when it is used (but currently dune complains with Error: %{lib:..} isn't allowed in this position) or be expanded directly when installed the file (I'm doing that at the moment and it seems to work). Note also that (:include %{lib:<my-lib>:cflags}) doesn't work as you need to make a copy first.

@ghost
Copy link

ghost commented Apr 22, 2020

I see. So you basically want to provide a set of flags as a library? I'm wondering if we shouldn't provide this high-level feature directly. After all, the compiler itself provide a way to distribute link flags with a library.

And also, I'm generally not excited by giving too many low-level features as it makes it very easy to mess things up :)

@samoht
Copy link
Member Author

samoht commented Apr 22, 2020

Installing C flags for a library would be very useful. In my use-case I need to use these to compile a C project, so storing them in the cma/cmxa is not very practical, but having an easier way to handle these would be very useful. Not that you usually 2 sets of flags, one for compile-time, one for link-time.

@ghost
Copy link

ghost commented Apr 28, 2020

Alright, let's look into this then. @voodoos I'm assigning you this issue since this seems useful for Tarides

@ghost ghost assigned voodoos Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants