autoconf_hdr
Rules
autoconf_hdr
load("@rules_cc_autoconf//autoconf:autoconf_hdr.bzl", "autoconf_hdr")
autoconf_hdr(name, deps, out, defaults, defaults_exclude, defaults_include, inlines, mode,
substitutions, template)
Generate configuration headers from results provided by autoconf targets.
This rule takes check results from autoconf targets (via deps) and generates a header file.
The template file (if provided) is used to format the output header.
Example:
load("@rules_cc_autoconf//autoconf:autoconf.bzl", "autoconf")
load("@rules_cc_autoconf//autoconf:autoconf_hdr.bzl", "autoconf_hdr")
load("@rules_cc_autoconf//autoconf:checks.bzl", "checks")
autoconf(
name = "config_checks",
checks = [
checks.AC_CHECK_HEADER("stdio.h"),
checks.AC_CHECK_HEADER("stdlib.h"),
checks.AC_CHECK_FUNC("printf"),
],
)
autoconf_hdr(
name = "config",
out = "config.h",
deps = [":config_checks"],
template = "config.h.in",
)
Valid mode values:
"defines"(default): Only process defines (AC_DEFINE, AC_CHECK_*, etc.), not substitution variables (AC_SUBST). This is for config.h files."subst": Only process substitution variables (AC_SUBST), not defines. This is for subst.h files."all": Process both defines and substitution variables.
This allows you to run checks once and generate multiple header files from the same results.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | List of autoconf targets which provide check results. Results from all deps will be merged together, and duplicate define names will produce an error. If not provided, an empty results file will be created. | List of labels | optional | [] |
| out | The output config file (typically config.h). | Label; nonconfigurable | required | |
| defaults | Whether to include toolchain defaults. When False (the default), no toolchain defaults are included and only the explicit deps provide check results. When True, defaults from the autoconf toolchain are included, subject to filtering by defaults_include or defaults_exclude. | Boolean | optional | False |
| defaults_exclude | Labels to exclude from toolchain defaults. Only effective when defaults=True. If specified, defaults from these labels are excluded. Labels not found in the toolchain are silently ignored. Mutually exclusive with defaults_include. | List of labels | optional | [] |
| defaults_include | Labels to include from toolchain defaults. Only effective when defaults=True. If specified, only defaults from these labels are included. An error is raised if a specified label is not found in the toolchain. Mutually exclusive with defaults_exclude. | List of labels | optional | [] |
| inlines | A mapping of strings to files for replace within the content of the given template attribute.The exact string in the template is replaced with the content of the associated file. Any @VAR@ style placeholders in the inline file content will be replaced with their corresponding define values (package info, check results, etc.) after insertion. | Dictionary: String -> Label | optional | {} |
| mode | Processing mode that determines what should be replaced within the file. | String | optional | "defines" |
| substitutions | A mapping of exact strings to replacement values. Each entry performs an exact text replacement in the template - the key string is replaced with the value string. No special patterns or wrappers are added. Example: This would replace the exact string @MY_VERSION@ with 1.2.3, @BUILD_TYPE@ with release, and PLACEHOLDER_TEXT with actual_value. | Dictionary: String -> String | optional | {} |
| template | Template file (config.h.in) to use as base for generating the header file. The template is used to format the output header, but does not generate any checks. | Label | required |