Bazel rules for GNU Bison.
bison(name, bison_options, skeleton, src)
Generate source code for a Bison parser.
This rule exists for special cases where the build needs to perform further
modification of the generated .c
/ .h
before compilation. Most users
will find the bison_cc_library
rule more convenient.
load("@rules_bison//bison:bison.bzl", "bison")
bison(
name = "hello",
src = "hello.y",
)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
bison_options | Additional options to pass to the bison command.These will be added to the command args immediately before the source file. |
List of strings | optional | [] |
skeleton | Specify the skeleton to use. This file is used as a template for rendering the generated parser. See the Bison documentation regarding the %skeleton directive for more details. |
Label | optional | None |
src | A Bison source file. The source's file extension will determine whether Bison operates in C or C++ mode:
|
Label | required |
bison_cc_library(name, bison_options, deps, include_prefix, linkstatic, skeleton, src, strip_include_prefix)
Generate a C/C++ library for a Bison parser.
Verbose descriptions of the parser are available in output group bison_report
.
load("@rules_bison//bison:bison.bzl", "bison_cc_library")
bison_cc_library(
name = "hello_lib",
src = "hello.y",
)
cc_binary(
name = "hello",
srcs = ["hello_main.c"],
deps = [":hello_lib"],
)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
bison_options | Additional options to pass to the bison command.These will be added to the command args immediately before the source file. |
List of strings | optional | [] |
deps | A list of other C/C++ libraries to depend on. | List of labels | optional | [] |
include_prefix | A prefix to add to the path of the generated header. See cc_library.include_prefix for more details. |
String | optional | "" |
linkstatic | Disable creation of a shared library output. See cc_library.linkstatic for more details. |
Boolean | optional | False |
skeleton | Specify the skeleton to use. This file is used as a template for rendering the generated parser. See the Bison documentation regarding the %skeleton directive for more details. |
Label | optional | None |
src | A Bison source file. The source's file extension will determine whether Bison operates in C or C++ mode:
|
Label | required | |
strip_include_prefix | A prefix to strip from the path of the generated header. See cc_library.strip_include_prefix for more details. |
String | optional | "" |
bison_java_library(name, bison_options, deps, skeleton, src)
Generate a Java library for a Bison parser.
Verbose descriptions of the parser are available in output group bison_report
.
load("@rules_bison//bison:bison.bzl", "bison_java_library")
bison_java_library(
name = "HelloParser",
src = "hello.y",
)
java_binary(
name = "HelloMain",
srcs = ["HelloMain.java"],
main_class = "HelloMain",
deps = [":HelloParser"],
)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
bison_options | Additional options to pass to the bison command.These will be added to the command args immediately before the source file. |
List of strings | optional | [] |
deps | A list of other Java libraries to depend on. | List of labels | optional | [] |
skeleton | Specify the skeleton to use. This file is used as a template for rendering the generated parser. See the Bison documentation regarding the %skeleton directive for more details. |
Label | optional | None |
src | A Bison source file. | Label | required |
bison_repository(name, extra_copts, repo_mapping, version)
Repository rule for GNU Bison.
The resulting repository will have a //bin:bison
executable target.
load("@rules_bison//bison:bison.bzl", "bison_repository")
bison_repository(
name = "bison_v3.3.2",
version = "3.3.2",
)
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 Bison. | 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 Bison. | String | required |
bison_toolchain_repository(name, bison_repository, repo_mapping)
Toolchain repository rule for Bison 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:bison
(an alias into the underlying [bison_repository
] (#bison_repository))//:toolchain
, which can be registered with Bazel.
load(
"@rules_bison//bison:bison.bzl",
"bison_repository",
"bison_toolchain_repository",
)
bison_repository(
name = "bison_v3.3.2",
version = "3.3.2",
)
bison_toolchain_repository(
name = "bison",
bison_repository = "@bison_v3.3.2",
)
register_toolchains("@bison//:toolchain")
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this repository. | Name | required | |
bison_repository | The name of a bison_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 |
BisonToolchainInfo(all_files, bison_tool, bison_env)
Provider for a Bison toolchain.
FIELDS
bison_register_toolchains(version, extra_copts)
A helper function for Bison toolchains registration.
This workspace macro will create a bison_repository
named bison_v{version}
and register it as a Bazel toolchain.
PARAMETERS
Name | Description | Default Value |
---|---|---|
version | A supported version of Bison. | "3.3.2" |
extra_copts | Additional C compiler options to use when building Bison. | [] |
bison_toolchain(ctx)
Returns the current BisonToolchainInfo
.
PARAMETERS
Name | Description | Default Value |
---|---|---|
ctx | A rule context, where the rule has a toolchain dependency on BISON_TOOLCHAIN_TYPE . |
none |
RETURNS