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

OPAM implementation deps ("virtual" libs), e.g. digestif #31

Open
mobileink opened this issue Sep 4, 2021 · 1 comment
Open

OPAM implementation deps ("virtual" libs), e.g. digestif #31

mobileink opened this issue Sep 4, 2021 · 1 comment

Comments

@mobileink
Copy link
Collaborator

digestif is an example of a library that affords multiple implementations. To use it one must depend on both digestif and either digestif.c or digestif.ocaml

We should be able to reduce this to a dependency on digestif and a build/config setting that automatically selects the implementation. This should work with the new "nocamlfind" version that generates BUILD.bazel files for opam libs. The following is currently generated for digestif

ocaml_import(
    name = "digestif",
    version = """0.9.0""",
    archive = select({
        "@ocaml//mode:bytecode": [

        "@ocaml//mode:native": [

    }),
    deps = [
        "@opam//lib/bigarray-compat",
        "@opam//lib/eqaf",
    ],
    visibility = ["//visibility:public"]
)

The idea is that we can add a select to the deps attribute to make digestif depend on an implementation, something like:

    struct = select({
        ":foo: "@opam/lib/digestif/c",
        ":bar": "@opam/lib/digestif/ocaml",
    }),

Here :foo and :bar could be platform constraints, for example.

@mobileink
Copy link
Collaborator Author

in the case of digestif, we can define build settings in the package, so e.g. the user can select an implementation by passing one of --@opam//lib/digestif:c or --@opam//lib/digestif:ocaml. default could be c, so the option would only be needed to switch to the ocaml impl.

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

1 participant