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

obazl v2 migration: opam pkg labels #11

Open
mobileink opened this issue Oct 5, 2021 · 1 comment
Open

obazl v2 migration: opam pkg labels #11

mobileink opened this issue Oct 5, 2021 · 1 comment

Comments

@mobileink
Copy link
Collaborator

Mapping from opam pkg labels to bazel labels:

  • single segment: @pkg//:pkg. E.g. ounit2 => @ounit2//:ounit2

  • multiple segments: seg1.seg2.seg3 => @seg1//seg2/seg3. E.g. ptime.clock.os => @ptime//clock/os

Special cases: the OPAM repo contains a handful of "pseudo-packages", which are effectively aliases for files included in the standard OCaml distribution. In OPAM switches these packages contain nothing but a META file that defines a package (and possibly subpackages) whose content properties point to the OCaml standard lib (which is $OPAM_SWITCH_PREFIX/lib/ocaml). I think they're retained for backward compatibility.

In OBazl we do not need such pseudo-packages; we just (pre)define targets in the @ocaml namespace. For example, instead of dynlink => @dynlink//:dynlink we have @ocaml//dynlink. This means that such "packages" cannot be overridden using e.g. --override_repository, but that should not be a problem; since they are included in the core distribution, devs should have no reason to override them.

So a conversion tool needs to special-case these mappings:

  • bigarray => @ocaml//bigarray
  • compiler-libs => @ocaml//compiler-libs
  • compiler-libs.common => @ocaml//compiler-libs/common
  • compiler-libs.bytecomp => @ocaml//compiler-libs/bytecomp
  • compiler-libs.optcomp => @ocaml//compiler-libs/optcomp
  • compiler-libs.toplevel => @ocaml//compiler-libs/toplevel
  • compiler-libs.native-toplevel => @ocaml//compiler-libs/native-toplevel
  • dynlink => @ocaml//dynlink
  • str => @ocaml//str
  • unix => @ocaml//unix

Threads are slightly more complicated. Historically we had threads.posix and threads.vm; now there is just `threads.

  • threads.posix => @ocaml//threads
  • threads.vm => @ocaml//threads (the vmthreads code no longer exists)

Note that these targets within the @ocaml namespace do not necessarily correspond to subdirectories in the opam switch. In fact most of them are aliased to separate repos. For example, the compiler-lib targets alias to @ocaml.compiler-libs. The intention is that the @ocaml labels provide a simple, uniform, idiomatic user interface, that does not use '.' in repo names. The repos they alias to include links, which makes globbing more straightforward. This is needed because each ocaml_import target needs to glob all the deps of the main (archive) files it provides.

@tek
Copy link
Member

tek commented Oct 5, 2021

awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants