- Notifications
You must be signed in to change notification settings - Fork7
Bazel rules to generate java files with JFlex
License
jflex-de/bazel_rules
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This repository offers two rules for projects using theBazel build system:
Rule to generate java source files from a lexer specification, withJFlex
Rule to generate java source files from a parser specification, withCUP
This is not an officially supported Google product.
Seebazelbuild/rules_jvm_external.
Load thebazel_rules in yourWORKSPACE
fileand addJFLEX_ARTIFACTS
in yourmaven_install
rule:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")load("@rules_jvm_external//:defs.bzl", "maven_install")http_archive( name = "jflex_rules", sha256 = "c4d68bde12f47af86b6f80a34dd55c67e82cf77b7ff2317cb472c07b1d09a6da", strip_prefix = "bazel_rules-1.9.1", url = "https://github.com/jflex-de/bazel_rules/archive/v1.9.1.tar.gz",)load("@jflex_rules//jflex:deps.bzl", "JFLEX_ARTIFACTS")maven_install( name = "maven", artifacts = JFLEX_ARTIFACTS, maven_install_json = "//:maven_install.json", repositories = [ "https://jcenter.bintray.com/", "https://maven.google.com", "https://repo1.maven.org/maven2", ],)
If this is the first time you usemaven_install
, you need to generate themaven_install.json
with
bazel run @maven//:pin
If you already usedmaven_install
before, you need to update the pinned artifacts with:
bazel run @unpinned_maven//:pin
load("@jflex_rules//jflex:jflex.bzl", "jflex")load("@jflex_rules//cup:cup.bzl", "cup")jflex( name = "", # Choose a rule name srcs = [], # A list of flex specifications outputs = [], # List of expected generated files)cup( name = "", # Choose a rule name src = "", # Grammar specification)
As usual, these rules can be used as one of thesrcs
of another rules, such as ajava_library
.
For more details, seecup andjflex.
├── assets → assets for the web site├── cup → contains the `cup.bzl` Skylark extension├── java → main Java source code│ └── jflex│ └── examples → examples│ ├── calculator → integration of JFlex and CUP│ └── helloworld → simple lexer├── javatests → tests of the examples├── jflex → contains the `jflex.bzl` Skylark extension└── third_party → Aliases for third-party libraries
About
Bazel rules to generate java files with JFlex