Dune: disable build on non-linux platforms

Hi there,

I’m building a package for bindings to a c library that can only be used on Linux systems. Does dune provide a way to check the OS version and stop the build and print a nice error message if the OS is not Linux?

I see that dune has variable to check the OS version with os_version variable. I’m not quite sure how to do the rest of this.

Cheers

Look for enabled_if in the dune file description at https://dune.readthedocs.io/en/stable/dune-files.html#dune.

Needless to say, try not to do this unless you are sure the library really is Linux-only. Often, many things are portable to BSDs and so on, and explicit build checks such as this prevent easy porting with patching those build constraints away.

@avsm, thank you I’ll check out the enabled_if feature.

This package will be bindings to libbpf, specifically the AF_XDP features. As far as I know this is Linux only right now, but it could be ported. You’re right though, I wouldn’t want to make this difficult for other developers to use if they could.