Improve schema, support 'type', prep for 'headers' (breaking for WORKSPACE) (#23)

Improve the schema to specify a union over the binary kinds with more pedantic definitions. Add keyword args for `type` on archive binary kind and `headers` on all binary kinds when Bazel version is >= 7.1.0.

Note: this includes a breaking change for WORKSPACE users and requires loading bazel_features ahead of rules_multitool. Richer instructions for WORKSPACE usage will now be available in the release notes.
18 files changed
tree: 207f891d0f032405ed4a88f95841717b06286b03
  1. .bcr/
  2. .github/
  3. examples/
  4. multitool/
  5. .bazelignore
  6. .bazelrc
  7. .bazelversion
  8. .gitattributes
  9. .gitignore
  10. BUILD.bazel
  11. LICENSE
  12. lockfile.schema.json
  13. MODULE.bazel
  14. readme.md
  15. WORKSPACE.bazel
readme.md

rules_multitool

An ergonomic approach to defining a single tool target that resolves to a matching os and CPU architecture variant of the tool.

Usage

For a quickstart, see the module example or workspace example.

Define a lockfile that references the tools to load:

{
  "$schema": "https://raw.githubusercontent.com/theoremlp/rules_multitool/main/lockfile.schema.json",
  "tool-name": {
    "binaries": [
      {
        "kind": "file",
        "url": "https://...",
        "sha256": "sha256 of the file",
        "os": "linux|macos",
        "cpu": "x86_64|arm64"
      }
    ]
  }
}

The lockfile supports the following binary kinds:

  • file: the URL refers to a file to download

    • sha256: the sha256 of the downloaded file
  • archive: the URL referes to an archive to download, specify additional options:

    • file: executable file within the archive
    • sha256: the sha256 of the downloaded archive
  • pkg: the URL refers to a MacOS pkg archive to download, specify additional options:

    • file: executable file within the archive
    • sha256: the sha256 of the downloaded pkg archive

Save your lockfile and ensure the file is exported using export_files so that it's available to Bazel.

Bazel Module Usage

Once your lockfile is defined, load the ruleset in your MODULE.bazel and create a hub that refers to your lockfile:

bazel_dep(name = "rules_multitool", version = "0.0.0")

multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
multitool.hub(lockfile = "//:multitool.lock.json")
use_repo(multitool, "multitool")

Tools may then be accessed using @multitool//tools/tool-name.

Workspace Usage

Instructions for using with WORKSPACE may be found in release notes.