1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16- """Bazel rule to run bison toolchain
16+ """Bazel rule to run bison
1717"""
1818
19+ load ("@bison//:bison.bzl" , "bison" )
20+
1921# Adapter rule around the @rules_bison toolchain.
2022def genyacc (
2123 name ,
@@ -26,21 +28,13 @@ def genyacc(
2628 extra_outs = []):
2729 """Build rule for generating C or C++ sources with Bison.
2830 """
29- native .genrule (
31+
32+ bison (
3033 name = name ,
3134 srcs = [src ],
3235 outs = [header_out , source_out ] + extra_outs ,
33- cmd = select ({
34- "//bazel:use_local_flex_bison_enabled" : "bison --defines=$(location " + header_out + ") --output-file=$(location " + source_out + ") " + " " .join (extra_options ) + " $<" ,
35- "@platforms//os:windows" : "win_bison.exe --defines=$(location " + header_out + ") --output-file=$(location " + source_out + ") " + " " .join (extra_options ) + " $<" ,
36- "//conditions:default" : "M4=$(M4) $(BISON) --defines=$(location " + header_out + ") --output-file=$(location " + source_out + ") " + " " .join (extra_options ) + " $<" ,
37- }),
38- toolchains = select ({
39- "//bazel:use_local_flex_bison_enabled" : [],
40- "@platforms//os:windows" : [],
41- "//conditions:default" : [
42- "@rules_bison//bison:current_bison_toolchain" ,
43- "@rules_m4//m4:current_m4_toolchain" ,
44- ],
45- }),
36+ args = [
37+ "--output-file=$(location " + source_out + ")" ,
38+ "--defines=$(location " + header_out + ")" ,
39+ ] + extra_options + ["$(location " + src + ")" ],
4640 )
0 commit comments