Bazel rules for the m4 macro expander.
m4(name, freeze_state, m4_options, output, reload_state, srcs)
Perform macro expansion to produce an output file.
This rule blocks the of execution shell commands (such as syscmd
) by default.
To enable expansion of a file containing shell commands, set the m4_syscmd
target feature.
load("@rules_m4//m4:m4.bzl", "m4")
m4(
name = "m4_example.txt",
srcs = ["m4_example.in.txt"],
)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
freeze_state | Optional output file for GNU M4 frozen state. Must have extension .m4f . |
Label | optional | |
m4_options | Additional options to pass to the m4 command.These will be added to the command args immediately before the source files. |
List of strings | optional | [] |
output | File to write output to. If unset, defaults to the rule name. | Label | optional | |
reload_state | Optional input file for GNU M4 frozen state. Must have extension .m4f . |
Label | optional | None |
srcs | List of source files to macro-expand. | List of labels | required |
m4_repository(name, extra_copts, repo_mapping, version)
Repository rule for GNU M4.
The resulting repository will have a //bin:m4
executable target.
load("@rules_m4//m4:m4.bzl", "m4_repository")
m4_repository(
name = "m4_v1.4.18",
version = "1.4.18",
)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this repository. | Name | required | |
extra_copts | Additional C compiler options to use when building GNU M4. | List of strings | optional | [] |
repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>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 ). |
Dictionary: String -> String | required | |
version | A supported version of GNU M4. | String | required |
m4_toolchain_repository(name, m4_repository, repo_mapping)
Toolchain repository rule for m4 toolchains.
Toolchain repositories add a layer of indirection so that Bazel can resolve toolchains without downloading additional dependencies.
The resulting repository will have the following targets:
//bin:m4
(an alias into the underlyingm4_repository
)//:toolchain
, which can be registered with Bazel.
load("@rules_m4//m4:m4.bzl", "m4_repository", "m4_toolchain_repository")
m4_repository(
name = "m4_v1.4.18",
version = "1.4.18",
)
m4_toolchain_repository(
name = "m4",
m4_repository = "@m4_v1.4.18",
)
register_toolchains("@m4//:toolchain")
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this repository. | Name | required | |
m4_repository | The name of an m4_repository . |
String | required | |
repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>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 ). |
Dictionary: String -> String | required |
M4ToolchainInfo(all_files, m4_tool, m4_env)
Provider for an m4 toolchain.
FIELDS
m4_register_toolchains(version, extra_copts)
A helper function for m4 toolchains registration.
This workspace macro will create a m4_repository
named
m4_v{version}
and register it as a Bazel toolchain.
PARAMETERS
Name | Description | Default Value |
---|---|---|
version | A supported version of GNU M4. | "1.4.18" |
extra_copts | Additional C compiler options to use when building GNU M4. | [] |
m4_toolchain(ctx)
Returns the current M4ToolchainInfo
.
PARAMETERS
Name | Description | Default Value |
---|---|---|
ctx | A rule context, where the rule has a toolchain dependency on M4_TOOLCHAIN_TYPE . |
none |
RETURNS
An M4ToolchainInfo
.