Bazel rules for GNU Bison.
load("@rules_bison//bison:bison.bzl", "bison") bison(name, src, bison_options, language, skeleton)
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 | |
src | A Bison source file. Unless language is set, the source's file extension determines whether Bison operates in C or C++ mode:
|
Label | 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 | [] |
language | Which language to generate the parser in. | String | 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 |
load("@rules_bison//bison:bison.bzl", "bison_cc_library") bison_cc_library(name, deps, src, bison_options, conlyopts, copts, cxxopts, include_prefix, language, linkstatic, skeleton, 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 | |
deps | A list of other C/C++ libraries to depend on. | List of labels | optional | [] |
src | A Bison source file. Unless language is set, the source's file extension determines whether Bison operates in C or C++ mode:
|
Label | 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 | [] |
conlyopts | Add these options to the C compilation command. See cc_library.conlyopts for more details. |
List of strings | optional | [] |
copts | Add these options to the C/C++ compilation command. See cc_library.copts for more details. |
List of strings | optional | [] |
cxxopts | Add these options to the C++ compilation command. See cc_library.cxxopts for more details. |
List of strings | optional | [] |
include_prefix | A prefix to add to the path of the generated header. See cc_library.include_prefix for more details. |
String | optional | "" |
language | Which language to generate the parser in. | 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 |
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 | "" |
load("@rules_bison//bison:bison.bzl", "bison_java_library") bison_java_library(name, deps, src, bison_options, skeleton)
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 | |
deps | A list of other Java libraries to depend on. | List of labels | optional | [] |
src | A Bison source file. | Label | 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 |
load("@rules_bison//bison:bison.bzl", "BisonToolchainInfo") BisonToolchainInfo(all_files, bison_tool, bison_env)
Provider for a Bison toolchain.
FIELDS
load("@rules_bison//bison:bison.bzl", "bison_register_toolchains") 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. | [] |
load("@rules_bison//bison:bison.bzl", "bison_toolchain") 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
load("@rules_bison//bison:bison.bzl", "bison_repository") 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 | 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). |
Dictionary: String -> String | optional | |
version | A supported version of GNU Bison. | String | required |
load("@rules_bison//bison:bison.bzl", "bison_toolchain_repository") 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 | 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). |
Dictionary: String -> String | optional |
bison_repository_ext = use_extension("@rules_bison//bison/extensions:bison_repository_ext.bzl", "bison_repository_ext") bison_repository_ext.repository(name, extra_copts, version)
Module extension for declaring dependencies on GNU Bison.
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.
bison = use_extension(
"@rules_bison//bison/extensions:bison_repository_ext.bzl",
"bison_repository_ext",
)
bison.repository(name = "bison", version = "3.3.2")
use_repo(bison, "bison")
register_toolchains("@bison//:toolchain")
TAG CLASSES
Attributes
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | An optional name for the repository. The name must be unique within the set of names registered by this extension. If unset, the repository name will default to "bison_v{version}" . |
Name | optional | "" |
extra_copts | Additional C compiler options to use when building GNU Bison. | List of strings | optional | [] |
version | A supported version of GNU Bison. | String | optional | "3.3.2" |