rules_dAPI docs @0.3.1

@rules_d//d:defs.bzl

Public API of D rules.

Rules

d_binary
AttributeTypeDescription
*namename

A unique name for this target.

srcslist of labels

List of D '.d' or '.di' source files.

Default: []
depslist of labels

List of dependencies.

Default: []
doptslist of strings

Compiler flags.

Default: []
importslist of strings

List of import paths.

Default: []
linkoptslist of strings

Linker flags passed via -L flags.

Default: []
string_importslist of strings

List of string import paths.

Default: []
string_srcslist of labels

List of string import source files.

Default: []
versionslist of strings

List of version identifiers.

Default: []
envdictionary: String → String

Environment variables for the binary at runtime. Subject of location and make variable expansion.

Default: {}
datalist of labels

List of files to be made available at runtime.

Default: []
d_library
AttributeTypeDescription
*namename

A unique name for this target.

srcslist of labels

List of D '.d' or '.di' source files.

Default: []
depslist of labels

List of dependencies.

Default: []
doptslist of strings

Compiler flags.

Default: []
importslist of strings

List of import paths.

Default: []
linkoptslist of strings

Linker flags passed via -L flags.

Default: []
string_importslist of strings

List of string import paths.

Default: []
string_srcslist of labels

List of string import source files.

Default: []
versionslist of strings

List of version identifiers.

Default: []
source_onlyboolean

If true, the source files are compiled, but not library is produced.

Default: False
d_test
AttributeTypeDescription
*namename

A unique name for this target.

srcslist of labels

List of D '.d' or '.di' source files.

Default: []
depslist of labels

List of dependencies.

Default: []
doptslist of strings

Compiler flags.

Default: []
importslist of strings

List of import paths.

Default: []
linkoptslist of strings

Linker flags passed via -L flags.

Default: []
string_importslist of strings

List of string import paths.

Default: []
string_srcslist of labels

List of string import source files.

Default: []
versionslist of strings

List of version identifiers.

Default: []
envdictionary: String → String

Environment variables for the binary at runtime. Subject of location and make variable expansion.

Default: {}
datalist of labels

List of files to be made available at runtime.

Default: []

@rules_d//d:extensions.bzl

Extensions for bzlmod.

Installs a d toolchain.
Every module can define a toolchain version under the default name, "d".
The latest of those versions will be selected (the rest discarded),
and will always be registered by rules_d.

Additionally, the root module can define arbitrarily many more toolchain versions under different
names (the latest version will be picked for each name) and can register them as it sees fit,
effectively overriding the default named toolchain due to toolchain resolution precedence.

Module Extensions

d
Tag Classes
toolchain
AttributeTypeDescription
namename

Base name for generated repositories, allowing more than one d toolchain to be registered.
Overriding the default is only permitted in the root module.

Default: "d"
*d_versionstring

Version of the compiler. "auto" will select latest known dmd or ldc compiler available for
the current platform. "dmd" or "ldc" will select the latest known version of the respective
compiler. If a specific version is desired, it can be specified as "dmd-2.100.0" or
"ldc-1.30.0".

@rules_d//d:repositories.bzl

Declare runtime dependencies

These are needed for local dev, and users must install them as well.
See https://docs.bazel.build/versions/main/skylark/deploying.html#dependencies

Functions & Macros

http_archive
Parameters
*name
kwargs
rules_d_dependencies
d_register_toolchains

Convenience macro for users which does typical setup.

  • create a repository for each built-in platform like "d_linux_amd64"
  • TODO: create a convenience repository for the host platform like "d_host"
  • create a repository exposing toolchains for each platform like "d_platforms"
  • register a toolchain pointing at each platform
    Users can avoid this macro and do these steps themselves, if they want more control.
Parameters
*name

base name for all created repos, like "d1_14"

register

whether to call through to native.register_toolchains.
Should be True for WORKSPACE users, but false when used under bzlmod extension

Default: True
kwargs

passed to each d_repositories call

Repository Rules

d_repositories

Fetch external tools needed for d toolchain

AttributeTypeDescription
*namename

A unique name for this repository.

repo_mappingdictionary: String → String

In WORKSPACE context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.

For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target).

This attribute is not supported in MODULE.bazel context (when invoking a repository rule inside a module extension's implementation function).

*d_versionstring
*platformstring

@rules_d//d:toolchain.bzl

This module implements the D toolchain rule.

Rules

d_toolchain

Defines a d compiler/runtime toolchain.

For usage see https://docs.bazel.build/versions/main/toolchains.html#defining-toolchains.

AttributeTypeDescription
*namename

A unique name for this target.

compiler_flagslist of strings

Compiler flags.

Default: []
*d_compilerlabel

The D compiler.

dub_toollabel

The dub package manager.

Default: None
linker_flagslist of strings

Linker flags.

Default: []
rdmd_toollabel

The rdmd compile and execute utility.

Default: None

Providers

DToolchainInfo

D compiler information.

Fields
compiler_flags

Default compiler flags.

d_compiler

The D compiler executable.

dub_tool

The dub package manager executable.

linker_flags

Default linker flags.

rdmd_tool

The rdmd compile and execute utility.