Skip to content

obazl/tools_obazl

Repository files navigation

tools_obazl

Warning
Documentation is woefully outdated. I’m working on it.

A collection of Bazel tools, mainly for OCaml development using OBazl rules_ocaml.

Getting started

Start by installing bazelisk.

  1. Put this at the root of your project:

.bazelrc
common --registry=https://raw.githubusercontent.com/obazl/registry/main/
common --registry=https://bcr.bazel.build
MODULE.bazel
module(
    name = "mymodule",
    version = "0.1.0",
    compatibility_level = 0,
    bazel_compatibility = [">=6.0.0"]
)
bazel_dep(name = "tools_obazl", version = "x.y.x",   (1)
               repo_name = "obazl"                  (2)
          dev_dependency = True)
  1. See Releases page for latest version.

  2. This makes the repo accessible as @obazl rather than @tools_obazl.

Now run the following commands:

$ bazel run @obazl//new:workspace

tools

@obazl//new:workspace

Initializes new workspace.

$ bazel run @obazl//new:workspace

Alias: @obazl//new:ws

Installs:

  • .bazelignore

  • .bazeliskrc

  • .bazelversion

  • .bazelrc

  • .config/gitignore

  • .config/miblrc

  • .config/user.bazelrc

  • BUILD.bazel

  • BUILD.bzl

  • WORKSPACE.bazel

  • WORKSPACE.bzl

  • bzl/BUILD.bazel

  • bzl/host/BUILD.bazel

  • COSWITCH.bzl ???

@obazl//new:package

Alias: @obazl//new:pkg

@obazl//convert

Convert dune files to BUILD.bazel files.

see also

mibl

@mibl//coswitch

Obsolete?

bazel run @mibl//coswitch -- -p <pkg>

opam

@opam//shared:refresh

misc

  • tokenize tokenizes a string. Default separator is whitespace.

  • load( "@tools_bazel//tools/functions:strings.bzl", "tokenize")

  • tokenize("foo bar") ⇒ ["foo", "bar"].

  • tokenize("foo_bar", sep="_") ⇒ ["foo", "bar"].

  • get_xdg(repo_ctx) returns multival: home, XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME