Julia Bazel rules

Rules

Aspects

Module Extensions

julia_binary

load("@rules_julia//julia:defs.bzl", "julia_binary")

julia_binary(name, deps, srcs, data, env, main)

A Julia executable.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsOther Julia libraries this target depends onList of labelsoptional[]
srcsJulia source files (.jl files).List of labelsrequired
dataAdditional files needed at runtimeList of labelsoptional[]
envEnvironment variables to set when running the binary. Supports $(location) expansion.Dictionary: String -> Stringoptional{}
mainThe main entrypoint file. If not specified, defaults to the only file in srcs, or a file matching the target name.LabeloptionalNone

julia_format_test

load("@rules_julia//julia:defs.bzl", "julia_format_test")

julia_format_test(name, config, target)

A rule for running JuliaFormatter on a Julia target.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
configThe config file (.JuliaFormatter.toml) containing JuliaFormatter settings.Labeloptional"@rules_julia//julia/settings:formatter_config"
targetThe target to run JuliaFormatter on.Labelrequired

julia_library

load("@rules_julia//julia:defs.bzl", "julia_library")

julia_library(name, deps, srcs, data)

A sharable Julia library or module.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsOther Julia libraries this target depends onList of labelsoptional[]
srcsJulia source files (.jl files)List of labelsrequired
dataAdditional files needed at runtimeList of labelsoptional[]

julia_standalone_binary

load("@rules_julia//julia:defs.bzl", "julia_standalone_binary")

julia_standalone_binary(name, binary)

A rule for converting a julia_binary to a standalone application.

This rule uses PackageCompiler.jl to create a standalone executable that includes the Julia runtime and all dependencies. The resulting application can be distributed and run on machines without Julia installed.

Dependencies are provided hermetically through Bazel - no network access required! PackageCompiler.jl and all Julia package dependencies are managed through the Bazel build system.

Example:

julia_binary(
    name = "my_app_bin",
    srcs = ["my_app.jl"],
    deps = ["//my/lib"],
)

julia_standalone_binary(
    name = "my_app",
    binary = ":my_app_bin",
)

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
binaryThe julia_binary target to convert into a standalone applicationLabelrequired

julia_test

load("@rules_julia//julia:defs.bzl", "julia_test")

julia_test(name, deps, srcs, data, env, main)

A Julia test executable.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsOther Julia libraries this target depends onList of labelsoptional[]
srcsJulia test source files (.jl files).List of labelsrequired
dataAdditional files needed at runtime for the testList of labelsoptional[]
envEnvironment variables to set when running the test. Supports $(location) expansion.Dictionary: String -> Stringoptional{}
mainThe main test entrypoint file. If not specified, defaults to the only file in srcs, or a file matching the target name.LabeloptionalNone

julia_toolchain

load("@rules_julia//julia:defs.bzl", "julia_toolchain")

julia_toolchain(name, julia, version)

A toolchain for building Julia targets.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
juliaThe path to the Julia binary (julia or julia.exe).Labelrequired
versionThe Julia version string (e.g., '1.12.5').Stringrequired

julia_format_aspect

load("@rules_julia//julia:defs.bzl", "julia_format_aspect")

julia_format_aspect()

An aspect for running JuliaFormatter on targets with Julia sources.

ASPECT ATTRIBUTES

ATTRIBUTES

julia

julia = use_extension("@rules_julia//julia:defs.bzl", "julia")

Bzlmod extensions for Julia