All Projects → jin → rules_ocaml

jin / rules_ocaml

Licence: Apache-2.0 license
OCaml build rules for Bazel

Programming Languages

Starlark
911 projects

Projects that are alternatives of or similar to rules ocaml

Rules kotlin
Bazel rules for Kotlin
Stars: ✭ 235 (+518.42%)
Mutual labels:  bazel, bazel-rules
Rules kotlin
Bazel rules for Kotlin
Stars: ✭ 162 (+326.32%)
Mutual labels:  bazel, bazel-rules
Bazel Skylib
Common useful functions and rules for Bazel
Stars: ✭ 153 (+302.63%)
Mutual labels:  bazel, bazel-rules
rules proto grpc
Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
Stars: ✭ 201 (+428.95%)
Mutual labels:  bazel, bazel-rules
rules openapi
🍃 bazel rules for generating code from openapi specifications
Stars: ✭ 49 (+28.95%)
Mutual labels:  bazel, bazel-rules
Rules apple line
LINE's Apple rules for Bazel
Stars: ✭ 151 (+297.37%)
Mutual labels:  bazel, bazel-rules
Rules k8s
This repository contains rules for interacting with Kubernetes configurations / clusters.
Stars: ✭ 222 (+484.21%)
Mutual labels:  bazel, bazel-rules
Rules nixpkgs
Rules for importing Nixpkgs packages into Bazel.
Stars: ✭ 88 (+131.58%)
Mutual labels:  bazel, bazel-rules
Rules apple
Bazel rules to build apps for Apple platforms.
Stars: ✭ 217 (+471.05%)
Mutual labels:  bazel, bazel-rules
Rules protobuf
Bazel rules for building protocol buffers and gRPC services (java, c++, go, ...)
Stars: ✭ 206 (+442.11%)
Mutual labels:  bazel, bazel-rules
Rules rust
Rust rules for Bazel
Stars: ✭ 241 (+534.21%)
Mutual labels:  bazel, bazel-rules
bazel-latex
Bazel build system rules for LaTeX
Stars: ✭ 67 (+76.32%)
Mutual labels:  bazel, bazel-rules
Dbx build tools
Dropbox's Bazel rules and tools
Stars: ✭ 119 (+213.16%)
Mutual labels:  bazel, bazel-rules
Rules swift
Bazel rules to build Swift on Apple and Linux platforms
Stars: ✭ 151 (+297.37%)
Mutual labels:  bazel, bazel-rules
Bazel Tools
Reusable bits for Bazel
Stars: ✭ 109 (+186.84%)
Mutual labels:  bazel, bazel-rules
Rules python
Experimental Bazel Python Rules
Stars: ✭ 233 (+513.16%)
Mutual labels:  bazel, bazel-rules
Rules grafana
Bazel rules for building Grafana dashboards
Stars: ✭ 46 (+21.05%)
Mutual labels:  bazel, bazel-rules
Bazel Linting System
🌿💚 Experimental system for registering, configuring, and invoking source-code linters in Bazel.
Stars: ✭ 63 (+65.79%)
Mutual labels:  bazel, bazel-rules
Rules haskell
Haskell rules for Bazel.
Stars: ✭ 196 (+415.79%)
Mutual labels:  bazel, bazel-rules
bazel-maven-proxy
A local (read-only) proxy for Bazel to access Maven resources behind a secure repository or from the local Maven repository
Stars: ✭ 22 (-42.11%)
Mutual labels:  bazel, bazel-rules

OCaml rules for Bazel

Rules

Overview

Build OCaml with Bazel. Very experimental.

Setup

Add the following to your WORKSPACE file.

git_repository(
    name = "io_bazel_rules_ocaml",
    remote = "https://github.com/jin/rules_ocaml.git",
    commit = "7a0a6e5226af5f09eb6e3379b901d8f2ffdb8bbf",
)

load("@io_bazel_rules_ocaml//ocaml:repo.bzl", "ocaml_repositories")
ocaml_repositories(
    opam_packages = {
        # Put your OPAM dependencies here
        "lwt": "3.1.0",
        "yojson": "1.4.0",
    },
)

and this to your BUILD files.

load("@io_bazel_rules_ocaml//ocaml:ocaml.bzl", "ocaml_native_binary", "ocaml_bytecode_binary", "ocaml_interface")

ocaml_repositories() will download and compile the OCaml toolchain, including ocamlbuild, ocamlfind and OPAM itself, as the official source doesn't release binaries directly and requires the use of OPAM for installations.

The initial load time of toolchain compilation will take a few minutes and will not happen again for the same project.

Rules

ocaml_native_binary/ocaml_bytecode_binary

Generates a native binary using ocamlopt or bytecode binary using ocamlc.

ocaml_native_library(name, srcs, src_root, opam_packages)
ocaml_bytecode_library(name, srcs, src_root, opam_packages)

Example

ocaml_native_binary(
    name = "hello_world",
    srcs = glob(["examples/*.ml"]),
    src_root = "examples/hello_world.ml",
    opam_packages = ["yojson", "lwt"],
)

ocaml_bytecode_binary(
    name = "other_binary",
    srcs = [
      "examples/foo.ml",
      "examples/bar.ml",
      "examples/entry.ml",
    ],
    src_root = "examples/entry.ml",
    opam_packages = ["pkg_foo", "pkg_bar"],
)
Attributes
name

Name, required

A unique name for this target

srcs

List of labels, required

List of OCaml .ml source files used to build the library

src_root

Label, optional

The OCaml .ml source file used for the binary's entry point.

Defaults to main.ml if not specified.

opam_packages

List of strings, optional

The name of the OPAM package dependencies required by this binary.

The packages (and their versions) must already be defined in your WORKSPACE file's ocaml_repositories().

ocaml_interface

Generates a .mli file of the source file.

ocaml_interface(name, src)
Attributes
name

Name, required

A unique name for this target

src

Label

The OCaml .ml source file used for generating the interface file

Example

ocaml_interface(
    name = "hello_world_interface",
    src = "examples/hello_world.ml",
)

Projects using rules_ocaml

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].